From patchwork Wed Jul 22 18:21:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1334083 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BBkLy5x2vz9sRR; Thu, 23 Jul 2020 04:21:45 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jyJN7-0002HE-FC; Wed, 22 Jul 2020 18:21:41 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jyJN5-0002H3-AH for fwts-devel@lists.ubuntu.com; Wed, 22 Jul 2020 18:21:39 +0000 Received: from 2.general.alexhung.us.vpn ([10.172.65.255] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jyJN4-0001nl-MO; Wed, 22 Jul 2020 18:21:39 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH] tpm2: table size can be 76 when "LAML" & "LASA" are used Date: Wed, 22 Jul 2020 12:21:36 -0600 Message-Id: <20200722182136.150132-1-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" 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 Acked-by: Ivan Hu Acked-by: Colin Ian King --- 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)