diff mbox series

[1/2] tpm2: accept Arm FF-A Start Method and validate its parameters

Message ID 20260714083304.376972-1-ivan.hu@canonical.com
State Accepted
Headers show
Series [1/2] tpm2: accept Arm FF-A Start Method and validate its parameters | expand

Commit Message

Ivan Hu July 14, 2026, 8:33 a.m. UTC
BugLink: https://bugs.launchpad.net/fwts/+bug/2147237

The tpm2 test rejected TPM2 tables whose Start Method is 15 (0xf), the
TCG-defined "Command Response Buffer Interface with Arm Firmware
Framework-A (FF-A)" method, failing with:

    tpm2: TPM2's Start Method must be between 0x1 and 0xd, got 0xf

The hard-coded upper bound (>= 14) predated the Arm FF-A Start Method that
was added in the TCG ACPI Specification. Per the TCG ACPI Specification
(Table 8, Start Method field values) the defined values are 0x1-0xd and
0xf; 0x0 means the value is not set, 0xe is reserved for a future Memory
Mapped I/O Interface and 0x10+ are reserved for future use.

Update the range check to accept 0xf while still rejecting 0x0, 0xe and
0x10+. Also add the missing Start Method specific parameter size checks:
16 bytes for the AMD Mailbox method (0xd) and 12 bytes for the Arm FF-A
method (0xf), matching the existing check for Arm SMC (0xb).

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/acpi/tpm2/tpm2.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/acpi/tpm2/tpm2.c b/src/acpi/tpm2/tpm2.c
index 2a2dd52c..228592b1 100644
--- a/src/acpi/tpm2/tpm2.c
+++ b/src/acpi/tpm2/tpm2.c
@@ -51,11 +51,11 @@  static int tpm2_test1(fwts_framework *fw)
 
 	fwts_acpi_reserved_zero("TPM2", "Reserved", tpm2->reserved, &passed);
 
-	if (tpm2->start_method < 1 || tpm2->start_method >= 14) {
+	if (tpm2->start_method < 1 || tpm2->start_method == 14 || tpm2->start_method > 15) {
 		passed = false;
 		fwts_failed(fw, LOG_LEVEL_HIGH,
 			"TPM2BadStartMethod",
-			"TPM2's Start Method must be between 0x1 and 0xd, got 0x%" PRIx32,
+			"TPM2's Start Method must be between 0x1 and 0xd or 0xf, got 0x%" PRIx32,
 			tpm2->start_method);
 	}
 
@@ -78,6 +78,24 @@  static int tpm2_test1(fwts_framework *fw)
 				"got 0x%" PRIx32, (uint32_t) sizeof(fwts_acpi_table_tpm2) + 12,
 				(uint32_t) table->length);
 		}
+
+		if (tpm2->start_method == 13 && table->length < sizeof(fwts_acpi_table_tpm2) + 16) {
+			passed = false;
+			fwts_failed(fw, LOG_LEVEL_HIGH,
+				"TPM2BadPlatformParameters",
+				"Table length must be at least 0x%" PRIx32 " if Start Method equals 13, "
+				"got 0x%" PRIx32, (uint32_t) sizeof(fwts_acpi_table_tpm2) + 16,
+				(uint32_t) table->length);
+		}
+
+		if (tpm2->start_method == 15 && 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 15, "
+				"got 0x%" PRIx32, (uint32_t) sizeof(fwts_acpi_table_tpm2) + 12,
+				(uint32_t) table->length);
+		}
 	}
 
 	if (passed)