[PATCH] tpm: update bios log code for 1.2

The acpi table which contains the BIOS log events was updated for 1.2.
There are now client and server modes as defined in the specifications with
slightly different formats. Additionally, the start field was even too
small for the 1.1 version but had been working anyway. This patch updates
the code to deal with any of the three types of headers probperly (1.1, 1.2
client and 1.2 server).

Signed-off-by: Kylie Hall <kjhall@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Kylene Jo Hall and committed by Linus Torvalds 8b006db6 b09d5300

+37 -12
+37 -12
drivers/char/tpm/tpm_bios.c
··· 29 #define MAX_TEXT_EVENT 1000 /* Max event string length */ 30 #define ACPI_TCPA_SIG "TCPA" /* 0x41504354 /'TCPA' */ 31 32 struct tpm_bios_log { 33 void *bios_event_log; 34 void *bios_event_log_end; ··· 41 42 struct acpi_tcpa { 43 struct acpi_table_header hdr; 44 - u16 reserved; 45 - u32 log_max_len __attribute__ ((packed)); 46 - u32 log_start_addr __attribute__ ((packed)); 47 }; 48 49 struct tcpa_event { ··· 393 struct acpi_tcpa *buff; 394 acpi_status status; 395 struct acpi_table_header *virt; 396 397 if (log->bios_event_log != NULL) { 398 printk(KERN_ERR ··· 414 return -EIO; 415 } 416 417 - if (buff->log_max_len == 0) { 418 printk(KERN_ERR "%s: ERROR - TCPA log area empty\n", __func__); 419 return -EIO; 420 } 421 422 /* malloc EventLog space */ 423 - log->bios_event_log = kmalloc(buff->log_max_len, GFP_KERNEL); 424 if (!log->bios_event_log) { 425 - printk 426 - ("%s: ERROR - Not enough Memory for BIOS measurements\n", 427 - __func__); 428 return -ENOMEM; 429 } 430 431 - log->bios_event_log_end = log->bios_event_log + buff->log_max_len; 432 433 - acpi_os_map_memory(buff->log_start_addr, buff->log_max_len, (void *) &virt); 434 435 - memcpy(log->bios_event_log, virt, buff->log_max_len); 436 437 - acpi_os_unmap_memory(virt, buff->log_max_len); 438 return 0; 439 } 440
··· 29 #define MAX_TEXT_EVENT 1000 /* Max event string length */ 30 #define ACPI_TCPA_SIG "TCPA" /* 0x41504354 /'TCPA' */ 31 32 + enum bios_platform_class { 33 + BIOS_CLIENT = 0x00, 34 + BIOS_SERVER = 0x01, 35 + }; 36 + 37 struct tpm_bios_log { 38 void *bios_event_log; 39 void *bios_event_log_end; ··· 36 37 struct acpi_tcpa { 38 struct acpi_table_header hdr; 39 + u16 platform_class; 40 + union { 41 + struct client_hdr { 42 + u32 log_max_len __attribute__ ((packed)); 43 + u64 log_start_addr __attribute__ ((packed)); 44 + } client; 45 + struct server_hdr { 46 + u16 reserved; 47 + u64 log_max_len __attribute__ ((packed)); 48 + u64 log_start_addr __attribute__ ((packed)); 49 + } server; 50 + }; 51 }; 52 53 struct tcpa_event { ··· 379 struct acpi_tcpa *buff; 380 acpi_status status; 381 struct acpi_table_header *virt; 382 + u64 len, start; 383 384 if (log->bios_event_log != NULL) { 385 printk(KERN_ERR ··· 399 return -EIO; 400 } 401 402 + switch(buff->platform_class) { 403 + case BIOS_SERVER: 404 + len = buff->server.log_max_len; 405 + start = buff->server.log_start_addr; 406 + break; 407 + case BIOS_CLIENT: 408 + default: 409 + len = buff->client.log_max_len; 410 + start = buff->client.log_start_addr; 411 + break; 412 + } 413 + if (!len) { 414 printk(KERN_ERR "%s: ERROR - TCPA log area empty\n", __func__); 415 return -EIO; 416 } 417 418 /* malloc EventLog space */ 419 + log->bios_event_log = kmalloc(len, GFP_KERNEL); 420 if (!log->bios_event_log) { 421 + printk("%s: ERROR - Not enough Memory for BIOS measurements\n", 422 + __func__); 423 return -ENOMEM; 424 } 425 426 + log->bios_event_log_end = log->bios_event_log + len; 427 428 + acpi_os_map_memory(start, len, (void *) &virt); 429 430 + memcpy(log->bios_event_log, virt, len); 431 432 + acpi_os_unmap_memory(virt, len); 433 return 0; 434 } 435