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=3p87iu7O; spf=pass (domain: arm.com, ip: 40.107.15.58, mailfrom: krzysztof.koch@arm.com) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (EUR01-DB5-obe.outbound.protection.outlook.com [40.107.15.58]) by groups.io with SMTP; Fri, 28 Jun 2019 03:24:56 -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=LnTKHQiLO2rFcZUZIljJ8yLgYQwekZKOb4Hfp8Qz8W0=; b=3p87iu7OL50XDhMkPsfegHmpCW22Xa/pHIzuJAJCI8fyXajJLTL/UICXHYXw23U7xEDjUHDpYG02xz58NeHOjHEO4Cl0iz2zjHy/tz+CZz6y/MU3E4WDIyhtQ13aTi65HUjLsGkrNp0VpS5YkO/VCLH6IyzjTuZXFXGmi4lMAfk= Received: from VI1PR08CA0125.eurprd08.prod.outlook.com (2603:10a6:800:d4::27) by VI1PR08MB3967.eurprd08.prod.outlook.com (2603:10a6:803:df::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2032.17; Fri, 28 Jun 2019 10:24:52 +0000 Received: from AM5EUR03FT044.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::200) by VI1PR08CA0125.outlook.office365.com (2603:10a6:800:d4::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2032.18 via Frontend Transport; Fri, 28 Jun 2019 10:24:52 +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 AM5EUR03FT044.mail.protection.outlook.com (10.152.17.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2032.15 via Frontend Transport; Fri, 28 Jun 2019 10:24:50 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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; Fri, 28 Jun 2019 10:24:46 +0000 Received: from E119924.Arm.com (10.1.199.124) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Fri, 28 Jun 2019 10:24:46 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [PATCH v1 1/4] ShellPkg: acpiview: Improve PPTT table field validation Date: Fri, 28 Jun 2019 11:24:35 +0100 Message-ID: <20190628102438.30544-2-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20190628102438.30544-1-krzysztof.koch@arm.com> References: <20190628102438.30544-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)(346002)(376002)(396003)(39860400002)(136003)(2980300002)(189003)(199004)(336012)(51416003)(486006)(8676002)(126002)(68736007)(26005)(2351001)(36756003)(2616005)(966005)(6306002)(77096007)(476003)(47776003)(6916009)(81166006)(72206003)(53416004)(7696005)(446003)(478600001)(81156014)(53936002)(11346002)(44832011)(186003)(8936002)(76176011)(316002)(54906003)(4326008)(2906002)(50466002)(6666004)(426003)(48376002)(1076003)(86362001)(70206006)(5660300002)(305945005)(63370400001)(50226002)(63350400001)(70586007)(16586007)(356004);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR08MB3967;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: fffe9225-09a9-43cd-036a-08d6fbb2da9d X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:VI1PR08MB3967; X-MS-TrafficTypeDiagnostic: VI1PR08MB3967: X-MS-Exchange-PUrlCount: 1 NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:473; X-Forefront-PRVS: 00826B6158 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Np+qks3b9Yf5zZSDRNYeYaHzBbxDTluDXxzzhFxdQzGfRv/5HaFybjHiYdWJp3x5bH411EIPQZtvy4Lcyvjs5A4MntBH68isceC1AuGlQ8IEhlh/kBs6cDob4iqUEOri2m4/hlAexm5iRErtvHE4wfIAka7YGyFC8pBdiYAD0YeGPzMYQo7dU9KWXNZzQ93xyskbgwAdFtQ5slJOWdcO3HafmPa5v53YcRLiVWhlbwxkAyzPkQbPAtfGDS3IXNOy0IZJNquE0kjAtyoAp1fskNyytQP6XiaGX8Ni+DJQrh+hdajPm4PmTgM4eDSEm13nnwu4rQKXTvyxOqZfbIjVkew/xI11q7gUZdBrQSedDQhjUlxbSU2kvzMm/FDYnrLnW/ikh1V7Gqead7D2/UvJeKvYqR2OEgc9qReBs5xkciQ= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2019 10:24:50.8626 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fffe9225-09a9-43cd-036a-08d6fbb2da9d 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: VI1PR08MB3967 Content-Type: text/plain Add Cache Structure (Type 1) 'Number of sets' and 'Associativity' field validation in the acpiview Processor Properties Topology Table (PPTT) parser. Replace literal values with precompiler macros for existing Cache Structure validation functions. Signed-off-by: Krzysztof Koch --- Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/commit/014f98b8f1ba29607d8d465cac779badc3c79982 Notes: v1: - Use macros to define constant values used for validation [Krzysztof] - Add two new PPTT Type 1 structure validation functions [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 102 ++++++++++++++++++-- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.h | 38 ++++++++ 2 files changed, 130 insertions(+), 10 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c index 71b6e7ae7c727ee0ea12f74e60c27c4c46e05872..cec57be55e77096f9448f637ea129af2b42111ad 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c @@ -5,12 +5,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent @par Reference(s): - - ACPI 6.2 Specification - Errata A, September 2017 + - ACPI 6.3 Specification - January 2019 + - ARM Architecture Reference Manual ARMv8 (D.a) **/ #include #include #include "AcpiParser.h" +#include "AcpiView.h" +#include "PpttParser.h" // Local variables STATIC CONST UINT8* ProcessorTopologyStructureType; @@ -19,11 +22,80 @@ STATIC CONST UINT32* NumberOfPrivateResources; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; /** - An ACPI_PARSER array describing the ACPI PPTT Table. + This function validates the Cache Type Structure (Type 1) 'Number of sets' + 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 CONST ACPI_PARSER PpttParser[] = { - PARSE_ACPI_HEADER (&AcpiHdrInfo) -}; +STATIC +VOID +EFIAPI +ValidateCacheNumberOfSets ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + UINT32 NumberOfSets; + NumberOfSets = *(UINT32*)Ptr; + + if (NumberOfSets == 0) { + IncrementErrorCount (); + Print (L"\nERROR: Cache number of sets must be greater than 0"); + return; + } + +#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) + if (NumberOfSets > PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX) { + IncrementErrorCount (); + Print ( + L"\nERROR: When ARMv8.3-CCIDX is implemented the maximum cache number of " + L"sets must be less than or equal to %d", + PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX + ); + return; + } + + if (NumberOfSets > PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX) { + IncrementWarningCount (); + Print ( + L"\nWARNING: Without ARMv8.3-CCIDX, the maximum cache number of sets " + L"must be less than or equal to %d. Ignore this message if " + L"ARMv8.3-CCIDX is implemented", + PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX + ); + return; + } +#endif + +} + +/** + This function validates the Cache Type Structure (Type 1) 'Associativity' + 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 +ValidateCacheAssociativity ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + UINT8 Associativity; + Associativity = *(UINT8*)Ptr; + + if (Associativity == 0) { + IncrementErrorCount (); + Print (L"\nERROR: Cache associativity must be greater than 0"); + return; + } +} /** This function validates the Cache Type Structure (Type 1) Line size field. @@ -49,11 +121,14 @@ ValidateCacheLineSize ( UINT16 LineSize; LineSize = *(UINT16*)Ptr; - if ((LineSize < 16) || (LineSize > 2048)) { + if ((LineSize < PPTT_ARM_CACHE_LINE_SIZE_MIN) || + (LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX)) { IncrementErrorCount (); Print ( - L"\nERROR: The cache line size must be between 16 and 2048 bytes" - L" on ARM Platforms." + L"\nERROR: The cache line size must be between %d and %d bytes" + L" on ARM Platforms.", + PPTT_ARM_CACHE_LINE_SIZE_MIN, + PPTT_ARM_CACHE_LINE_SIZE_MAX ); return; } @@ -96,6 +171,13 @@ ValidateCacheAttributes ( } } +/** + An ACPI_PARSER array describing the ACPI PPTT Table. +**/ +STATIC CONST ACPI_PARSER PpttParser[] = { + PARSE_ACPI_HEADER (&AcpiHdrInfo) +}; + /** An ACPI_PARSER array describing the processor topology structure header. **/ @@ -133,8 +215,8 @@ STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = { {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, {L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, {L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, - {L"Number of sets", 4, 16, L"%d", NULL, NULL, NULL, NULL}, - {L"Associativity", 1, 20, L"%d", NULL, NULL, NULL, NULL}, + {L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL}, + {L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL}, {L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL}, {L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL} }; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.h new file mode 100644 index 0000000000000000000000000000000000000000..2a671203fb0035bbc407ff4bb0ca9960706fa588 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.h @@ -0,0 +1,38 @@ +/** @file + Header file for PPTT parser + + Copyright (c) 2019, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ARM Architecture Reference Manual ARMv8 (D.a) +**/ + +#ifndef PPTT_PARSER_H_ +#define PPTT_PARSER_H_ + +#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) + +/// Cache parameters allowed by the architecture with +/// ARMv8.3-CCIDX (Cache extended number of sets) +/// Derived from CCSIDR_EL1 when ID_AA64MMFR2_EL1.CCIDX==0001 +#define PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX (1 << 24) +#define PPTT_ARM_CCIDX_CACHE_ASSOCIATIVITY_MAX (1 << 21) + +/// Cache parameters allowed by the architecture without +/// ARMv8.3-CCIDX (Cache extended number of sets) +/// Derived from CCSIDR_EL1 when ID_AA64MMFR2_EL1.CCIDX==0000 +#define PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX (1 << 15) +#define PPTT_ARM_CACHE_ASSOCIATIVITY_MAX (1 << 10) + +/// Common cache parameters +/// Derived from CCSIDR_EL1 +/// The LineSize is represented by bits 2:0 +/// (Log2(Number of bytes in cache line)) - 4 is used to represent +/// the LineSize bits. +#define PPTT_ARM_CACHE_LINE_SIZE_MAX (1 << 11) +#define PPTT_ARM_CACHE_LINE_SIZE_MIN (1 << 4) + +#endif // if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) + +#endif // PPTT_PARSER_H_ -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'