From patchwork Mon Jan 15 03:31:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ivanhu X-Patchwork-Id: 1886512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TCyPg421Pz1yPY for ; Mon, 15 Jan 2024 14:32:23 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rPDhr-0001gu-J4; Mon, 15 Jan 2024 03:32:11 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rPDhj-0001gm-Ni for fwts-devel@lists.ubuntu.com; Mon, 15 Jan 2024 03:32:03 +0000 Received: from canonical.com (unknown [10.101.194.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 68D0B43776 for ; Mon, 15 Jan 2024 03:32:02 +0000 (UTC) From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] acpi: skvl: add tests for ACPI SKVL table (mantis 2314) Date: Mon, 15 Jan 2024 11:31:56 +0800 Message-Id: <20240115033157.113046-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.34.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" BugLink: https://bugs.launchpad.net/fwts/+bug/2047212 The ACPI SKVL(Storage Volume Key Location) table was added to ACPI6.5, add tests for the SKVL table. Signed-off-by: Ivan Hu --- src/Makefile.am | 3 +- src/acpi/skvl/skvl.c | 80 +++++++++++++++++++++++++++++++++++++ src/lib/include/fwts_acpi.h | 17 ++++++++ 3 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/acpi/skvl/skvl.c diff --git a/src/Makefile.am b/src/Makefile.am index ecb6d63a..0beb17f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -144,7 +144,8 @@ fwts_SOURCES = main.c \ acpi/sbst/sbst.c \ acpi/sdei/sdei.c \ acpi/sdev/sdev.c \ - acpi/slic/slic.c \ + acpi/skvl/skvl.c \ + acpi/slic/slic.c \ acpi/slit/slit.c \ acpi/spcr/spcr.c \ acpi/spmi/spmi.c \ diff --git a/src/acpi/skvl/skvl.c b/src/acpi/skvl/skvl.c new file mode 100644 index 00000000..9c4166b2 --- /dev/null +++ b/src/acpi/skvl/skvl.c @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2024 Canonical + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include "fwts.h" + +#if defined(FWTS_HAS_ACPI) + +#include +#include +#include +#include +#include + +static fwts_acpi_table_info *table; +acpi_table_init(SKVL, &table) + +static int skvl_test1(fwts_framework *fw) +{ + fwts_acpi_skvl_key_struct *key_struct; + bool passed = true; + uint32_t offset; + fwts_acpi_table_skvl *skvl = (fwts_acpi_table_skvl *)table->data; + + fwts_log_info_verbatim(fw, "Storage Volume Key Location Table:"); + fwts_log_info_simp_int(fw, " Key Count: ", skvl->key_count); + fwts_log_nl(fw); + + offset = sizeof(fwts_acpi_table_skvl); + + for (uint32_t i = 0; i < skvl->key_count; i++) { + if ((offset + sizeof(fwts_acpi_skvl_key_struct)) > table->length) { + fwts_failed(fw, LOG_LEVEL_HIGH, + "SKVLOutOfRangeOffset", + "SKVL key structure offset is out of range."); + return FWTS_OK; + } + key_struct = (fwts_acpi_skvl_key_struct *)(table->data + offset); + fwts_log_info_verbatim(fw, " Storage Volume Key Structure: "); + fwts_log_info_simp_int(fw, " Key Type: ", key_struct->key_type); + fwts_acpi_fixed_value(fw, LOG_LEVEL_HIGH, "SKVL", "Key Type", key_struct->key_type, 0, &passed); + fwts_log_info_simp_int(fw, " Key Format: ", key_struct->key_format); + fwts_acpi_fixed_value(fw, LOG_LEVEL_HIGH, "SKVL", "Key Format", key_struct->key_format, 0, &passed); + fwts_log_info_simp_int(fw, " Key Size: ", key_struct->key_size); + fwts_log_info_simp_int(fw, " Key Address: ", key_struct->key_address); + + offset += sizeof(fwts_acpi_skvl_key_struct); + fwts_log_nl(fw); + } + + if (passed) + fwts_passed(fw, "No issues found in SKVL table."); + + return FWTS_OK; +} + +static fwts_framework_minor_test skvl_tests[] = { + { skvl_test1, "Validate SKVL table." }, + { NULL, NULL } +}; + +static fwts_framework_ops skvl_ops = { + .description = "SKVL Storage Volume Key Location Table test.", + .init = SKVL_init, + .minor_tests = skvl_tests +}; + +FWTS_REGISTER("skvl", &skvl_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_ACPI) + +#endif diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h index e9d6b1dc..5ea01d35 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -2832,4 +2832,21 @@ typedef struct { uint64_t lasa; } __attribute__ ((packed)) fwts_acpi_table_ccel; +/* + * Storage Volume Key Location Table + * ACPI6.5 5.2.35 + */ +typedef struct { + uint16_t key_type; + uint16_t key_format; + uint32_t key_size; + uint64_t key_address; +} __attribute__ ((packed)) fwts_acpi_skvl_key_struct; + +typedef struct { + fwts_acpi_table_header header; + uint32_t key_count; + fwts_acpi_skvl_key_struct key_struct[0]; +} __attribute__ ((packed)) fwts_acpi_table_skvl; + #endif From patchwork Mon Jan 15 03:31:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ivanhu X-Patchwork-Id: 1886513 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TCyPm3tm0z1yPY for ; Mon, 15 Jan 2024 14:32:28 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rPDi3-0001i9-Fv; Mon, 15 Jan 2024 03:32:23 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rPDho-0001gv-2V for fwts-devel@lists.ubuntu.com; Mon, 15 Jan 2024 03:32:10 +0000 Received: from canonical.com (unknown [10.101.194.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 3C66D41BC5 for ; Mon, 15 Jan 2024 03:32:06 +0000 (UTC) From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/2] fwts-test: add regression tests for SKVL Date: Mon, 15 Jan 2024 11:31:57 +0800 Message-Id: <20240115033157.113046-2-ivan.hu@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240115033157.113046-1-ivan.hu@canonical.com> References: <20240115033157.113046-1-ivan.hu@canonical.com> 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" Signed-off-by: Ivan Hu --- Makefile.am | 2 ++ fwts-test/skvl-0001/acpidump-0001.log | 32 +++++++++++++++++++++++++++ fwts-test/skvl-0001/acpidump-0002.log | 32 +++++++++++++++++++++++++++ fwts-test/skvl-0001/skvl-0001.log | 30 +++++++++++++++++++++++++ fwts-test/skvl-0001/skvl-0002.log | 29 ++++++++++++++++++++++++ fwts-test/skvl-0001/test-0001.sh | 23 +++++++++++++++++++ fwts-test/skvl-0001/test-0002.sh | 23 +++++++++++++++++++ 7 files changed, 171 insertions(+) create mode 100644 fwts-test/skvl-0001/acpidump-0001.log create mode 100644 fwts-test/skvl-0001/acpidump-0002.log create mode 100644 fwts-test/skvl-0001/skvl-0001.log create mode 100644 fwts-test/skvl-0001/skvl-0002.log create mode 100755 fwts-test/skvl-0001/test-0001.sh create mode 100755 fwts-test/skvl-0001/test-0002.sh diff --git a/Makefile.am b/Makefile.am index 5178f3bd..e31af973 100644 --- a/Makefile.am +++ b/Makefile.am @@ -191,6 +191,8 @@ TESTS = fwts-test/acpidump-0001/test-0001.sh \ fwts-test/s0idle-0001/test-0002.sh \ fwts-test/sbst-0001/test-0001.sh \ fwts-test/sbst-0001/test-0002.sh \ + fwts-test/skvl-0001/test-0001.sh \ + fwts-test/skvl-0001/test-0002.sh \ fwts-test/spcr-0001/test-0001.sh \ fwts-test/spcr-0001/test-0002.sh \ fwts-test/srat-0001/test-0001.sh \ diff --git a/fwts-test/skvl-0001/acpidump-0001.log b/fwts-test/skvl-0001/acpidump-0001.log new file mode 100644 index 00000000..e030001c --- /dev/null +++ b/fwts-test/skvl-0001/acpidump-0001.log @@ -0,0 +1,32 @@ +FACS @ 0x00000000 + 0000: 46 41 43 53 40 00 00 00 00 00 00 00 00 00 00 00 FACS@........... + 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0020: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +FACP @ 0x00000000 + 0000: 46 41 43 50 f4 00 00 00 03 f9 41 4d 44 20 20 20 FACP......AMD + 0010: 47 55 41 4d 20 20 20 20 00 00 04 06 41 4d 44 20 GUAM ....AMD + 0020: 40 42 0f 00 c0 2f e9 af 92 47 e8 af 00 02 09 00 @B.../...G...... + 0030: b0 00 00 00 f0 f1 00 00 00 80 00 00 00 00 00 00 ................ + 0040: 04 80 00 00 00 00 00 00 00 82 00 00 08 80 00 00 ................ + 0050: 20 80 00 00 00 00 00 00 04 02 01 04 08 00 00 00 ............... + 0060: 65 00 e9 03 00 00 00 00 01 00 0d 00 32 00 00 00 e...........2... + 0070: a5 c1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0080: 00 00 00 00 c0 2f e9 af 00 00 00 00 92 47 e8 af ...../.......G.. + 0090: 00 00 00 00 01 20 00 00 00 80 00 00 00 00 00 00 ..... .......... + 00a0: 00 00 00 00 00 00 00 00 00 00 00 00 01 10 00 00 ................ + 00b0: 04 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 00c0: 00 00 00 00 01 08 00 00 00 82 00 00 00 00 00 00 ................ + 00d0: 01 20 00 00 08 80 00 00 00 00 00 00 01 40 00 00 . ...........@.. + 00e0: 20 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... + 00f0: 00 00 00 00 .... + +SKVL @ 0x00000000 + 0000: 53 4B 56 4C 58 00 00 00 01 52 49 4E 54 45 4C 20 MISC.....RINTEL + 0010: 54 65 6D 70 6C 61 74 65 00 00 00 00 49 4E 54 4C Template....INTL + 0020: 05 01 21 20 03 00 00 00 00 00 00 00 11 22 00 00 ... ....."...... + 0030: 11 22 33 44 55 66 77 88 00 00 00 00 22 33 00 00 ."3DUfw....."... + 0040: 22 33 44 55 66 77 88 99 00 00 00 00 FF 00 00 00 "3DUfw.......... + 0050: AA BB CC DD EE FF 00 11 ........ diff --git a/fwts-test/skvl-0001/acpidump-0002.log b/fwts-test/skvl-0001/acpidump-0002.log new file mode 100644 index 00000000..86d04dbe --- /dev/null +++ b/fwts-test/skvl-0001/acpidump-0002.log @@ -0,0 +1,32 @@ +FACS @ 0x00000000 + 0000: 46 41 43 53 40 00 00 00 00 00 00 00 00 00 00 00 FACS@........... + 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0020: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + +FACP @ 0x00000000 + 0000: 46 41 43 50 f4 00 00 00 03 f9 41 4d 44 20 20 20 FACP......AMD + 0010: 47 55 41 4d 20 20 20 20 00 00 04 06 41 4d 44 20 GUAM ....AMD + 0020: 40 42 0f 00 c0 2f e9 af 92 47 e8 af 00 02 09 00 @B.../...G...... + 0030: b0 00 00 00 f0 f1 00 00 00 80 00 00 00 00 00 00 ................ + 0040: 04 80 00 00 00 00 00 00 00 82 00 00 08 80 00 00 ................ + 0050: 20 80 00 00 00 00 00 00 04 02 01 04 08 00 00 00 ............... + 0060: 65 00 e9 03 00 00 00 00 01 00 0d 00 32 00 00 00 e...........2... + 0070: a5 c1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 0080: 00 00 00 00 c0 2f e9 af 00 00 00 00 92 47 e8 af ...../.......G.. + 0090: 00 00 00 00 01 20 00 00 00 80 00 00 00 00 00 00 ..... .......... + 00a0: 00 00 00 00 00 00 00 00 00 00 00 00 01 10 00 00 ................ + 00b0: 04 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + 00c0: 00 00 00 00 01 08 00 00 00 82 00 00 00 00 00 00 ................ + 00d0: 01 20 00 00 08 80 00 00 00 00 00 00 01 40 00 00 . ...........@.. + 00e0: 20 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... + 00f0: 00 00 00 00 .... + +SKVL @ 0x00000000 + 0000: 53 4B 56 4C 56 00 00 00 01 52 49 4E 54 45 4C 20 MISC.....RINTEL + 0010: 54 65 6D 70 6C 61 74 65 00 00 00 00 49 4E 54 4C Template....INTL + 0020: 05 01 21 20 03 00 00 00 01 00 00 00 11 22 00 00 ... ....."...... + 0030: 11 22 33 44 55 66 77 88 00 00 FF 00 22 33 00 00 ."3DUfw....."... + 0040: 22 33 44 55 66 77 88 99 00 00 00 00 FF 00 00 00 "3DUfw.......... + 0050: AA BB CC DD EE FF ...... diff --git a/fwts-test/skvl-0001/skvl-0001.log b/fwts-test/skvl-0001/skvl-0001.log new file mode 100644 index 00000000..6ce83979 --- /dev/null +++ b/fwts-test/skvl-0001/skvl-0001.log @@ -0,0 +1,30 @@ +skvl skvl: SKVL Storage Volume Key Location Table test. +skvl ---------------------------------------------------------- +skvl Test 1 of 1: Validate SKVL table. +skvl Storage Volume Key Location Table: +skvl Key Count: 0x00000003 +skvl +skvl Storage Volume Key Structure: +skvl Key Type: 0x0000 +skvl Key Format: 0x0000 +skvl Key Size: 0x00002211 +skvl Key Address: 0x8877665544332211 +skvl +skvl Storage Volume Key Structure: +skvl Key Type: 0x0000 +skvl Key Format: 0x0000 +skvl Key Size: 0x00003322 +skvl Key Address: 0x9988776655443322 +skvl +skvl Storage Volume Key Structure: +skvl Key Type: 0x0000 +skvl Key Format: 0x0000 +skvl Key Size: 0x000000ff +skvl Key Address: 0x1100ffeeddccbbaa +skvl +skvl PASSED: Test 1, No issues found in SKVL table. +skvl +skvl ========================================================== +skvl 1 passed, 0 failed, 0 warning, 0 aborted, 0 skipped, 0 +skvl info only. +skvl ========================================================== diff --git a/fwts-test/skvl-0001/skvl-0002.log b/fwts-test/skvl-0001/skvl-0002.log new file mode 100644 index 00000000..924ee0d7 --- /dev/null +++ b/fwts-test/skvl-0001/skvl-0002.log @@ -0,0 +1,29 @@ +skvl skvl: SKVL Storage Volume Key Location Table test. +skvl ---------------------------------------------------------- +skvl Test 1 of 1: Validate SKVL table. +skvl Storage Volume Key Location Table: +skvl Key Count: 0x00000003 +skvl +skvl Storage Volume Key Structure: +skvl Key Type: 0x0001 +skvl FAILED [HIGH] SKVLBadFieldValue: Test 1, SKVL Key Type +skvl field must be 0, got 1 instead. +skvl Key Format: 0x0000 +skvl Key Size: 0x00002211 +skvl Key Address: 0x8877665544332211 +skvl +skvl Storage Volume Key Structure: +skvl Key Type: 0x0000 +skvl Key Format: 0x00ff +skvl FAILED [HIGH] SKVLBadFieldValue: Test 1, SKVL Key Format +skvl field must be 0, got 255 instead. +skvl Key Size: 0x00003322 +skvl Key Address: 0x9988776655443322 +skvl +skvl FAILED [HIGH] SKVLOutOfRangeOffset: Test 1, SKVL key +skvl structure offset is out of range. +skvl +skvl ========================================================== +skvl 0 passed, 3 failed, 0 warning, 0 aborted, 0 skipped, 0 +skvl info only. +skvl ========================================================== diff --git a/fwts-test/skvl-0001/test-0001.sh b/fwts-test/skvl-0001/test-0001.sh new file mode 100755 index 00000000..60aadecd --- /dev/null +++ b/fwts-test/skvl-0001/test-0001.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +TEST="Test acpitables against SKVL" +NAME=test-0001.sh +TMPLOG=$TMP/skvl.log.$$ + +$FWTS --show-tests | grep skvl > /dev/null +if [ $? -eq 1 ]; then + echo SKIP: $TEST, $NAME + exit 77 +fi + +$FWTS --log-format="%line %owner " -w 80 --dumpfile=$FWTSTESTDIR/skvl-0001/acpidump-0001.log skvl - | cut -c7- | grep "^skvl" > $TMPLOG +diff $TMPLOG $FWTSTESTDIR/skvl-0001/skvl-0001.log >> $FAILURE_LOG +ret=$? +if [ $ret -eq 0 ]; then + echo PASSED: $TEST, $NAME +else + echo FAILED: $TEST, $NAME +fi + +rm $TMPLOG +exit $ret diff --git a/fwts-test/skvl-0001/test-0002.sh b/fwts-test/skvl-0001/test-0002.sh new file mode 100755 index 00000000..e54d3862 --- /dev/null +++ b/fwts-test/skvl-0001/test-0002.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +TEST="Test acpitables against SKVL" +NAME=test-0002.sh +TMPLOG=$TMP/skvl.log.$$ + +$FWTS --show-tests | grep skvl > /dev/null +if [ $? -eq 1 ]; then + echo SKIP: $TEST, $NAME + exit 77 +fi + +$FWTS --log-format="%line %owner " -w 80 --dumpfile=$FWTSTESTDIR/skvl-0001/acpidump-0002.log skvl - | cut -c7- | grep "^skvl" > $TMPLOG +diff $TMPLOG $FWTSTESTDIR/skvl-0001/skvl-0002.log >> $FAILURE_LOG +ret=$? +if [ $ret -eq 0 ]; then + echo PASSED: $TEST, $NAME +else + echo FAILED: $TEST, $NAME +fi + +rm $TMPLOG +exit $ret