[PATCH] tpm2: table size can be 76 when "LAML" & "LASA" are used

Alex Hung alex.hung at canonical.com
Wed Jul 22 18:21:36 UTC 2020


TCG ACPI Specification released in 2017 added two fields, "Log Area
Minimum Length" and "Log Area Start Address". When they are used, the
table size will be 76.

Buglink: https://bugs.launchpad.net/bugs/1888189

Signed-off-by: Alex Hung <alex.hung at canonical.com>
---
 src/acpi/tpm2/tpm2.c | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/src/acpi/tpm2/tpm2.c b/src/acpi/tpm2/tpm2.c
index bca5cb8a..56b35a1c 100644
--- a/src/acpi/tpm2/tpm2.c
+++ b/src/acpi/tpm2/tpm2.c
@@ -72,22 +72,25 @@ static int tpm2_test1(fwts_framework *fw)
 			tpm2->start_method);
 	}
 
-	if (tpm2->start_method == 2 && table->length != sizeof(fwts_acpi_table_tpm2) + 4) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"TPM2BadPlatformParameters",
-			"Table length must be 0x%" PRIx32 " if Start method equals 2, got 0x%" PRIx32,
-			(uint32_t) sizeof(fwts_acpi_table_tpm2) + 4,
-			(uint32_t) table->length);
-	}
-
-	if (tpm2->start_method == 11 && table->length < sizeof(fwts_acpi_table_tpm2) + 12) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"TPM2BadPlatformParameters",
-			"Table length must be atleast 0x%" PRIx32 " if Start method equals 11, got 0x%" PRIx32,
-			(uint32_t) sizeof(fwts_acpi_table_tpm2) + 12,
-			(uint32_t) table->length);
+	/* When TPM2 includes fields "LAML" & "LASA", table size will be fixed to 76. */
+	if (table->length != 76) {
+		if (tpm2->start_method == 2 && table->length != sizeof(fwts_acpi_table_tpm2) + 4) {
+			passed = false;
+			fwts_failed(fw, LOG_LEVEL_HIGH,
+				"TPM2BadPlatformParameters",
+				"Table length must be 0x%" PRIx32 " if Start Method equals 2, "
+				"got 0x%" PRIx32, (uint32_t) sizeof(fwts_acpi_table_tpm2) + 4,
+				(uint32_t) table->length);
+		}
+
+		if (tpm2->start_method == 11 && table->length < sizeof(fwts_acpi_table_tpm2) + 12) {
+			passed = false;
+			fwts_failed(fw, LOG_LEVEL_HIGH,
+				"TPM2BadPlatformParameters",
+				"Table length must be at least 0x%" PRIx32 " if Start Method equals 11, "
+				"got 0x%" PRIx32, (uint32_t) sizeof(fwts_acpi_table_tpm2) + 12,
+				(uint32_t) table->length);
+		}
 	}
 
 	if (passed)
-- 
2.25.1




More information about the fwts-devel mailing list