From patchwork Thu Nov 26 21:12:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1406891 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 4Chr7f0VgZz9s0b for ; Fri, 27 Nov 2020 08:12:45 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1kiOZE-0002pj-Pq; Thu, 26 Nov 2020 21:12:40 +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 1kiOZB-0002pd-IG for fwts-devel@lists.ubuntu.com; Thu, 26 Nov 2020 21:12:37 +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 1kiOZA-0000C7-U0; Thu, 26 Nov 2020 21:12:37 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH][V2] acpi: fadt: X_GPE0/1_BLK can be zero when not used Date: Thu, 26 Nov 2020 14:12:31 -0700 Message-Id: <20201126211231.417829-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" ACPI spec states "if this register block is not supported, this field contains zero". This patch also replaces spaces by a tab for fwts_acpi_gas struct. Signed-off-by: Alex Hung Acked-by: Colin Ian King Acked-by: Ivan Hu --- src/acpi/fadt/fadt.c | 22 ++++++++++++---------- src/lib/include/fwts_acpi.h | 7 ++++--- src/lib/src/fwts_acpi.c | 11 +++++++++++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c index ab5a3b2b..5159ec81 100644 --- a/src/acpi/fadt/fadt.c +++ b/src/acpi/fadt/fadt.c @@ -1527,21 +1527,23 @@ static void acpi_table_check_fadt_x_gpex_blk(fwts_framework *fw) { if (fadt->x_gpe0_blk.access_width == 1) fwts_passed(fw, "FADT X_GPE0_BLK has correct byte access width."); else { - fwts_failed(fw, LOG_LEVEL_HIGH, - "X_GPE0_BLKBadAccessWidth", - "FADT X_GPE0_BLK Access width 0x%2.2" PRIx8 - " but it should be 1 (byte access).", - fadt->x_gpe0_blk.access_width); + if (!fwts_acpi_data_zero((const void *) &fadt->x_gpe0_blk, sizeof(fwts_acpi_gas))) + fwts_failed(fw, LOG_LEVEL_HIGH, + "X_GPE0_BLKBadAccessWidth", + "FADT X_GPE0_BLK Access width 0x%2.2" PRIx8 + " but it should be 1 (byte access).", + fadt->x_gpe0_blk.access_width); } if (fadt->x_gpe1_blk.access_width == 1) fwts_passed(fw, "FADT X_GPE1_BLK has correct byte access width."); else { - fwts_failed(fw, LOG_LEVEL_HIGH, - "X_GPE1_BLKBadAccessWidth", - "FADT X_GPE1_BLK Access width 0x%2.2" PRIx8 - " but it should be 1 (byte access).", - fadt->x_gpe1_blk.access_width); + if (!fwts_acpi_data_zero((const void *) &fadt->x_gpe1_blk, sizeof(fwts_acpi_gas))) + fwts_failed(fw, LOG_LEVEL_HIGH, + "X_GPE1_BLKBadAccessWidth", + "FADT X_GPE1_BLK Access width 0x%2.2" PRIx8 + " but it should be 1 (byte access).", + fadt->x_gpe1_blk.access_width); } } diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h index efa988f2..d4dfa46f 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -117,9 +117,9 @@ extern const char *fwts_acpi_fadt_preferred_pm_profile[]; typedef struct { uint8_t address_space_id; uint8_t register_bit_width; - uint8_t register_bit_offset; - uint8_t access_width; - uint64_t address; + uint8_t register_bit_offset; + uint8_t access_width; + uint64_t address; } __attribute__ ((packed)) fwts_acpi_gas; /* @@ -1830,6 +1830,7 @@ typedef struct { } __attribute__ ((packed)) fwts_acpi_table_hest_generic_hardware_error_source_v2; void fwts_acpi_table_get_header(fwts_acpi_table_header *hdr, uint8_t *data); +bool fwts_acpi_data_zero(const void *data, const size_t len); /* * ACPI CSTR (Core System Resources Table) diff --git a/src/lib/src/fwts_acpi.c b/src/lib/src/fwts_acpi.c index 55ac50bc..172e630c 100644 --- a/src/lib/src/fwts_acpi.c +++ b/src/lib/src/fwts_acpi.c @@ -51,4 +51,15 @@ void fwts_acpi_table_get_header(fwts_acpi_table_header *hdr, uint8_t *data) memcpy(hdr, data, sizeof(fwts_acpi_table_header)); } +bool fwts_acpi_data_zero(const void *data, const size_t len) { + uint8_t *ptr = (uint8_t *) data; + uint8_t i; + + for (i = 0; i < len; i++) + if (*ptr++) + return false; + + return true; +} + #endif