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