From patchwork Thu Jan 11 06:02:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ivanhu X-Patchwork-Id: 1885367 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 4T9Yx62pPjz1yP3 for ; Thu, 11 Jan 2024 17:02:49 +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 1rNo9I-0004HX-OG; Thu, 11 Jan 2024 06:02:41 +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 1rNo9D-0004HJ-IJ for fwts-devel@lists.ubuntu.com; Thu, 11 Jan 2024 06:02:36 +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 1E47F42F77 for ; Thu, 11 Jan 2024 06:02:32 +0000 (UTC) From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] acpi: misc: add tests for ACPI MISC table (mantis 2297) Date: Thu, 11 Jan 2024 14:02:27 +0800 Message-Id: <20240111060228.243345-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 MISC(Miscellaneous GUIDed Table Entries) table was added to ACPI6.5, add tests for the MISC table. Signed-off-by: Ivan Hu --- src/Makefile.am | 1 + src/acpi/misc/misc.c | 88 +++++++++++++++++++++++++++++++++++++ src/lib/include/fwts_acpi.h | 17 +++++++ 3 files changed, 106 insertions(+) create mode 100644 src/acpi/misc/misc.c diff --git a/src/Makefile.am b/src/Makefile.am index 69204479..dde55098 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -114,6 +114,7 @@ fwts_SOURCES = main.c \ acpi/madt/madt.c \ acpi/mcfg/mcfg.c \ acpi/mchi/mchi.c \ + acpi/misc/misc.c \ acpi/mpam/mpam.c \ acpi/mpst/mpst.c \ acpi/msct/msct.c \ diff --git a/src/acpi/misc/misc.c b/src/acpi/misc/misc.c new file mode 100644 index 00000000..44375424 --- /dev/null +++ b/src/acpi/misc/misc.c @@ -0,0 +1,88 @@ +/* + * 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(MISC, &table) + +static int misc_test1(fwts_framework *fw) +{ + fwts_acpi_misc_guided_entry *entry; + bool passed = true; + uint32_t offset; + + offset = sizeof(fwts_acpi_table_misc); + entry = (fwts_acpi_misc_guided_entry *)(table->data + offset); + while (offset < table->length) { + char guid_str[37]; + + if (fwts_acpi_structure_length_zero(fw, "MISC", entry->entry_len, offset)) { + passed = false; + break; + } + + if ((offset + entry->entry_len) > table->length) { + fwts_failed(fw, LOG_LEVEL_HIGH, + "MISCOutOfRangeOffset", + "MISC GUIDed Entry Offset is out of range."); + passed = false; + break; + } + + fwts_log_info_verbatim(fw, "Miscellaneous GUIDed Table Entries:"); + fwts_guid_buf_to_str(entry->entry_guid, guid_str, sizeof(guid_str)); + fwts_log_info_verbatim(fw, " Entry GUID ID: %s", guid_str); + fwts_log_info_simp_int(fw, " Entry Length: ", entry->entry_len); + fwts_log_info_simp_int(fw, " Revision: ", entry->revision); + fwts_log_info_simp_int(fw, " Producer ID: ", entry->producer_id); + fwts_log_info_verbatim(fw, " Data:"); + fwts_hexdump_data_prefix_all(fw, entry->data, " ", + (entry->entry_len - sizeof(fwts_acpi_misc_guided_entry))); + + /* Nothing else need to be checked currently */ + + offset += entry->entry_len; + entry = (fwts_acpi_misc_guided_entry *)(table->data + offset); + fwts_log_nl(fw); + } + + if (passed) + fwts_passed(fw, "No issues found in MISC table."); + + return FWTS_OK; +} + +static fwts_framework_minor_test misc_tests[] = { + { misc_test1, "Validate MISC table." }, + { NULL, NULL } +}; + +static fwts_framework_ops misc_ops = { + .description = "MISC Miscellaneous GUIDed Table Entries test.", + .init = MISC_init, + .minor_tests = misc_tests +}; + +FWTS_REGISTER("misc", &misc_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 79763bab..a78aa577 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -2802,4 +2802,21 @@ typedef struct { uint64_t reserved; } __attribute__ ((packed)) fwts_acpi_table_viot; +/* + * Miscellaneous GUIDed Table Entries + * ACPI6.5 5.2.33 + */ +typedef struct { + uint8_t entry_guid[16]; + uint32_t entry_len; + uint32_t revision; + uint32_t producer_id; + uint8_t data[0]; +} __attribute__ ((packed)) fwts_acpi_misc_guided_entry; + +typedef struct { + fwts_acpi_table_header header; + fwts_acpi_misc_guided_entry entry[0]; +} __attribute__ ((packed)) fwts_acpi_table_misc; + #endif