Skip to content

Commit 8b006db

Browse files
Kylene Jo HallLinus Torvalds
authored andcommitted
[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>
1 parent b09d530 commit 8b006db

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

drivers/char/tpm/tpm_bios.c

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,30 @@
2929
#define MAX_TEXT_EVENT 1000 /* Max event string length */
3030
#define ACPI_TCPA_SIG "TCPA" /* 0x41504354 /'TCPA' */
3131

32+
enum bios_platform_class {
33+
BIOS_CLIENT = 0x00,
34+
BIOS_SERVER = 0x01,
35+
};
36+
3237
struct tpm_bios_log {
3338
void *bios_event_log;
3439
void *bios_event_log_end;
3540
};
3641

3742
struct acpi_tcpa {
3843
struct acpi_table_header hdr;
39-
u16 reserved;
40-
u32 log_max_len __attribute__ ((packed));
41-
u32 log_start_addr __attribute__ ((packed));
44+
u16 platform_class;
45+
union {
46+
struct client_hdr {
47+
u32 log_max_len __attribute__ ((packed));
48+
u64 log_start_addr __attribute__ ((packed));
49+
} client;
50+
struct server_hdr {
51+
u16 reserved;
52+
u64 log_max_len __attribute__ ((packed));
53+
u64 log_start_addr __attribute__ ((packed));
54+
} server;
55+
};
4256
};
4357

4458
struct tcpa_event {
@@ -379,6 +393,7 @@ static int read_log(struct tpm_bios_log *log)
379393
struct acpi_tcpa *buff;
380394
acpi_status status;
381395
struct acpi_table_header *virt;
396+
u64 len, start;
382397

383398
if (log->bios_event_log != NULL) {
384399
printk(KERN_ERR
@@ -399,27 +414,37 @@ static int read_log(struct tpm_bios_log *log)
399414
return -EIO;
400415
}
401416

402-
if (buff->log_max_len == 0) {
417+
switch(buff->platform_class) {
418+
case BIOS_SERVER:
419+
len = buff->server.log_max_len;
420+
start = buff->server.log_start_addr;
421+
break;
422+
case BIOS_CLIENT:
423+
default:
424+
len = buff->client.log_max_len;
425+
start = buff->client.log_start_addr;
426+
break;
427+
}
428+
if (!len) {
403429
printk(KERN_ERR "%s: ERROR - TCPA log area empty\n", __func__);
404430
return -EIO;
405431
}
406432

407433
/* malloc EventLog space */
408-
log->bios_event_log = kmalloc(buff->log_max_len, GFP_KERNEL);
434+
log->bios_event_log = kmalloc(len, GFP_KERNEL);
409435
if (!log->bios_event_log) {
410-
printk
411-
("%s: ERROR - Not enough Memory for BIOS measurements\n",
412-
__func__);
436+
printk("%s: ERROR - Not enough Memory for BIOS measurements\n",
437+
__func__);
413438
return -ENOMEM;
414439
}
415440

416-
log->bios_event_log_end = log->bios_event_log + buff->log_max_len;
441+
log->bios_event_log_end = log->bios_event_log + len;
417442

418-
acpi_os_map_memory(buff->log_start_addr, buff->log_max_len, (void *) &virt);
443+
acpi_os_map_memory(start, len, (void *) &virt);
419444

420-
memcpy(log->bios_event_log, virt, buff->log_max_len);
445+
memcpy(log->bios_event_log, virt, len);
421446

422-
acpi_os_unmap_memory(virt, buff->log_max_len);
447+
acpi_os_unmap_memory(virt, len);
423448
return 0;
424449
}
425450

0 commit comments

Comments
 (0)