From nobody Wed Apr 24 00:18:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43644+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1562914416; cv=none; d=zoho.com; s=zohoarc; b=OBRPIcHDPx/ukMXVhE9oU5d/9Kimi4+mG/6/+DX4fd/FxoRo1YlVcGJNldr+HWSCxZjkYLrwi5/jL1qZikC/wkaVTgHU8OPeVPbhHmimpDtX1UI/izH8uwtz20h32CShXnRBL4ypz+m6k4gQPwQtitQNRBRRgOU8xADxY6NP1J4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562914416; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=e2HT16Hx4pKkYwqsMFXgd3vjToJDbSfmq5lH4R7hX1U=; b=dIz7veLjaReFkNNgZoWgoCjFk5Q8642PUGW+2qAEztSiAJxuZVhyKDW5DQbJcJJsSFdy7hrKHswESBXqospsI/AnCGo6A7IltT64qDbJ9HC8OSZpw/R/WXpRMHrBfPOSMnncZhlSagYGODpsON3EpW7aNxySz9I+dEfSDNKxyl4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43644+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1562914416518490.6146139445218; Thu, 11 Jul 2019 23:53:36 -0700 (PDT) Return-Path: X-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 X-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 X-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 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+43644+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-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 X-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 X-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: [edk2-devel] [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> In-Reply-To: <20190712065243.3812-1-krzysztof.koch@arm.com> References: <20190712065243.3812-1-krzysztof.koch@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dad75a3a-17e2-47b8-625d-08d70695a5d1 X-MS-TrafficTypeDiagnostic: AM5PR0802MB2594: X-MS-Exchange-PUrlCount: 1 X-Microsoft-Antispam-PRVS: NoDisclaimer: True X-MS-Oob-TLC-OOBClassifiers: OLM:3826; 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 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1562914416; bh=qQavICRIpAu0aAUbst4Mb4VBzcn1dozdu2wrPXqYavw=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=MXj8ljcSy2wHF4ENY5tQKlA4CaIq1tkNzN+C/xKprfb/TQJk7ik5FmCTBsNaDvEvC0Q CBq+G/FlIIgEaDnGmRTUrFGLCIBB5HJrvMku/blj96LZOWpSyDz4nblXLq+73JHS42paV 0ToE8h6R9z2lWK4Ioa5U7Jg729MYvL7hG0o= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Alexei Fedorov --- Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/commit/73e6d= 7e117da244f8f4065620115a47f7f66d372 Notes: v1: - make RSDP parser behavior consistent with other tables [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 1= 44 +++++++++----------- 1 file changed, 68 insertions(+), 76 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/Rsdp= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpPa= rser.c index 586de7cbfb12f856c0c735b6e295c1cc32eb2ceb..952517cd09aaff601bb363fd733= 31c750a9e97ff 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 =20 - 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 =20 @par Reference(s): @@ -11,6 +11,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiView.h" =20 // 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 Platf= orms + // 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 =3D *(UINT32*)Ptr; + + if (RsdtAddr !=3D 0) { + IncrementErrorCount (); + Print ( + L"\nERROR: Rsdt Address =3D 0x%p. This must be NULL on ARM Platforms= .", + RsdtAddr + ); + } +#endif +} =20 /** 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 Platf= orms + // 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 =3D *(UINT64*)Ptr; + + if (XsdtAddr =3D=3D 0) { + IncrementErrorCount (); + Print ( + L"\nERROR: Xsdt Address =3D 0x%p. This must not be NULL on ARM Platf= orms.", + XsdtAddr + ); + } +#endif +} =20 /** An array describing the ACPI RSDP Table. @@ -61,76 +102,6 @@ STATIC CONST ACPI_PARSER RsdpParser[] =3D { {L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL} }; =20 -/** - 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 Platf= orms - // 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 =3D *(UINT32*)Ptr; - - if (RsdtAddr !=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Rsdt Address =3D 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 Platf= orms - // 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 =3D *(UINT64*)Ptr; - - if (XsdtAddr =3D=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Xsdt Address =3D 0x%p. This must not be NULL on ARM Platf= orms.", - XsdtAddr - ); - } -#endif -} - /** This function parses the ACPI RSDP table. =20 @@ -156,10 +127,31 @@ ParseAcpiRsdp ( { if (Trace) { DumpRaw (Ptr, AcpiTableLength); - VerifyChecksum (TRUE, Ptr, AcpiTableLength); + if (GetConsistencyChecking ()) { + VerifyChecksum (TRUE, Ptr, AcpiTableLength); + } } =20 - ParseAcpi (Trace, 0, "RSDP", Ptr, AcpiTableLength, PARSER_PARAMS (RsdpPa= rser)); + 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 =3D=3D NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength =3D %d." \ + L"RSDP parsing aborted.\n", + AcpiTableLength + ); + return; + } =20 // 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) =3D=3D 0) { IncrementErrorCount (); - Print (L"ERROR: XSDT Pointer is not set.\n"); + Print (L"ERROR: XSDT Pointer is not set. RSDP parsing aborted.\n"); return; } =20 -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#43644): https://edk2.groups.io/g/devel/message/43644 Mute This Topic: https://groups.io/mt/32439506/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-