From patchwork Thu Jan 11 10:21:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1885455 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 4T9ggg4xr2z1yPp for ; Thu, 11 Jan 2024 21:21:34 +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 1rNsBg-0000pG-Ud; Thu, 11 Jan 2024 10:21:25 +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 1rNsBa-0000oM-TV for fwts-devel@lists.ubuntu.com; Thu, 11 Jan 2024 10:21:19 +0000 Received: from canonical.com (unknown [106.104.136.95]) (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 B3299413BC for ; Thu, 11 Jan 2024 10:21:17 +0000 (UTC) From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] acpi: ccel: add tests for ACPI CCEL table (mantis 2314) Date: Thu, 11 Jan 2024 18:21:03 +0800 Message-Id: <20240111102104.374625-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 CCEL(CC Event Log) table was added to ACPI6.5, add tests for the CCEL table. Signed-off-by: Ivan Hu --- src/Makefile.am | 1 + src/acpi/ccel/ccel.c | 78 +++++++++++++++++++++++++++++++++++++ src/lib/include/fwts_acpi.h | 13 +++++++ 3 files changed, 92 insertions(+) create mode 100644 src/acpi/ccel/ccel.c diff --git a/src/Makefile.am b/src/Makefile.am index dde55098..ecb6d63a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -69,6 +69,7 @@ fwts_SOURCES = main.c \ acpi/brightness/brightness-helper.c \ acpi/brightness/brightness.c \ acpi/brightness/autobrightness.c \ + acpi/ccel/ccel.c \ acpi/cedt/cedt.c \ acpi/checksum/checksum.c \ acpi/cpep/cpep.c \ diff --git a/src/acpi/ccel/ccel.c b/src/acpi/ccel/ccel.c new file mode 100644 index 00000000..0d979a2a --- /dev/null +++ b/src/acpi/ccel/ccel.c @@ -0,0 +1,78 @@ +/* + * 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(CCEL, &table) + +static int ccel_test1(fwts_framework *fw) +{ + + bool passed = true; + fwts_acpi_table_ccel *ccel = (fwts_acpi_table_ccel *)table->data; + + if (ccel->header.length != sizeof(fwts_acpi_table_ccel)) { + fwts_failed(fw, LOG_LEVEL_HIGH, + "CCELBadTableLength", + "CCEL table lengthe shoud be %" PRIu32 ", got %" PRIu32 + " instead.", (uint32_t)sizeof(fwts_acpi_table_ccel), + ccel->header.length); + return FWTS_OK; + } + + fwts_log_info_verbatim(fw, "CC Event Log ACPI Table:"); + fwts_log_info_simp_int(fw, " CC Type: ", ccel->cc_type); + if (ccel->cc_type == 0 || ccel->cc_type >= 3) { + fwts_failed(fw, LOG_LEVEL_HIGH, + "CCELBadCCType", + "CCEL CC types must not have the reaserved value 0, 0x03..0xff, " + "got 0x%2.2" PRIx8 " instead.", ccel->cc_type); + passed = false; + } + fwts_log_info_simp_int(fw, " CC Subtype: ", ccel->cc_subtype); + fwts_log_info_simp_int(fw, " Reserved: ", ccel->reserved); + fwts_acpi_reserved_zero("CCEL", "Reserved", ccel->reserved, &passed); + fwts_log_info_simp_int(fw, " Log Area Minimum Length(LAML): ", ccel->laml); + fwts_log_info_simp_int(fw, " Log Area Start Address(LASA): ", ccel->lasa); + fwts_log_nl(fw); + + if (passed) + fwts_passed(fw, "No issues found in CCEL table."); + + return FWTS_OK; +} + +static fwts_framework_minor_test ccel_tests[] = { + { ccel_test1, "Validate CCEL table." }, + { NULL, NULL } +}; + +static fwts_framework_ops ccel_ops = { + .description = "CCEL CC Event Log ACPI Table test.", + .init = CCEL_init, + .minor_tests = ccel_tests +}; + +FWTS_REGISTER("ccel", &ccel_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 a78aa577..2538a847 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -2819,4 +2819,17 @@ typedef struct { fwts_acpi_misc_guided_entry entry[0]; } __attribute__ ((packed)) fwts_acpi_table_misc; +/* + * CC Event Log ACPI Table + * ACPI6.5 5.2.34 + */ +typedef struct { + fwts_acpi_table_header header; + uint8_t cc_type; + uint8_t cc_subtype; + uint16_t reserved; + uint64_t laml; + uint64_t lasa; +} __attribute__ ((packed)) fwts_acpi_table_ccel; + #endif From patchwork Thu Jan 11 10:21:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1885456 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 4T9ggn455jz1yPp for ; Thu, 11 Jan 2024 21:21:41 +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 1rNsBp-0000rI-JN; Thu, 11 Jan 2024 10:21:33 +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 1rNsBi-0000pK-Ek for fwts-devel@lists.ubuntu.com; Thu, 11 Jan 2024 10:21:26 +0000 Received: from canonical.com (unknown [106.104.136.95]) (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 B2F22413BC for ; Thu, 11 Jan 2024 10:21:24 +0000 (UTC) From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/2] fwts-test: add regression tests for CCEL Date: Thu, 11 Jan 2024 18:21:04 +0800 Message-Id: <20240111102104.374625-2-ivan.hu@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240111102104.374625-1-ivan.hu@canonical.com> References: <20240111102104.374625-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/ccel-0001/acpidump-0001.log | 30 +++++++++++++++++++++++++++ fwts-test/ccel-0001/acpidump-0002.log | 30 +++++++++++++++++++++++++++ fwts-test/ccel-0001/ccel-0001.log | 16 ++++++++++++++ fwts-test/ccel-0001/ccel-0002.log | 20 ++++++++++++++++++ fwts-test/ccel-0001/test-0001.sh | 23 ++++++++++++++++++++ fwts-test/ccel-0001/test-0002.sh | 23 ++++++++++++++++++++ 7 files changed, 144 insertions(+) create mode 100644 fwts-test/ccel-0001/acpidump-0001.log create mode 100644 fwts-test/ccel-0001/acpidump-0002.log create mode 100644 fwts-test/ccel-0001/ccel-0001.log create mode 100644 fwts-test/ccel-0001/ccel-0002.log create mode 100755 fwts-test/ccel-0001/test-0001.sh create mode 100755 fwts-test/ccel-0001/test-0002.sh diff --git a/Makefile.am b/Makefile.am index dba22fdb..5178f3bd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -98,6 +98,8 @@ TESTS = fwts-test/acpidump-0001/test-0001.sh \ fwts-test/bgrt-0001/test-0002.sh \ fwts-test/boot-0001/test-0001.sh \ fwts-test/boot-0001/test-0002.sh \ + fwts-test/ccel-0001/test-0001.sh \ + fwts-test/ccel-0001/test-0002.sh \ fwts-test/cedt-0001/test-0001.sh \ fwts-test/cedt-0001/test-0002.sh \ fwts-test/checksum-0001/test-0001.sh \ diff --git a/fwts-test/ccel-0001/acpidump-0001.log b/fwts-test/ccel-0001/acpidump-0001.log new file mode 100644 index 00000000..c5c92465 --- /dev/null +++ b/fwts-test/ccel-0001/acpidump-0001.log @@ -0,0 +1,30 @@ +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 .... + +CCEL @ 0x00000000 + 0000: 43 43 45 4C 38 00 00 00 04 1C 49 4E 54 45 4C 20 CCEL8.....INTEL + 0010: 54 65 6D 70 6C 61 74 65 00 00 00 00 49 4E 54 4C Template....INTL + 0020: 30 09 21 20 01 00 00 00 EF CD AB 78 56 34 12 00 0.! .......xV4.. + 0030: 78 56 34 12 EF CD AB 00 xV4..... diff --git a/fwts-test/ccel-0001/acpidump-0002.log b/fwts-test/ccel-0001/acpidump-0002.log new file mode 100644 index 00000000..05a29307 --- /dev/null +++ b/fwts-test/ccel-0001/acpidump-0002.log @@ -0,0 +1,30 @@ +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 .... + +CCEL @ 0x00000000 + 0000: 43 43 45 4C 38 00 00 00 04 1C 49 4E 54 45 4C 20 CCEL8.....INTEL + 0010: 54 65 6D 70 6C 61 74 65 00 00 00 00 49 4E 54 4C Template....INTL + 0020: 30 09 21 20 05 00 FF FF EF CD AB 78 56 34 12 00 0.! .......xV4.. + 0030: 78 56 34 12 EF CD AB 00 xV4..... diff --git a/fwts-test/ccel-0001/ccel-0001.log b/fwts-test/ccel-0001/ccel-0001.log new file mode 100644 index 00000000..a2c666fd --- /dev/null +++ b/fwts-test/ccel-0001/ccel-0001.log @@ -0,0 +1,16 @@ +ccel ccel: CCEL CC Event Log ACPI Table test. +ccel ---------------------------------------------------------- +ccel Test 1 of 1: Validate CCEL table. +ccel CC Event Log ACPI Table: +ccel CC Type: 0x01 +ccel CC Subtype: 0x00 +ccel Reserved: 0x0000 +ccel Log Area Minimum Length(LAML): 0x0012345678abcdef +ccel Log Area Start Address(LASA): 0x00abcdef12345678 +ccel +ccel PASSED: Test 1, No issues found in CCEL table. +ccel +ccel ========================================================== +ccel 1 passed, 0 failed, 0 warning, 0 aborted, 0 skipped, 0 +ccel info only. +ccel ========================================================== diff --git a/fwts-test/ccel-0001/ccel-0002.log b/fwts-test/ccel-0001/ccel-0002.log new file mode 100644 index 00000000..3de18b87 --- /dev/null +++ b/fwts-test/ccel-0001/ccel-0002.log @@ -0,0 +1,20 @@ +ccel ccel: CCEL CC Event Log ACPI Table test. +ccel ---------------------------------------------------------- +ccel Test 1 of 1: Validate CCEL table. +ccel CC Event Log ACPI Table: +ccel CC Type: 0x05 +ccel FAILED [HIGH] CCELBadCCType: Test 1, CCEL CC types must +ccel not have the reaserved value 0, 0x03..0xff, got 0x05 +ccel instead. +ccel CC Subtype: 0x00 +ccel Reserved: 0xffff +ccel FAILED [MEDIUM] CCELReservedNonZero: Test 1, CCEL Reserved +ccel field must be zero, got 0xffff instead +ccel Log Area Minimum Length(LAML): 0x0012345678abcdef +ccel Log Area Start Address(LASA): 0x00abcdef12345678 +ccel +ccel +ccel ========================================================== +ccel 0 passed, 2 failed, 0 warning, 0 aborted, 0 skipped, 0 +ccel info only. +ccel ========================================================== diff --git a/fwts-test/ccel-0001/test-0001.sh b/fwts-test/ccel-0001/test-0001.sh new file mode 100755 index 00000000..c3d6277f --- /dev/null +++ b/fwts-test/ccel-0001/test-0001.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +TEST="Test acpitables against CCEL" +NAME=test-0001.sh +TMPLOG=$TMP/ccel.log.$$ + +$FWTS --show-tests | grep ccel > /dev/null +if [ $? -eq 1 ]; then + echo SKIP: $TEST, $NAME + exit 77 +fi + +$FWTS --log-format="%line %owner " -w 80 --dumpfile=$FWTSTESTDIR/ccel-0001/acpidump-0001.log ccel - | cut -c7- | grep "^ccel" > $TMPLOG +diff $TMPLOG $FWTSTESTDIR/ccel-0001/ccel-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/ccel-0001/test-0002.sh b/fwts-test/ccel-0001/test-0002.sh new file mode 100755 index 00000000..c710c14d --- /dev/null +++ b/fwts-test/ccel-0001/test-0002.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +TEST="Test acpitables against CCEL" +NAME=test-0002.sh +TMPLOG=$TMP/ccel.log.$$ + +$FWTS --show-tests | grep ccel > /dev/null +if [ $? -eq 1 ]; then + echo SKIP: $TEST, $NAME + exit 77 +fi + +$FWTS --log-format="%line %owner " -w 80 --dumpfile=$FWTSTESTDIR/ccel-0001/acpidump-0002.log ccel - | cut -c7- | grep "^ccel" > $TMPLOG +diff $TMPLOG $FWTSTESTDIR/ccel-0001/ccel-0002.log >> $FAILURE_LOG +ret=$? +if [ $ret -eq 0 ]; then + echo PASSED: $TEST, $NAME +else + echo FAILED: $TEST, $NAME +fi + +rm $TMPLOG +exit $ret