Skip to content

Commit 85467f6

Browse files
stefanbergerJarkko Sakkinen
authored andcommitted
tpm: Add support for event log pointer found in TPM2 ACPI table
In case a TPM2 is attached, search for a TPM2 ACPI table when trying to get the event log from ACPI. If one is found, use it to get the start and length of the log area. This allows non-UEFI systems, such as SeaBIOS, to pass an event log when using a TPM2. Cc: Peter Huewe <[email protected]> Cc: Jason Gunthorpe <[email protected]> Signed-off-by: Stefan Berger <[email protected]> Reviewed-by: Jerry Snitselaar <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 1830611 commit 85467f6

File tree

1 file changed

+42
-21
lines changed
  • drivers/char/tpm/eventlog

1 file changed

+42
-21
lines changed

drivers/char/tpm/eventlog/acpi.c

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
4949
void __iomem *virt;
5050
u64 len, start;
5151
struct tpm_bios_log *log;
52-
53-
if (chip->flags & TPM_CHIP_FLAG_TPM2)
54-
return -ENODEV;
52+
struct acpi_table_tpm2 *tbl;
53+
struct acpi_tpm2_phy *tpm2_phy;
54+
int format;
5555

5656
log = &chip->log;
5757

@@ -61,23 +61,44 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
6161
if (!chip->acpi_dev_handle)
6262
return -ENODEV;
6363

64-
/* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */
65-
status = acpi_get_table(ACPI_SIG_TCPA, 1,
66-
(struct acpi_table_header **)&buff);
67-
68-
if (ACPI_FAILURE(status))
69-
return -ENODEV;
70-
71-
switch(buff->platform_class) {
72-
case BIOS_SERVER:
73-
len = buff->server.log_max_len;
74-
start = buff->server.log_start_addr;
75-
break;
76-
case BIOS_CLIENT:
77-
default:
78-
len = buff->client.log_max_len;
79-
start = buff->client.log_start_addr;
80-
break;
64+
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
65+
status = acpi_get_table("TPM2", 1,
66+
(struct acpi_table_header **)&tbl);
67+
if (ACPI_FAILURE(status))
68+
return -ENODEV;
69+
70+
if (tbl->header.length <
71+
sizeof(*tbl) + sizeof(struct acpi_tpm2_phy))
72+
return -ENODEV;
73+
74+
tpm2_phy = (void *)tbl + sizeof(*tbl);
75+
len = tpm2_phy->log_area_minimum_length;
76+
77+
start = tpm2_phy->log_area_start_address;
78+
if (!start || !len)
79+
return -ENODEV;
80+
81+
format = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2;
82+
} else {
83+
/* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */
84+
status = acpi_get_table(ACPI_SIG_TCPA, 1,
85+
(struct acpi_table_header **)&buff);
86+
if (ACPI_FAILURE(status))
87+
return -ENODEV;
88+
89+
switch (buff->platform_class) {
90+
case BIOS_SERVER:
91+
len = buff->server.log_max_len;
92+
start = buff->server.log_start_addr;
93+
break;
94+
case BIOS_CLIENT:
95+
default:
96+
len = buff->client.log_max_len;
97+
start = buff->client.log_start_addr;
98+
break;
99+
}
100+
101+
format = EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
81102
}
82103
if (!len) {
83104
dev_warn(&chip->dev, "%s: TCPA log area empty\n", __func__);
@@ -98,7 +119,7 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
98119
memcpy_fromio(log->bios_event_log, virt, len);
99120

100121
acpi_os_unmap_iomem(virt, len);
101-
return EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
122+
return format;
102123

103124
err:
104125
kfree(log->bios_event_log);

0 commit comments

Comments
 (0)