* [PATCH 2/4] Read TCG log from TPM2 table
@ 2017-03-29 7:43 Petr Vandrovec
[not found] ` <20170329074326.jxeoxtn4tbjjwcl2-WbvboCQVrrgDIl+Cyo8nDyLysJ1jNyTM@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Petr Vandrovec @ 2017-03-29 7:43 UTC (permalink / raw)
To: Peter Huewe; +Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
From: Petr Vandrovec <petr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
Latest draft of TPM 2 ACPI specification added TCG log start/length
to the TPM2 ACPI table. So Linux kernel can now read it without
having to get involved with boot loader, same way TPM1/TCPA tables
work.
Signed-off-by: Petr Vandrovec <petr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
drivers/char/tpm/tpm_acpi.c | 70 ++++++++++++++++++++++++++++-----------------
1 file changed, 43 insertions(+), 27 deletions(-)
diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
index 169edf3ce86d..e48b1503220c 100644
--- a/drivers/char/tpm/tpm_acpi.c
+++ b/drivers/char/tpm/tpm_acpi.c
@@ -48,46 +48,62 @@ struct acpi_tcpa {
/* read binary bios log */
int tpm_read_log_acpi(struct tpm_chip *chip)
{
- struct acpi_tcpa *buff;
acpi_status status;
void __iomem *virt;
u64 len, start;
struct tpm_bios_log *log;
- if (chip->flags & TPM_CHIP_FLAG_TPM2)
- return -ENODEV;
-
- log = &chip->log;
-
/* Unfortuntely ACPI does not associate the event log with a specific
* TPM, like PPI. Thus all ACPI TPMs will read the same log.
*/
if (!chip->acpi_dev_handle)
return -ENODEV;
- /* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */
- status = acpi_get_table(ACPI_SIG_TCPA, 1,
- (struct acpi_table_header **)&buff);
-
- if (ACPI_FAILURE(status))
- return -ENODEV;
-
- switch(buff->platform_class) {
- case BIOS_SERVER:
- len = buff->server.log_max_len;
- start = buff->server.log_start_addr;
- break;
- case BIOS_CLIENT:
- default:
- len = buff->client.log_max_len;
- start = buff->client.log_start_addr;
- break;
- }
- if (!len) {
- dev_warn(&chip->dev, "%s: TCPA log area empty\n", __func__);
- return -EIO;
+ if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+ struct acpi_table_tpm2 *buff;
+
+ /* Find TPM2 entry in RSDT (ACPI_LOGICAL_ADDRESSING) */
+ status = acpi_get_table(ACPI_SIG_TPM2, 1,
+ (struct acpi_table_header **)&buff);
+
+ if (ACPI_FAILURE(status) || buff->header.length < ACPI_TPM2_SIZE_WITH_LOG)
+ return -ENODEV;
+
+ len = buff->minimum_log_length;
+ start = buff->log_address;
+ if (!len) {
+ dev_warn(&chip->dev, "%s: TPM2 log area empty\n", __func__);
+ return -EIO;
+ }
+ } else {
+ struct acpi_tcpa *buff;
+
+ /* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */
+ status = acpi_get_table(ACPI_SIG_TCPA, 1,
+ (struct acpi_table_header **)&buff);
+
+ if (ACPI_FAILURE(status))
+ return -ENODEV;
+
+ switch(buff->platform_class) {
+ case BIOS_SERVER:
+ len = buff->server.log_max_len;
+ start = buff->server.log_start_addr;
+ break;
+ case BIOS_CLIENT:
+ default:
+ len = buff->client.log_max_len;
+ start = buff->client.log_start_addr;
+ break;
+ }
+ if (!len) {
+ dev_warn(&chip->dev, "%s: TCPA log area empty\n", __func__);
+ return -EIO;
+ }
}
+ log = &chip->log;
+
/* malloc EventLog space */
log->bios_event_log = kmalloc(len, GFP_KERNEL);
if (!log->bios_event_log)
--
2.11.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 2+ messages in thread[parent not found: <20170329074326.jxeoxtn4tbjjwcl2-WbvboCQVrrgDIl+Cyo8nDyLysJ1jNyTM@public.gmane.org>]
* Re: [PATCH 2/4] Read TCG log from TPM2 table [not found] ` <20170329074326.jxeoxtn4tbjjwcl2-WbvboCQVrrgDIl+Cyo8nDyLysJ1jNyTM@public.gmane.org> @ 2017-04-05 11:32 ` Jarkko Sakkinen 0 siblings, 0 replies; 2+ messages in thread From: Jarkko Sakkinen @ 2017-04-05 11:32 UTC (permalink / raw) To: Petr Vandrovec; +Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f On Wed, Mar 29, 2017 at 12:43:26AM -0700, Petr Vandrovec wrote: > From: Petr Vandrovec <petr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> > > Latest draft of TPM 2 ACPI specification added TCG log start/length > to the TPM2 ACPI table. So Linux kernel can now read it without > having to get involved with boot loader, same way TPM1/TCPA tables > work. > > Signed-off-by: Petr Vandrovec <petr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> > --- > drivers/char/tpm/tpm_acpi.c | 70 ++++++++++++++++++++++++++++----------------- > 1 file changed, 43 insertions(+), 27 deletions(-) > > diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c > index 169edf3ce86d..e48b1503220c 100644 > --- a/drivers/char/tpm/tpm_acpi.c > +++ b/drivers/char/tpm/tpm_acpi.c > @@ -48,46 +48,62 @@ struct acpi_tcpa { > /* read binary bios log */ > int tpm_read_log_acpi(struct tpm_chip *chip) > { > - struct acpi_tcpa *buff; > acpi_status status; > void __iomem *virt; > u64 len, start; > struct tpm_bios_log *log; > > - if (chip->flags & TPM_CHIP_FLAG_TPM2) > - return -ENODEV; > - > - log = &chip->log; > - > /* Unfortuntely ACPI does not associate the event log with a specific > * TPM, like PPI. Thus all ACPI TPMs will read the same log. > */ > if (!chip->acpi_dev_handle) > return -ENODEV; > > - /* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ > - status = acpi_get_table(ACPI_SIG_TCPA, 1, > - (struct acpi_table_header **)&buff); > - > - if (ACPI_FAILURE(status)) > - return -ENODEV; > - > - switch(buff->platform_class) { > - case BIOS_SERVER: > - len = buff->server.log_max_len; > - start = buff->server.log_start_addr; > - break; > - case BIOS_CLIENT: > - default: > - len = buff->client.log_max_len; > - start = buff->client.log_start_addr; > - break; > - } > - if (!len) { > - dev_warn(&chip->dev, "%s: TCPA log area empty\n", __func__); > - return -EIO; > + if (chip->flags & TPM_CHIP_FLAG_TPM2) { > + struct acpi_table_tpm2 *buff; > + > + /* Find TPM2 entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ > + status = acpi_get_table(ACPI_SIG_TPM2, 1, > + (struct acpi_table_header **)&buff); > + > + if (ACPI_FAILURE(status) || buff->header.length < ACPI_TPM2_SIZE_WITH_LOG) > + return -ENODEV; > + > + len = buff->minimum_log_length; > + start = buff->log_address; > + if (!len) { > + dev_warn(&chip->dev, "%s: TPM2 log area empty\n", __func__); > + return -EIO; > + } > + } else { > + struct acpi_tcpa *buff; > + > + /* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ > + status = acpi_get_table(ACPI_SIG_TCPA, 1, > + (struct acpi_table_header **)&buff); > + > + if (ACPI_FAILURE(status)) > + return -ENODEV; > + > + switch(buff->platform_class) { > + case BIOS_SERVER: > + len = buff->server.log_max_len; > + start = buff->server.log_start_addr; > + break; > + case BIOS_CLIENT: > + default: > + len = buff->client.log_max_len; > + start = buff->client.log_start_addr; > + break; > + } > + if (!len) { > + dev_warn(&chip->dev, "%s: TCPA log area empty\n", __func__); > + return -EIO; > + } > } > > + log = &chip->log; > + > /* malloc EventLog space */ > log->bios_event_log = kmalloc(len, GFP_KERNEL); > if (!log->bios_event_log) > -- > 2.11.0 > It would be a better idea to rename the existing function as tpm1_read_log_acpi() and add a new function called tpm2_read_log_acpi(). /Jarkko ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-05 11:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-29 7:43 [PATCH 2/4] Read TCG log from TPM2 table Petr Vandrovec
[not found] ` <20170329074326.jxeoxtn4tbjjwcl2-WbvboCQVrrgDIl+Cyo8nDyLysJ1jNyTM@public.gmane.org>
2017-04-05 11:32 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).