From patchwork Fri Jul 6 14:42:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elliott, Robert (Servers)" X-Patchwork-Id: 940545 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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=none (p=none dis=none) header.from=hpe.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41McrG6pr8z9s4V; Sat, 7 Jul 2018 00:42:06 +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 1fbRvw-0000xt-GG; Fri, 06 Jul 2018 14:42:04 +0000 Received: from g9t5009.houston.hpe.com ([15.241.48.73]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1fbRvu-0000xS-Vt for fwts-devel@lists.ubuntu.com; Fri, 06 Jul 2018 14:42:03 +0000 Received: from g4t3433.houston.hpecorp.net (g4t3433.houston.hpecorp.net [16.208.49.245]) by g9t5009.houston.hpe.com (Postfix) with ESMTP id 7960C71 for ; Fri, 6 Jul 2018 14:42:01 +0000 (UTC) Received: from s17.americas.hpqcorp.net (s17.americas.hpqcorp.net [16.84.27.163]) by g4t3433.houston.hpecorp.net (Postfix) with ESMTP id 573B84B; Fri, 6 Jul 2018 14:42:01 +0000 (UTC) From: Robert Elliott To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] nfit: improve length handling for ACPI NFIT structures Date: Fri, 6 Jul 2018 09:42:54 -0500 Message-Id: <20180706144255.56986-1-elliott@hpe.com> X-Mailer: git-send-email 2.14.3 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: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Check that each ACPI NFIT structure length is long enough before decoding values in its fields. For example, ACPI defines that the Control Region structure is either 32 or 80 bytes; if 32, then none of the fields after the Size of Block Control Window field is valid. However, fwts was accessing those fields, interpreting whatever was in the next table entry. Example complaining that the reserved fields in bytes 74-79 are non-zero (because it's re reading bits from the next structure): NFIT Subtable: Type: 0x0004 Length: 0x0020 NVDIMM Control Region Structure Index: 0x0001 ... Size of Status Register: 0x0000000100300001 NVDIMM Control Region Flag: 0x0025 Reserved: 0x0000000100010000 FAILED [HIGH] NFITReservedBitsNonZero: Test 1, NFIT NVDIMM Control Region Flags Bits [15..1] must be zero, got 0x0025 instead FAILED [MEDIUM] NFITReservedNonZero: Test 1, NFIT Reserved field must be zero, got 0x0000000100010000 instead 1. Check that each structure is the minimum size defined in ACPI. 2. Check that the Interleave and Flush Hint Address structures are the minimum size defined by their fields indicating the number of entries. 3. Move field accesses after the appropriate length checks. Signed-off-by: Robert Elliott Acked-by: Alex Hung Acked-by: Ivan Hu --- src/acpi/nfit/nfit.c | 127 ++++++++++++++++++++++++++++++++++++++------ src/lib/include/fwts_acpi.h | 18 +++++++ 2 files changed, 130 insertions(+), 15 deletions(-) diff --git a/src/acpi/nfit/nfit.c b/src/acpi/nfit/nfit.c index 216593d3..99231501 100644 --- a/src/acpi/nfit/nfit.c +++ b/src/acpi/nfit/nfit.c @@ -40,6 +40,16 @@ static const uint8_t guid_virtual_device[4][16] = { static fwts_acpi_table_info *table; +static bool check_length(fwts_framework *fw, int actual, int min, const char *name) { + if (actual < min) { + fwts_failed(fw, LOG_LEVEL_HIGH, "NFITSubtableLength", + "NFIT Subtable %s length %d bytes is too short, expected >= %d bytes", + name, actual, min); + return false; + } + return true; +} + static int nfit_init(fwts_framework *fw) { if (fwts_acpi_find_table(fw, "NFIT", 0, &table) != FWTS_OK) { @@ -93,6 +103,14 @@ static int nfit_test1(fwts_framework *fw) bool guid_skip = false; size_t i; + bool ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_SYSTEM_ADDRESS, + FWTS_ACPI_NFIT_NAME_SYSTEM_ADDRESS); + if (!ret) { + passed = false; + break; + } + fwts_guid_buf_to_str(nfit_struct->range_guid, guid_str, sizeof(guid_str)); fwts_log_info_verbatim(fw, " SPA Range Structure Index: 0x%4.4" PRIx16, nfit_struct->range_index); @@ -180,6 +198,14 @@ static int nfit_test1(fwts_framework *fw) } else if (entry->type == FWTS_ACPI_NFIT_TYPE_MEMORY_MAP) { fwts_acpi_table_nfit_memory_map *nfit_struct = (fwts_acpi_table_nfit_memory_map *) entry; + bool ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_MEMORY_MAP, + FWTS_ACPI_NFIT_NAME_MEMORY_MAP); + if (!ret) { + passed = false; + break; + } + fwts_log_info_verbatim(fw, " NFIT Device Handle: 0x%8.8" PRIx32, nfit_struct->device_handle); fwts_log_info_verbatim(fw, " NVDIMM Physical ID: 0x%4.4" PRIx16, nfit_struct->physical_id); fwts_log_info_verbatim(fw, " NVDIMM Region ID: 0x%4.4" PRIx16, nfit_struct->region_id); @@ -202,11 +228,28 @@ static int nfit_test1(fwts_framework *fw) fwts_acpi_table_nfit_interleave *nfit_struct = (fwts_acpi_table_nfit_interleave *) entry; uint32_t i; + bool ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_INTERLEAVE, + FWTS_ACPI_NFIT_NAME_INTERLEAVE); + if (!ret) { + passed = false; + break; + } + fwts_log_info_verbatim(fw, " Interleave Structure Index: 0x%4.4" PRIx16, nfit_struct->interleave_index); fwts_log_info_verbatim(fw, " Reserved: 0x%4.4" PRIx16, nfit_struct->reserved); fwts_log_info_verbatim(fw, " Number of Lines Described: 0x%8.8" PRIx32, nfit_struct->line_count); fwts_log_info_verbatim(fw, " Line Size: 0x%8.8" PRIx32, nfit_struct->line_size); + ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_INTERLEAVE + + nfit_struct->line_count * sizeof nfit_struct->line_offset[0], + FWTS_ACPI_NFIT_NAME_INTERLEAVE); + if (!ret) { + passed = false; + break; + } + for (i = 0; i < nfit_struct->line_count; i++) { fwts_log_info_verbatim(fw, " Line Offset: 0x%8.8" PRIx32, nfit_struct->line_offset[i]); @@ -230,20 +273,28 @@ static int nfit_test1(fwts_framework *fw) } else if (entry->type == FWTS_ACPI_NFIT_TYPE_SMBIOS) { fwts_acpi_table_nfit_smbios *nfit_struct = (fwts_acpi_table_nfit_smbios *) entry; + bool ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_SMBIOS, + FWTS_ACPI_NFIT_NAME_SMBIOS); + if (!ret) { + passed = false; + break; + } + fwts_log_info_verbatim(fw, " Reserved: 0x%8.8" PRIx32, nfit_struct->reserved); } else if (entry->type == FWTS_ACPI_NFIT_TYPE_CONTROL_REGION) { fwts_acpi_table_nfit_control_range *nfit_struct = (fwts_acpi_table_nfit_control_range *) entry; uint64_t reserved1; - reserved1 = (uint64_t) nfit_struct->reserved1[0] + ((uint64_t) nfit_struct->reserved1[1] << 8) + - ((uint64_t) nfit_struct->reserved1[2] << 16) + ((uint64_t) nfit_struct->reserved1[3] << 24) + - ((uint64_t) nfit_struct->reserved1[4] << 32) + ((uint64_t) nfit_struct->reserved1[5] << 40); - - if (reserved1 != 0) - reserved_passed = reserved1; + bool ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_CONTROL_REGION, + FWTS_ACPI_NFIT_NAME_CONTROL_REGION); + if (!ret) { + passed = false; + break; + } - fwts_log_info_verbatim(fw, " NVDIMM Control Region Structure Index: 0x%4.4" PRIx16, nfit_struct->region_index); fwts_log_info_verbatim(fw, " Vendor ID: 0x%4.4" PRIx16, nfit_struct->vendor_id); fwts_log_info_verbatim(fw, " Device ID: 0x%4.4" PRIx16, nfit_struct->device_id); fwts_log_info_verbatim(fw, " Revision ID: 0x%4.4" PRIx16, nfit_struct->revision_id); @@ -257,13 +308,6 @@ static int nfit_test1(fwts_framework *fw) fwts_log_info_verbatim(fw, " Serial Number: 0x%8.8" PRIx32, nfit_struct->serial_number); fwts_log_info_verbatim(fw, " Region Format Interface Code: 0x%4.4" PRIx16, nfit_struct->interface_code); fwts_log_info_verbatim(fw, " Number of Block Control Windows: 0x%4.4" PRIx16, nfit_struct->windows_num); - fwts_log_info_verbatim(fw, " Size of Block Control Window: 0x%16.16" PRIx64, nfit_struct->window_size); - fwts_log_info_verbatim(fw, " Command Register Offset: 0x%16.16" PRIx64, nfit_struct->command_offset); - fwts_log_info_verbatim(fw, " Size of Command Register: 0x%16.16" PRIx64, nfit_struct->command_size); - fwts_log_info_verbatim(fw, " Status RegisterOffset: 0x%16.16" PRIx64, nfit_struct->status_offset); - fwts_log_info_verbatim(fw, " Size of Status Register: 0x%16.16" PRIx64, nfit_struct->status_size); - fwts_log_info_verbatim(fw, " NVDIMM Control Region Flag: 0x%4.4" PRIx16, nfit_struct->flags); - fwts_log_info_verbatim(fw, " Reserved: 0x%16.16" PRIx64, reserved1); if (nfit_struct->revision_id & 0xFF00) { passed = false; @@ -285,11 +329,38 @@ static int nfit_test1(fwts_framework *fw) reserved_passed = nfit_struct->reserved; fwts_acpi_reserved_bits_check(fw, "NFIT", "Valid", nfit_struct->valid_fields, sizeof(nfit_struct->valid_fields), 1, 7, &passed); - fwts_acpi_reserved_bits_check(fw, "NFIT", "NVDIMM Control Region Flags", nfit_struct->flags, sizeof(nfit_struct->flags), 1, 15, &passed); + + if (entry->length >= sizeof(*nfit_struct)) { + reserved1 = (uint64_t) nfit_struct->reserved1[0] + ((uint64_t) nfit_struct->reserved1[1] << 8) + + ((uint64_t) nfit_struct->reserved1[2] << 16) + ((uint64_t) nfit_struct->reserved1[3] << 24) + + ((uint64_t) nfit_struct->reserved1[4] << 32) + ((uint64_t) nfit_struct->reserved1[5] << 40); + + if (reserved1 != 0) + reserved_passed = reserved1; + + fwts_log_info_verbatim(fw, " Size of Block Control Window: 0x%16.16" PRIx64, nfit_struct->window_size); + fwts_log_info_verbatim(fw, " Command Register Offset: 0x%16.16" PRIx64, nfit_struct->command_offset); + fwts_log_info_verbatim(fw, " Size of Command Register: 0x%16.16" PRIx64, nfit_struct->command_size); + fwts_log_info_verbatim(fw, " Status RegisterOffset: 0x%16.16" PRIx64, nfit_struct->status_offset); + fwts_log_info_verbatim(fw, " Size of Status Register: 0x%16.16" PRIx64, nfit_struct->status_size); + fwts_log_info_verbatim(fw, " NVDIMM Control Region Flag: 0x%4.4" PRIx16, nfit_struct->flags); + fwts_log_info_verbatim(fw, " Reserved: 0x%16.16" PRIx64, reserved1); + + fwts_acpi_reserved_bits_check(fw, "NFIT", "NVDIMM Control Region Flags", nfit_struct->flags, sizeof(nfit_struct->flags), 1, 15, &passed); + fwts_log_info_verbatim(fw, " NVDIMM Control Region Structure Index: 0x%4.4" PRIx16, nfit_struct->region_index); + } } else if (entry->type == FWTS_ACPI_NFIT_TYPE_DATA_REGION) { fwts_acpi_table_nfit_data_range *nfit_struct = (fwts_acpi_table_nfit_data_range *) entry; + bool ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_DATA_REGION, + FWTS_ACPI_NFIT_NAME_DATA_REGION); + if (!ret) { + passed = false; + break; + } + fwts_log_info_verbatim(fw, " NVDIMM Control Region Structure Index: 0x%4.4" PRIx16, nfit_struct->region_index); fwts_log_info_verbatim(fw, " Number of Block Data Windows: 0x%4.4" PRIx16, nfit_struct->window_num); fwts_log_info_verbatim(fw, " Block Data Window Start Offset: 0x%16.16" PRIx64, nfit_struct->window_offset); @@ -309,6 +380,14 @@ static int nfit_test1(fwts_framework *fw) uint64_t reserved; uint16_t i; + bool ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_FLUSH_ADDRESS, + FWTS_ACPI_NFIT_NAME_FLUSH_ADDRESS); + if (!ret) { + passed = false; + break; + } + reserved = (uint64_t) nfit_struct->reserved[0] + ((uint64_t) nfit_struct->reserved[1] << 8) + ((uint64_t) nfit_struct->reserved[2] << 16) + ((uint64_t) nfit_struct->reserved[3] << 24) + ((uint64_t) nfit_struct->reserved[4] << 32) + ((uint64_t) nfit_struct->reserved[5] << 40); @@ -316,6 +395,16 @@ static int nfit_test1(fwts_framework *fw) fwts_log_info_verbatim(fw, " NFIT Device Handle: 0x%8.8" PRIx32, nfit_struct->device_handle); fwts_log_info_verbatim(fw, " Number of Flush Hint Addresses: 0x%4.4" PRIx16, nfit_struct->hint_count); fwts_log_info_verbatim(fw, " Reserved: 0x%16.16" PRIx64, reserved); + + ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_FLUSH_ADDRESS + + nfit_struct->hint_count * sizeof nfit_struct->hint_address[0], + FWTS_ACPI_NFIT_NAME_FLUSH_ADDRESS); + if (!ret) { + passed = false; + break; + } + for (i = 0; i < nfit_struct->hint_count; i++) fwts_log_info_verbatim(fw, " Flush Hint Address: 0x%16.16" PRIx64, nfit_struct->hint_address[i]); @@ -326,6 +415,14 @@ static int nfit_test1(fwts_framework *fw) fwts_acpi_table_nfit_platform_cap *nfit_struct = (fwts_acpi_table_nfit_platform_cap *) entry; uint32_t reserved1; + bool ret = check_length(fw, entry->length, + FWTS_ACPI_NFIT_MINLEN_PLATFORM_CAPABILITY, + FWTS_ACPI_NFIT_NAME_PLATFORM_CAPABILITY); + if (!ret) { + passed = false; + break; + } + reserved1 = (uint32_t) nfit_struct->reserved1[0] + ((uint32_t) nfit_struct->reserved1[1] << 8) + ((uint32_t) nfit_struct->reserved1[2] << 16); diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h index e550cd76..10dedb6a 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -1181,6 +1181,24 @@ typedef enum { FWTS_ACPI_NFIT_TYPE_RESERVED = 8 /* >= 8 are reserved */ } fwts_acpi_nfit_type; +#define FWTS_ACPI_NFIT_NAME_SYSTEM_ADDRESS "SPA Range structure" +#define FWTS_ACPI_NFIT_NAME_MEMORY_MAP "NVDIMM Region Mapping structure" +#define FWTS_ACPI_NFIT_NAME_INTERLEAVE "Interleave structure" +#define FWTS_ACPI_NFIT_NAME_SMBIOS "SMBIOS Management Information structure" +#define FWTS_ACPI_NFIT_NAME_CONTROL_REGION "NVDIMM Control Region structure" +#define FWTS_ACPI_NFIT_NAME_DATA_REGION "NVDIMM Block Data Window Region structure" +#define FWTS_ACPI_NFIT_NAME_FLUSH_ADDRESS "Flush Hint Address structure" +#define FWTS_ACPI_NFIT_NAME_PLATFORM_CAPABILITY "Platform Capabilities structure" + +#define FWTS_ACPI_NFIT_MINLEN_SYSTEM_ADDRESS 56 +#define FWTS_ACPI_NFIT_MINLEN_MEMORY_MAP 48 +#define FWTS_ACPI_NFIT_MINLEN_INTERLEAVE 16 +#define FWTS_ACPI_NFIT_MINLEN_SMBIOS 8 +#define FWTS_ACPI_NFIT_MINLEN_CONTROL_REGION 32 +#define FWTS_ACPI_NFIT_MINLEN_DATA_REGION 32 +#define FWTS_ACPI_NFIT_MINLEN_FLUSH_ADDRESS 16 +#define FWTS_ACPI_NFIT_MINLEN_PLATFORM_CAPABILITY 16 + typedef struct { fwts_acpi_table_nfit_struct_header header; uint16_t range_index; From patchwork Fri Jul 6 14:42:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elliott, Robert (Servers)" X-Patchwork-Id: 940546 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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=none (p=none dis=none) header.from=hpe.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41McrK74lbz9s4V; Sat, 7 Jul 2018 00:42:09 +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 1fbRvz-0000yY-Ic; Fri, 06 Jul 2018 14:42:07 +0000 Received: from g4t3426.houston.hpe.com ([15.241.140.75]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1fbRvw-0000xr-BO for fwts-devel@lists.ubuntu.com; Fri, 06 Jul 2018 14:42:04 +0000 Received: from g4t3433.houston.hpecorp.net (g4t3433.houston.hpecorp.net [16.208.49.245]) by g4t3426.houston.hpe.com (Postfix) with ESMTP id 184FF5A for ; Fri, 6 Jul 2018 14:42:03 +0000 (UTC) Received: from s17.americas.hpqcorp.net (s17.americas.hpqcorp.net [16.84.27.163]) by g4t3433.houston.hpecorp.net (Postfix) with ESMTP id E5B4E62; Fri, 6 Jul 2018 14:42:02 +0000 (UTC) From: Robert Elliott To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/2] nfit: remove broken NFITBadLineOffsetAlignment check Date: Fri, 6 Jul 2018 09:42:55 -0500 Message-Id: <20180706144255.56986-2-elliott@hpe.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180706144255.56986-1-elliott@hpe.com> References: <20180706144255.56986-1-elliott@hpe.com> 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: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Remove the NFITBadLineOffsetAlignment check. Entries in the ACPI NFIT Interleave structure are in units of the line size, not values required to be multiples of the line size. So, the test fails incorrectly with these errors: NFIT Subtable: Type: 0x0002 Length: 0x0050 Interleave Structure Index: 0x000c Reserved: 0x0000 Number of Lines Described: 0x00000010 Line Size: 0x00000100 Line Offset: 0x00000000 Line Offset: 0x00000001 FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x00000001 instead Line Offset: 0x00000002 FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x00000002 instead Line Offset: 0x00000003 FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x00000003 instead Line Offset: 0x00000004 FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x00000004 instead Line Offset: 0x00000005 FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x00000005 instead Line Offset: 0x00000006 FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x00000006 instead Line Offset: 0x00000007 FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x00000007 instead Line Offset: 0x00000008 FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x00000008 instead Line Offset: 0x00000009 FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x00000009 instead Line Offset: 0x0000000a FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x0000000a instead Line Offset: 0x0000000b FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x0000000b instead Line Offset: 0x0000000c FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x0000000c instead Line Offset: 0x0000000d FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x0000000d instead Line Offset: 0x0000000e FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x0000000e instead Line Offset: 0x0000000f FAILED [HIGH] NFITBadLineOffsetAlignment: Test 1, NFIT Line Offset must be aligned nfit_struct->line_size, got 0x0000000f instead Instead, print the full SPA address offset alongside the Line Offset (by multiplying by the Line Size). NFIT Subtable: Type: 0x0002 Length: 0x0050 Interleave Structure Index: 0x000c Reserved: 0x0000 Number of Lines Described: 0x00000010 Line Size: 0x00000100 Line Offset: 0x00000000, SPA 0x0000000000000000 Line Offset: 0x00000001, SPA 0x0000000000000100 Line Offset: 0x00000002, SPA 0x0000000000000200 Line Offset: 0x00000003, SPA 0x0000000000000300 Line Offset: 0x00000004, SPA 0x0000000000000400 Line Offset: 0x00000005, SPA 0x0000000000000500 Line Offset: 0x00000006, SPA 0x0000000000000600 Line Offset: 0x00000007, SPA 0x0000000000000700 Line Offset: 0x00000008, SPA 0x0000000000000800 Line Offset: 0x00000009, SPA 0x0000000000000900 Line Offset: 0x0000000a, SPA 0x0000000000000a00 Line Offset: 0x0000000b, SPA 0x0000000000000b00 Line Offset: 0x0000000c, SPA 0x0000000000000c00 Line Offset: 0x0000000d, SPA 0x0000000000000d00 Line Offset: 0x0000000e, SPA 0x0000000000000e00 Line Offset: 0x0000000f, SPA 0x0000000000000f00 Fixes: d11965d8346b9525 ("add ACPI NFIT test") Signed-off-by: Robert Elliott Acked-by: Alex Hung Acked-by: Ivan Hu --- src/acpi/nfit/nfit.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/acpi/nfit/nfit.c b/src/acpi/nfit/nfit.c index 99231501..961e5f28 100644 --- a/src/acpi/nfit/nfit.c +++ b/src/acpi/nfit/nfit.c @@ -250,15 +250,11 @@ static int nfit_test1(fwts_framework *fw) break; } - for (i = 0; i < nfit_struct->line_count; i++) { - fwts_log_info_verbatim(fw, " Line Offset: 0x%8.8" PRIx32, nfit_struct->line_offset[i]); - - if (nfit_struct->line_offset[i] % nfit_struct->line_size) - fwts_failed(fw, LOG_LEVEL_HIGH, - "NFITBadLineOffsetAlignment", - "NFIT Line Offset must be aligned nfit_struct->line_size, got " - "0x%8.8" PRIx32 " instead", nfit_struct->line_offset[i]); - } + for (i = 0; i < nfit_struct->line_count; i++) + fwts_log_info_verbatim(fw, + " Line Offset: 0x%8.8" PRIx32 ", SPA 0x%16.16" PRIx64, + nfit_struct->line_offset[i], + (uint64_t) nfit_struct->line_offset[i] * nfit_struct->line_size); if (nfit_struct->reserved != 0) reserved_passed = nfit_struct->reserved;