2020-03-30 15:17:33

by Stefan Berger

[permalink] [raw]
Subject: [PATCH v2 0/3] tpm2: Make TPM2 logs accessible for non-UEFI firmware

From: Stefan Berger <[email protected]>

This series of patches extends the existing TPM2 ACPI table with additional
fields found in the TPM2 TCG ACPI specification (reference is in the patch)
that allow access to the log's address and its size. We then modify the
code that so far only enables access to a TPM 1.2's log for a TPM2 as well.
This then enables access to the TPM2's log on non-UEFI system that for example
run SeaBIOS.

Stefan

v1->v2:
- Repost of the series

Stefan Berger (3):
acpi: Extend TPM2 ACPI table with missing log fields
tpm: Rearrange ACPI log code to easier extend for TPM2 case
tpm: Add support for ACPI logs from TPM2 ACPI table

drivers/char/tpm/eventlog/acpi.c | 54 ++++++++++++++++++++++++----------------
drivers/char/tpm/tpm_crb.c | 13 +++++++---
drivers/char/tpm/tpm_tis.c | 4 ++-
include/acpi/actbl3.h | 5 ++--
4 files changed, 49 insertions(+), 27 deletions(-)

--
2.14.5


2020-03-30 16:30:08

by Stefan Berger

[permalink] [raw]
Subject: [PATCH v2 2/3] tpm: Rearrange ACPI log code to easier extend for TPM2 case

From: Stefan Berger <[email protected]>

Rearrange the ACPI table based log code to allow for easier extension
for the TPM2 case.

Signed-off-by: Stefan Berger <[email protected]>
---
drivers/char/tpm/eventlog/acpi.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/char/tpm/eventlog/acpi.c b/drivers/char/tpm/eventlog/acpi.c
index 63ada5e53f13..1ef2267c9378 100644
--- a/drivers/char/tpm/eventlog/acpi.c
+++ b/drivers/char/tpm/eventlog/acpi.c
@@ -50,9 +50,6 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
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
@@ -61,23 +58,27 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
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))
+ if (chip->flags & TPM_CHIP_FLAG_TPM2) {
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;
+ } else {
+ /* 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__);
--
2.14.5

2020-03-30 19:34:04

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] tpm: Rearrange ACPI log code to easier extend for TPM2 case

On Mon, Mar 30, 2020 at 11:15:35AM -0400, Stefan Berger wrote:
> From: Stefan Berger <[email protected]>
>
> Rearrange the ACPI table based log code to allow for easier extension
> for the TPM2 case.
>
> Signed-off-by: Stefan Berger <[email protected]>

I think this change does not do anything useful.

/Jarkko

2020-03-30 21:13:27

by Stefan Berger

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] tpm: Rearrange ACPI log code to easier extend for TPM2 case

On 3/30/20 3:32 PM, Jarkko Sakkinen wrote:
> On Mon, Mar 30, 2020 at 11:15:35AM -0400, Stefan Berger wrote:
>> From: Stefan Berger <[email protected]>
>>
>> Rearrange the ACPI table based log code to allow for easier extension
>> for the TPM2 case.
>>
>> Signed-off-by: Stefan Berger <[email protected]>
> I think this change does not do anything useful.

I know. So it's easy to see what's happening and harmless. But I'll
squash it.


>
> /Jarkko


2020-03-31 11:53:41

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] tpm: Rearrange ACPI log code to easier extend for TPM2 case

On Mon, Mar 30, 2020 at 05:12:24PM -0400, Stefan Berger wrote:
> On 3/30/20 3:32 PM, Jarkko Sakkinen wrote:
> > On Mon, Mar 30, 2020 at 11:15:35AM -0400, Stefan Berger wrote:
> > > From: Stefan Berger <[email protected]>
> > >
> > > Rearrange the ACPI table based log code to allow for easier extension
> > > for the TPM2 case.
> > >
> > > Signed-off-by: Stefan Berger <[email protected]>
> > I think this change does not do anything useful.
>
> I know. So it's easy to see what's happening and harmless. But I'll squash
> it.

Yeah, well files aren't getting moved or anything and overally
the change is still somewhat scoped.

/Jarkko