1. Remove a call to ParseAcpi responsible for getting the XSDT table length. This call is not needed because the ACPI table buffer length is provided as an input argument to the ParseAcpiXsdt() function.
2. Use ParseAcpiXsdt function argument instead of a global variable to check against table buffer overruns. 3. Allow suppressing errors about invalid ACPI table poiners inside the XSDT table. Signed-off-by: Krzysztof Koch <krzysztof.k...@arm.com> --- Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/commit/27b4ae23c4f230225d6bcb27598b42edcf329512 Notes: v1: - Remove a redundant call to ParseAcpi() [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c | 22 +++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c index 4196168bff47d70c67f79f3fc1f4cdee302d460e..b7d8f4215a71ef429fb88d6f2d998d8f38250716 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c @@ -1,7 +1,7 @@ /** @file XSDT table parser - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @par Reference(s): @@ -13,6 +13,7 @@ #include <Library/PrintLib.h> #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiView.h" // Local variables STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; @@ -60,22 +61,12 @@ ParseAcpiXsdt ( UINTN EntryIndex; CHAR16 Buffer[32]; - // Parse the ACPI header to get the length - ParseAcpi ( - FALSE, - 0, - "XSDT", - Ptr, - ACPI_DESCRIPTION_HEADER_LENGTH, - PARSER_PARAMS (XsdtParser) - ); - Offset = ParseAcpi ( Trace, 0, "XSDT", Ptr, - *AcpiHdrInfo.Length, + AcpiTableLength, PARSER_PARAMS (XsdtParser) ); @@ -84,7 +75,7 @@ ParseAcpiXsdt ( if (Trace) { EntryIndex = 0; TablePointer = (UINT64*)(Ptr + TableOffset); - while (Offset < (*AcpiHdrInfo.Length)) { + while (Offset < AcpiTableLength) { CONST UINT32* Signature; CONST UINT32* Length; CONST UINT8* Revision; @@ -124,7 +115,8 @@ ParseAcpiXsdt ( Print (L"0x%lx\n", *TablePointer); // Validate the table pointers are not NULL - if ((UINT64*)(UINTN)(*TablePointer) == NULL) { + if (GetConsistencyChecking () && + ((UINT64*)(UINTN)(*TablePointer) == NULL)) { IncrementErrorCount (); Print ( L"ERROR: Invalid table entry at 0x%lx, table address is 0x%lx\n", @@ -140,7 +132,7 @@ ParseAcpiXsdt ( // Process the tables Offset = TableOffset; TablePointer = (UINT64*)(Ptr + TableOffset); - while (Offset < (*AcpiHdrInfo.Length)) { + while (Offset < AcpiTableLength) { if ((UINT64*)(UINTN)(*TablePointer) != NULL) { ProcessAcpiTable ((UINT8*)(UINTN)(*TablePointer)); } -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#43645): https://edk2.groups.io/g/devel/message/43645 Mute This Topic: https://groups.io/mt/32439507/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-