From nobody Thu Apr 25 23:22:56 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+43642+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1562914409; cv=none; d=zoho.com; s=zohoarc; b=USgeY51VjuA+2+FNtXod/LR8N5zgTM7DKgLpaTkZPsluLQ4LEWsM5be+46q19V6BJo091ilFXywFBJgMH+LxJWmyy6yGqirDYjnxOeOBCd7RY/pi8TzJ+rDD0GGP3VCHozJC8EcoJ2n9llomv715dEtOPVmQD0uhMQgVORSTBPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562914409; 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=4JZKD718irALbzxhktOg70VA8TvGDUxP9ckJWdtcr1U=; b=mOAnn9WlAn6iLEshOlyFS2B/rKrJQxglRXBu6L/52iU1kVBnFTC1saF4EBTKsKO1riuYSb3oHZ1B8QrW8VEYFm5+/rxjXb7DcMgnc5StFN/YouTQD4rMos2m8/8eyOpwwiqEhCmNXNeCqXyi1ZQG0SFArlo9Do9TtVKA4D9EuUY= 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+43642+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1562914409785713.5045274915612; Thu, 11 Jul 2019 23:53:29 -0700 (PDT) Return-Path: X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.45]) by groups.io with SMTP; Thu, 11 Jul 2019 23:53:28 -0700 X-Received: from VI1PR08CA0147.eurprd08.prod.outlook.com (2603:10a6:800:d5::25) by VI1PR0802MB2608.eurprd08.prod.outlook.com (2603:10a6:800:ae::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.19; Fri, 12 Jul 2019 06:53:24 +0000 X-Received: from DB5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::201) by VI1PR08CA0147.outlook.office365.com (2603:10a6:800:d5::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2073.11 via Frontend Transport; Fri, 12 Jul 2019 06:53:24 +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+43642+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:22 +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:15 +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:14 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 01/11] ShellPkg: acpiview: FADT: Validate global pointers before use Date: Fri, 12 Jul 2019 07:52:33 +0100 Message-ID: <20190712065243.3812-2-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: 3d292c97-2e97-4b68-d023-08d70695a182 X-MS-TrafficTypeDiagnostic: VI1PR0802MB2608: X-MS-Exchange-PUrlCount: 1 X-Microsoft-Antispam-PRVS: NoDisclaimer: True X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: hT7OkivdAQi5mhkNjVpO0n7BJkDJuV3gygI5giEYApOLg9rbE6Q6J5faXoCYL5tJoeRH1s+XZTbyEj//3sSRqBgBf7IOQx3EzbBsBRcFR25BKs22tp8Tp6f1mbrCOBBYBhNDOM6iRao0nO0v/E8WW1PrRoZyIe1gf1ufWR36YOIG4mxzQjRSo0yf1nKB13CLHagke8zUP/FuqFgdc3VRT6kafOqjLkrgZbIVE8mSKnj8w3jXtsAsv71k0YHhw6gzKUMNZEvmfQwqNTqFa8/Ks6LjM+1ib89dLpMAakxUw/p179WOYs83G4BoZ/V38TiA1WRyhmyTzFj4u0iL4+NJPZZ7bcCrwW0CQRY2FNv5uD+TyFBj6kzgpK7m6/2bgmCgjisWdX9NrEP38kw0D6YM3A6fVBbMp3CPzcHPblizixw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2019 06:53:22.5702 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d292c97-2e97-4b68-d023-08d70695a182 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: VI1PR0802MB2608 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=1562914409; bh=TnaPax0RjFUee7S+W8UFlpb691YhjwhZRTrtu4rkIk4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=GGmIpOnESRiR0ts6LLRYiMQgdHCgcw0g/bkgv5ZzqLreSmShSeAefBvxWdnhY52zcMO 6iYgUT1SCR90l7ZVYbGptnj5Ng/s46WUGwwZ7ffhdBSjyKEyNmFgAPM4VbEInOjxlbahk QEAWkPRQa5Egx+183+7bmAZXBoxoXEXLcmM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 1. Check if the global pointer have been successfully updated before they are later used to control the parsing logic in the FADT acpiview parser. 2. Remove redundant forward function declarations by repositioning blocks of code. 3. Allow silencing ACPI table content validation errors which do not cause table parsing to fail. Signed-off-by: Krzysztof Koch Reviewed-by: Jaben Carsey --- Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/commit/49cc4= 1430775fb93205e302590a7d31f080c3952 Notes: v1: - improve the logic in the parser [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c | 1= 31 ++++++++------------ 1 file changed, 51 insertions(+), 80 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/Fadt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPa= rser.c index cee7ee0770433da96d6042d2f5d687903f4b5495..600d3b16d7b22b61c1a1fd21ecb= 93f16c7f8fa1a 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c @@ -1,7 +1,7 @@ /** @file FADT 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): @@ -12,6 +12,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiView.h" =20 // Local variables STATIC CONST UINT32* DsdtAddress; @@ -46,7 +47,17 @@ EFIAPI ValidateFirmwareCtrl ( IN UINT8* Ptr, IN VOID* Context - ); +) +{ +#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) + if (*(UINT32*)Ptr !=3D 0) { + IncrementErrorCount (); + Print ( + L"\nERROR: Firmware Control must be zero for ARM platforms." + ); + } +#endif +} =20 /** This function validates the X_Firmware Control Field. @@ -61,7 +72,17 @@ EFIAPI ValidateXFirmwareCtrl ( IN UINT8* Ptr, IN VOID* Context - ); +) +{ +#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) + if (*(UINT64*)Ptr !=3D 0) { + IncrementErrorCount (); + Print ( + L"\nERROR: X Firmware Control must be zero for ARM platforms." + ); + } +#endif +} =20 /** This function validates the flags. @@ -76,7 +97,17 @@ EFIAPI ValidateFlags ( IN UINT8* Ptr, IN VOID* Context - ); +) +{ +#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) + if (((*(UINT32*)Ptr) & HW_REDUCED_ACPI) =3D=3D 0) { + IncrementErrorCount (); + Print ( + L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms." + ); + } +#endif +} =20 /** An ACPI_PARSER array describing the ACPI FADT Table. @@ -142,81 +173,6 @@ STATIC CONST ACPI_PARSER FadtParser[] =3D { {L"Hypervisor VendorIdentity", 8, 268, L"%lx", NULL, NULL, NULL, NULL} }; =20 -/** - This function validates the Firmware Control Field. - - @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 -ValidateFirmwareCtrl ( - IN UINT8* Ptr, - IN VOID* Context -) -{ -#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (*(UINT32*)Ptr !=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Firmware Control must be zero for ARM platforms." - ); - } -#endif -} - -/** - This function validates the X_Firmware Control Field. - - @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 -ValidateXFirmwareCtrl ( - IN UINT8* Ptr, - IN VOID* Context -) -{ -#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (*(UINT64*)Ptr !=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: X Firmware Control must be zero for ARM platforms." - ); - } -#endif -} - -/** - This function validates the flags. - - @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 -ValidateFlags ( - IN UINT8* Ptr, - IN VOID* Context -) -{ -#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (((*(UINT32*)Ptr) & HW_REDUCED_ACPI) =3D=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms." - ); - } -#endif -} - /** This function parses the ACPI FADT table. This function parses the FADT table and optionally traces the ACPI table= fields. @@ -248,12 +204,27 @@ ParseAcpiFadt ( PARSER_PARAMS (FadtParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((DsdtAddress =3D=3D NULL) || + (FadtMinorRevision =3D=3D NULL) || + (X_DsdtAddress =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength =3D %d. " \ + L"FADT parsing aborted.\n", + AcpiTableLength + ); + return; + } + if (Trace) { Print (L"\nSummary:\n"); PrintFieldName (2, L"FADT Version"); Print (L"%d.%d\n", *AcpiHdrInfo.Revision, *FadtMinorRevision); =20 - if (*GetAcpiXsdtHeaderInfo ()->OemTableId !=3D *AcpiHdrInfo.OemTableId= ) { + if (GetConsistencyChecking () && + (*GetAcpiXsdtHeaderInfo ()->OemTableId !=3D *AcpiHdrInfo.OemTableI= d)) { IncrementErrorCount (); Print (L"ERROR: OEM Table Id does not match with RSDT/XSDT.\n"); } -- '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 (#43642): https://edk2.groups.io/g/devel/message/43642 Mute This Topic: https://groups.io/mt/32439503/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-