From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector1-arm-com header.b=UDASTc1/; spf=pass (domain: arm.com, ip: 40.107.14.70, mailfrom: krzysztof.koch@arm.com) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.70]) by groups.io with SMTP; Thu, 16 May 2019 01:43:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YdIMlCd6I/g87uZ5pKwsHygo3yLwmVNCfc33rfOa8EA=; b=UDASTc1/UkdeSIWQVbm+tPksDCWV3RRgJv6Dke7FG4ZPP7v4HlxfDayOAWYs+cjmvyeFB862uUa5EqDr185EyYxkXSpv3oEqnpYcwos0P6XaJdwD+YwGp+2NlhJTkh9AGm5b5zMzz8tv/rpVTsFVdOFMl4+f6Vk9VSZif2QGxWE= Received: from DB6PR0802CA0032.eurprd08.prod.outlook.com (2603:10a6:4:a3::18) by DBBPR08MB4776.eurprd08.prod.outlook.com (2603:10a6:10:d5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.22; Thu, 16 May 2019 08:43:46 +0000 Received: from VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by DB6PR0802CA0032.outlook.office365.com (2603:10a6:4:a3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1900.16 via Frontend Transport; Thu, 16 May 2019 08:43:46 +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 VE1EUR03FT021.mail.protection.outlook.com (10.152.18.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.1900.16 via Frontend Transport; Thu, 16 May 2019 08:43:44 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Thu, 16 May 2019 08:43:41 +0000 Received: from E119924.Arm.com (10.1.37.21) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 16 May 2019 08:43:41 +0000 From: "Krzysztof Koch" To: CC: , , , , Subject: [PATCH v2 1/1] ShellPkg: acpiview: Add GT Frame Number validation to GTDT parser Date: Thu, 16 May 2019 09:43:35 +0100 Message-ID: <20190516084335.33928-1-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 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:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(376002)(136003)(39860400002)(396003)(2980300002)(189003)(199004)(44832011)(1076003)(478600001)(2616005)(305945005)(486006)(63370400001)(336012)(72206003)(966005)(126002)(476003)(426003)(356004)(6666004)(2351001)(63350400001)(6916009)(4326008)(53936002)(5660300002)(54906003)(50226002)(8936002)(81166006)(8676002)(53416004)(86362001)(77096007)(186003)(68736007)(16586007)(6306002)(316002)(14444005)(36756003)(70206006)(2906002)(70586007)(48376002)(26005)(81156014)(7696005)(47776003)(50466002)(51416003);DIR:OUT;SFP:1101;SCL:1;SRVR:DBBPR08MB4776;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: 2bb7e8e7-14a5-4a05-0ec0-08d6d9da9b3c X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328);SRVR:DBBPR08MB4776; X-MS-TrafficTypeDiagnostic: DBBPR08MB4776: X-MS-Exchange-PUrlCount: 1 NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0039C6E5C5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: J73CGTsEcyVflu8UT9o3dp9hOvdNQMLJAvzaVrAeY4GyHosjC2S9Nu/iPuoyrEgimpPAbdMUofXlw+WJRsHRC1BXInyFiBNyU3kujavSh9dN5F8vQ06pawrRQ6/rK84ymPbLP6NuxxHHderwbkchf5HGy35WCWFT7okDGg11x+plNqipw41ZVILifvDIdxbnOKsMazsdszy7gvjFzoRPaLLOksZb1GkKltJy8QVRSYepiUJKt6a0Bc+hTtn19pt9ZDR2fedfdlTOZHe5mvukfnju5HRxpA52FbY+GIqpE/F4YcrTXNCoNEBT+ogFqPnq2gyrOVwWQ3gt2uCWfk5pm1X38N3R9MmSrbX+rWBYVkNsOAdyuHeKDFYmkU6xuzT3D/hqDmMrxaTmV0dPIB0vR4XE+HOljJTD4+BEMhJqw7M= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2019 08:43:44.8805 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bb7e8e7-14a5-4a05-0ec0-08d6d9da9b3c 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: DBBPR08MB4776 Content-Type: text/plain The ACPI 6.2 specification mandates that the Generic Timer (GT) Block Timer Structures must have a frame number in the range 0-7. Update the GTDT parser to warn if this condition is violated. Signed-off-by: Krzysztof Koch --- The changes can be seen at: https://github.com/KrzysztofKoch1/edk2/tree/528_acpiview_gt_frame_validate_v2 Notes: v2: - Change FrameNumber data type to UINT8 [Zhichao] - Modify the patch based on upstream review [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c | 47 +++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c index f31c4a2761751c58d4b1d3eb75084e24ec318e7f..1b7e56486c8fb98a8fe063ae5fa25d86500a58a9 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c @@ -1,7 +1,7 @@ /** @file GTDT 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): @@ -38,6 +38,21 @@ ValidateGtBlockTimerCount ( IN VOID* Context ); +/** + This function validates the GT Frame Number. + + @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 +ValidateGtFrameNumber ( + IN UINT8* Ptr, + IN VOID* Context + ); + /** An ACPI_PARSER array describing the ACPI GTDT Table. **/ @@ -92,7 +107,7 @@ STATIC CONST ACPI_PARSER GtBlockParser[] = { An ACPI_PARSER array describing the GT Block timer. **/ STATIC CONST ACPI_PARSER GtBlockTimerParser[] = { - {L"Frame Number", 1, 0, L"%d", NULL, NULL, NULL, NULL}, + {L"Frame Number", 1, 0, L"%d", NULL, NULL, ValidateGtFrameNumber, NULL}, {L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}, {L"Physical address (CntBaseX)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL}, {L"Physical address (CntEL0BaseX)", 8, 12, L"0x%lx", NULL, NULL, NULL, @@ -145,6 +160,34 @@ ValidateGtBlockTimerCount ( } } +/** + This function validates the GT Frame Number. + + @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 +ValidateGtFrameNumber ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + UINT8 FrameNumber; + + FrameNumber = *(UINT8*)Ptr; + + if (FrameNumber > 7) { + IncrementErrorCount (); + Print ( + L"\nERROR: GT Frame Number = %d. GT Frame Number must be in range 0-7.", + FrameNumber + ); + } +} + /** This function parses the Platform GT Block. -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'