From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=QiLgPUdj; spf=pass (domain: arm.com, ip: 40.107.13.53, mailfrom: krzysztof.koch@arm.com) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.53]) by groups.io with SMTP; Thu, 11 Jul 2019 23:53:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yQ12PNwhUUV/Uh60P69yYOFLPQl1ISxpKIpVzsPTosI=; b=QiLgPUdjjz2boSWz+dx6tDbm7iocoJxYeenudDnEogST2tUo8IQJ3tLQStF3CFHKsveTxiH3GnxKuvQ++kS5q2jOYTaTIPJjlvMAjllkxROUhZWhhKR0OlDpzV1CHSo/0cncksTQdtEb+9A9Bzp3ZMObGMneLmhusEsFBE4cqcc= Received: from VI1PR08CA0151.eurprd08.prod.outlook.com (2603:10a6:800:d5::29) by AM5PR0802MB2594.eurprd08.prod.outlook.com (2603:10a6:203:99::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.16; Fri, 12 Jul 2019 06:53:31 +0000 Received: from DB5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::200) by VI1PR08CA0151.outlook.office365.com (2603:10a6:800:d5::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2073.14 via Frontend Transport; Fri, 12 Jul 2019 06:53:31 +0000 Authentication-Results: spf=temperror (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT040.mail.protection.outlook.com (10.152.20.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2052.18 via Frontend Transport; Fri, 12 Jul 2019 06:53:29 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Fri, 12 Jul 2019 06:53:17 +0000 Received: from E119924.Arm.com (10.37.8.167) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Fri, 12 Jul 2019 06:53:16 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [PATCH v1 03/11] ShellPkg: acpiview: RSDP: Make printing table checksum optional Date: Fri, 12 Jul 2019 07:52:35 +0100 Message-ID: <20190712065243.3812-4-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20190712065243.3812-1-krzysztof.koch@arm.com> References: <20190712065243.3812-1-krzysztof.koch@arm.com> Return-Path: Krzysztof.Koch@arm.com MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:40.67.248.234;IPV:NLI;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(376002)(396003)(346002)(136003)(2980300002)(189003)(199004)(7696005)(76176011)(1076003)(305945005)(81166006)(81156014)(8676002)(70586007)(11346002)(2616005)(426003)(486006)(2906002)(476003)(8936002)(126002)(51416003)(70206006)(47776003)(336012)(6916009)(26005)(966005)(186003)(478600001)(48376002)(53416004)(50226002)(44832011)(16586007)(50466002)(54906003)(5660300002)(68736007)(53936002)(14444005)(4326008)(6306002)(63350400001)(63370400001)(446003)(6666004)(356004)(36756003)(2351001)(86362001)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0802MB2594;H:nebula.arm.com;FPR:;SPF:TempError;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dad75a3a-17e2-47b8-625d-08d70695a5d1 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:AM5PR0802MB2594; X-MS-TrafficTypeDiagnostic: AM5PR0802MB2594: X-MS-Exchange-PUrlCount: 1 X-Microsoft-Antispam-PRVS: NoDisclaimer: True X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-Forefront-PRVS: 00963989E5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: hdxzlUBHL7z6NVFZc9OiDOJ7EI5pR06Wb2d/OgVqs9GGYATif4q4ItWJAsfTq4iXsSx5YM0PgUOVrPahlsy6UvO2dvapmKyzPWVfbG0cI5HHoPdd+BoOyuk8f7qMHAEDdy2f8mDsZQqmsrNLMCrROyhdXjT2Bv7Jkg841IZe3U/0DeYZJbkFgqcolc0mEyXDoE03eGbE5DprYNf9y7v1PzNG+5ZoF2RUQGpuIhwMDzJWq/lhmZN4qqnCVyySMCmvU1UYZu1P0+bloptSUOlty4Bg8084rkaJ0Wauqgjsv7o5rNvlNrKKDT23/QsaEPdboYccck6AfCOD2puR/rD7LGg2oeKcBQBn+9VBjGTghx6bOv/blk1GgLcM9xbNWfewhK2ddcOYC5hqsRyengrerqwY6o67HWPYgc+NUkCbk4o= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2019 06:53:29.7941 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dad75a3a-17e2-47b8-625d-08d70695a5d1 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[40.67.248.234];Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2594 Content-Type: text/plain 1. Don't validate Root System Description Pointer (RSDP) structure checksum if the '-q' command line flag is used with the acpiview UEFI shell tool. This change makes the RSDP parser consistent with the parsers for other ACPI tables. 2. Check if XsdtAddress pointer has been successfully updated before it is used for further table parsing. 3. Remove redundant forward function declarations by repositioning blocks of code. Signed-off-by: Krzysztof Koch --- Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/commit/73e6d7e117da244f8f4065620115a47f7f66d372 Notes: v1: - make RSDP parser behavior consistent with other tables [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 144 +++++++++----------- 1 file changed, 68 insertions(+), 76 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c index 586de7cbfb12f856c0c735b6e295c1cc32eb2ceb..952517cd09aaff601bb363fd73331c750a9e97ff 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c @@ -1,7 +1,7 @@ /** @file RSDP 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): @@ -11,6 +11,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiView.h" // Local Variables STATIC CONST UINT64* XsdtAddress; @@ -28,7 +29,27 @@ EFIAPI ValidateRsdtAddress ( IN UINT8* Ptr, IN VOID* Context - ); + ) +{ +#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) + // Reference: Server Base Boot Requirements System Software on ARM Platforms + // Section: 4.2.1.1 RSDP + // Root System Description Pointer (RSDP), ACPI ? 5.2.5. + // - Within the RSDP, the RsdtAddress field must be null (zero) and the + // XsdtAddresss MUST be a valid, non-null, 64-bit value. + UINT32 RsdtAddr; + + RsdtAddr = *(UINT32*)Ptr; + + if (RsdtAddr != 0) { + IncrementErrorCount (); + Print ( + L"\nERROR: Rsdt Address = 0x%p. This must be NULL on ARM Platforms.", + RsdtAddr + ); + } +#endif +} /** This function validates the XSDT Address. @@ -43,7 +64,27 @@ EFIAPI ValidateXsdtAddress ( IN UINT8* Ptr, IN VOID* Context - ); + ) +{ +#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) + // Reference: Server Base Boot Requirements System Software on ARM Platforms + // Section: 4.2.1.1 RSDP + // Root System Description Pointer (RSDP), ACPI ? 5.2.5. + // - Within the RSDP, the RsdtAddress field must be null (zero) and the + // XsdtAddresss MUST be a valid, non-null, 64-bit value. + UINT64 XsdtAddr; + + XsdtAddr = *(UINT64*)Ptr; + + if (XsdtAddr == 0) { + IncrementErrorCount (); + Print ( + L"\nERROR: Xsdt Address = 0x%p. This must not be NULL on ARM Platforms.", + XsdtAddr + ); + } +#endif +} /** An array describing the ACPI RSDP Table. @@ -61,76 +102,6 @@ STATIC CONST ACPI_PARSER RsdpParser[] = { {L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL} }; -/** - This function validates the RSDT Address. - - @param [in] Ptr Pointer to the start of the field data. - @param [in] Context Pointer to context specific information e.g. this - could be a pointer to the ACPI table header. -**/ -STATIC -VOID -EFIAPI -ValidateRsdtAddress ( - IN UINT8* Ptr, - IN VOID* Context - ) -{ -#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - // Reference: Server Base Boot Requirements System Software on ARM Platforms - // Section: 4.2.1.1 RSDP - // Root System Description Pointer (RSDP), ACPI ? 5.2.5. - // - Within the RSDP, the RsdtAddress field must be null (zero) and the - // XsdtAddresss MUST be a valid, non-null, 64-bit value. - UINT32 RsdtAddr; - - RsdtAddr = *(UINT32*)Ptr; - - if (RsdtAddr != 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Rsdt Address = 0x%p. This must be NULL on ARM Platforms.", - RsdtAddr - ); - } -#endif -} - -/** - This function validates the XSDT Address. - - @param [in] Ptr Pointer to the start of the field data. - @param [in] Context Pointer to context specific information e.g. this - could be a pointer to the ACPI table header. -**/ -STATIC -VOID -EFIAPI -ValidateXsdtAddress ( - IN UINT8* Ptr, - IN VOID* Context - ) -{ -#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - // Reference: Server Base Boot Requirements System Software on ARM Platforms - // Section: 4.2.1.1 RSDP - // Root System Description Pointer (RSDP), ACPI ? 5.2.5. - // - Within the RSDP, the RsdtAddress field must be null (zero) and the - // XsdtAddresss MUST be a valid, non-null, 64-bit value. - UINT64 XsdtAddr; - - XsdtAddr = *(UINT64*)Ptr; - - if (XsdtAddr == 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Xsdt Address = 0x%p. This must not be NULL on ARM Platforms.", - XsdtAddr - ); - } -#endif -} - /** This function parses the ACPI RSDP table. @@ -156,10 +127,31 @@ ParseAcpiRsdp ( { if (Trace) { DumpRaw (Ptr, AcpiTableLength); - VerifyChecksum (TRUE, Ptr, AcpiTableLength); + if (GetConsistencyChecking ()) { + VerifyChecksum (TRUE, Ptr, AcpiTableLength); + } } - ParseAcpi (Trace, 0, "RSDP", Ptr, AcpiTableLength, PARSER_PARAMS (RsdpParser)); + ParseAcpi ( + Trace, + 0, + "RSDP", + Ptr, + AcpiTableLength, + PARSER_PARAMS (RsdpParser) + ); + + // Check if the values used to control the parsing logic have been + // successfully read. + if (XsdtAddress == NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength = %d." \ + L"RSDP parsing aborted.\n", + AcpiTableLength + ); + return; + } // This code currently supports parsing of XSDT table only // and does not parse the RSDT table. Platforms provide the @@ -167,7 +159,7 @@ ParseAcpiRsdp ( // Therefore the RSDT should not be used on ARM platforms. if ((*XsdtAddress) == 0) { IncrementErrorCount (); - Print (L"ERROR: XSDT Pointer is not set.\n"); + Print (L"ERROR: XSDT Pointer is not set. RSDP parsing aborted.\n"); return; } -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'