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

Stefan Berger stefanb at linux.vnet.ibm.com
Mon Mar 30 15:15:35 UTC 2020


From: Stefan Berger <stefanb at linux.ibm.com>

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

Signed-off-by: Stefan Berger <stefanb at linux.ibm.com>
---
 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



More information about the Linux-security-module-archive mailing list