From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (EUR03-DB5-obe.outbound.protection.outlook.com [40.107.4.71]) by mx.groups.io with SMTP id smtpd.web12.14998.1638979612617470754 for ; Wed, 08 Dec 2021 08:06:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=YhNnfcOr; spf=pass (domain: arm.com, ip: 40.107.4.71, mailfrom: christopher.jones@arm.com) 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=4hPF7qKlRB8hLkXvfl3aWKPCw+6r6IaCDKA4tfCg9jk=; b=YhNnfcOrJfpGIbnBEGQfHiImReaqzwuHeHLffS7awXmou2gmtQHcE51Pbzaph3MFJoO5m2ZGQCc66qHbT8gmw6OHuAMBF0bShhfJS3XCQOSAKssEPlNJih7FTxWbbSd4Dqs2jdHGb3x0wSQP0E6FIZQOuAuU9MXjoLGh5xWaFIM= Received: from DBBPR09CA0001.eurprd09.prod.outlook.com (2603:10a6:10:c0::13) by DB6PR0801MB1864.eurprd08.prod.outlook.com (2603:10a6:4:74::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11; Wed, 8 Dec 2021 16:06:49 +0000 Received: from DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::59) by DBBPR09CA0001.outlook.office365.com (2603:10a6:10:c0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Wed, 8 Dec 2021 16:06:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT050.mail.protection.outlook.com (10.152.21.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.13 via Frontend Transport; Wed, 8 Dec 2021 16:06:49 +0000 Received: ("Tessian outbound f493ab4f1fb8:v110"); Wed, 08 Dec 2021 16:06:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c2968633760a69df X-CR-MTA-TID: 64aa7808 Received: from 5e2e6c599e81.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6A97D5E8-964D-48C5-A7EE-1255296DF05D.1; Wed, 08 Dec 2021 16:06:43 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5e2e6c599e81.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Dec 2021 16:06:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jIKilIx2dO7IMDbzuwIPj6OggEPtbMuoFGVcsfjL3JqewM3eorJBf//pF2V7lZoaynVdw/063pWDNzDfHjNNqfzzkqwfUp3+QlLZkYi5ILntMFQQdnGQQoSjRRaNUSYElH04KGO+yfvvsnaiLaVmT02+B8xsYjV7O02kEOYAVBQqSvVXBcZzBk02PpUCba/ECKZGcISPqa30p5H1QJFxBacm22TqdSCXPAgAezjXnQj9vqgBtBiarww5vnClceHAHnOpV+u2YH1G+9cp8Kl517Bp/N4rTLSLMrk7toYuBDjdp+IbYWckz7xhvk46caOS8TNOXuIjDypd8p65aqhuPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4hPF7qKlRB8hLkXvfl3aWKPCw+6r6IaCDKA4tfCg9jk=; b=HapC8sWLfuU5CHCPjZ5gUUhKPTrrs3kI5I+R0L83x0zG75NgrO/hxODXCFKbj4R8HE3CIpgV7mKlbeUD3pJJMogdUm8xQWOgmwOJQSseDZGDQ8gZ+tpVPURt5QPKDNx+exFx435VbcgVy6f0hseoGPa7J46eZ1ngmCODOlOrqqQM8yRlFXylOPqYINNXsxG0sLfJ0/xRF3Zh4ytnkvEuZ11UmB3Esk9B7XPw2qxg16dDjYmTxArUTHbyq4Qz/qynScGlNYZZ1XDmhPQeDojVnNXUWTAiKkcmEjx92aoBHeyjSQsPNvTwcmyO3uc8Xf09jwApouCYYwt/vbtg81E39w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none 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=4hPF7qKlRB8hLkXvfl3aWKPCw+6r6IaCDKA4tfCg9jk=; b=YhNnfcOrJfpGIbnBEGQfHiImReaqzwuHeHLffS7awXmou2gmtQHcE51Pbzaph3MFJoO5m2ZGQCc66qHbT8gmw6OHuAMBF0bShhfJS3XCQOSAKssEPlNJih7FTxWbbSd4Dqs2jdHGb3x0wSQP0E6FIZQOuAuU9MXjoLGh5xWaFIM= Received: from AM7PR02CA0027.eurprd02.prod.outlook.com (2603:10a6:20b:100::37) by VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16; Wed, 8 Dec 2021 16:06:40 +0000 Received: from AM5EUR03FT003.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:100:cafe::9a) by AM7PR02CA0027.outlook.office365.com (2603:10a6:20b:100::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Wed, 8 Dec 2021 16:06:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT003.mail.protection.outlook.com (10.152.16.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4755.13 via Frontend Transport; Wed, 8 Dec 2021 16:06:40 +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.2308.20; Wed, 8 Dec 2021 16:06:37 +0000 Received: from e125153.arm.com (10.57.3.247) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Wed, 8 Dec 2021 16:06:36 +0000 From: "Chris Jones" To: CC: , , , , , , , Subject: [PATCH v3 7/7] DynamicTablesPkg: Add CacheId to PPTT generator Date: Wed, 8 Dec 2021 16:06:30 +0000 Message-ID: <20211208160630.10923-8-christopher.jones@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211208160630.10923-1-christopher.jones@arm.com> References: <20211208160630.10923-1-christopher.jones@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 3df39f4d-454e-4abe-9453-08d9ba64bde2 X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DB5EUR03FT050:EE_|DB6PR0801MB1864:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: dkDEOyRcCZGav8qZYhnTqDK7zYWzBA0rFe+ab6h6DDQfKD7HEf2+StM+wm/jk9ukKFmN0sl+EeOxDhQBlp3nlmeGgV4Ts1RK1sH4/p0xZu9JEKiJsJnmP2XaSF2SqcneaHgOVyQog6cmfSTfghCIhepAN7EJ1SoqpXtCZP7H1OoN81LIpUHwhXbYsARW2tUu/92ws996V5Z87kn1AWO4vfB+SXbk7k20GlI0elLAQbsABkfubYwrGqKri0J7gdx6QcDUjS52IAgFfjFxI2nunOvccZGdfq7EMBNKH65ZXh0UPU5imvGzeFn+c/6qmpsKc8McqRsH6Iv+BdVFlMNhr02Er+wqc3xXp+alyUVo/tURO5m8bNU9xDxBLs9mlgs0rqfWbhq/voTfkZY4sUk+1UgZ0TA1Q53elv7sJsMgsJO6cB5+STXImzhKglBphu72rLHle+bMkmgeLU/gmlTCbn5GP50WggRJsRAyySnXZF8CzkJ6r5eNEA5LAThx+IOtrs7N/rTwk/8hm/1DsIzodPv+Ii+wD5iWpmlQkweCl+61wqd0JlN8DqEpL7YHC3dX6Y3Hmh4rJ9R0Ox6Ofj8hF4foKepV8Et8IpOLLeyV8UhQpab1NVFfx7be6O3qevQKbnEn11A6gvdDd5r1KBmAHe8PojbCVHOcBfowhc9pcvMbMRbxYobC990TKXJF22oW9BrB9pzMX8RnpaZtk4dRz7ybW7I4NR1GG53pZHmvN7qTnpkdP5nIImTj3hnxZrRUpi3juL+UvFjWK81qgBeixW3x5F2GmpQ6VxqVYgvkEcRgDeBFuoyjhBESad1LQWRnBKFJIMFvptktKpZi0mxHOzu35ARu8p+Dxz8XS0r6dUYv/x9U22uPgW3Ra9hzJX76 X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(40470700001)(6666004)(81166007)(26005)(83380400001)(4326008)(426003)(186003)(5660300002)(8676002)(1076003)(36860700001)(2906002)(2616005)(70586007)(7696005)(54906003)(316002)(82310400004)(356005)(8936002)(40460700001)(336012)(6916009)(86362001)(70206006)(508600001)(47076005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4974 Return-Path: Christopher.Jones@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c43b575f-d0b0-439d-1f30-08d9ba64b871 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z37NWyLWw3igS/+lJG5zz7FJsL6/Zn5Ahvgp6s2cu+XSM3yqpwyeFC4XZPjIqlp1vbxY0EV9uD1MlKPHyw8SVVsOcD4jJg8QDRNKVyaOpHUrURN5N+7gaw6QgMAYHDJYOhb3ZP8maEj8L0PGcHYVH4AGbLhBSgEqY7xac7zEuWxRvJpr5//NO08NvoNWKk8w+t1viTeJhd0hPl5NCZAEGWje8SAGiq2PBN+oms1qnbnSX/+f+VRHwwK3M6MDHnAus+4euo+WHEJoaIckU+UzSLXkkyZfJ2l4XXLaQkwuG0RNpitVP68qLWS82qUAkxt6VZXYrCLeFkutMJzkS/iXqytztBsQ4+J1DHPh+2x5vuD0X9jktPFHk0JkQxkLO4T2C6oagUJE+5KaapstcNLJhYQPmVwOZJxsv+KO1hj+p1Q/vqeSUMH58FxyWSZ6AbJcUT9ZbWVkyn2NzIZj1CpQhEOh9zfqY+WJPwkhyry/tUurT1p7T1bT7RJsAA1dAfXijuqWDBu16lXAimdfYwZZGWOEeg/MF2Cs23dgISvLcnj7cacNsdYfC5V0nPHBXDXwtrqfKAYkSKPNYvXWZd6atmkJSfKzTpag9ZJeeRLlaW4Pt0b2OeAdij4LzXfzeeEd3lZyoFpFuaMy94BFymFKhxIhGNfJyHkGMs24afPJ5dMQYaHFe1RbA+PW+IUAKZVCE3MyH5BBvfzLfhQl0teTR2i2DQ6dNdKB78WeFD3JL4+xb1lsR6EaVNXBXTASUgzt+yeinUj01Q1k5MSN3TZp51u6/ZgLXP72kBHy8Wc3kuiZPUy1+KHi8xcCvlMMtMYJCJLZxP6kl/S0GNpEKousGpQSiHX+ZDIJDe6Mb2AMqtQ= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(40470700001)(508600001)(26005)(54906003)(7696005)(86362001)(83380400001)(36756003)(81166007)(316002)(186003)(1076003)(4326008)(70586007)(336012)(47076005)(8936002)(70206006)(36860700001)(426003)(8676002)(5660300002)(2616005)(2906002)(6916009)(82310400004)(40460700001)(6666004);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2021 16:06:49.4874 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3df39f4d-454e-4abe-9453-08d9ba64bde2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1864 Content-Type: text/plain Bugzilla: 3697 (https://bugzilla.tianocore.org/show_bug.cgi?id=3697) Update the PPTT generator with the CacheId field as defined in table 5.140 of the ACPI 6.4 specification. Also add validations to ensure that the cache id generated is unique. Signed-off-by: Chris Jones --- DynamicTablesPkg/Include/ArmNameSpaceObjects.h | 4 +- DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c | 102 ++++++++++++++++++-- 2 files changed, 96 insertions(+), 10 deletions(-) diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h index 3246e8884723ac85340bf880a3859800726be3c1..6ea03fca487b96577b8fd8105bc3d22047ff5697 100644 --- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h @@ -741,10 +741,12 @@ typedef struct CmArmCacheInfo { /// PPTT_ARM_CCIDX_CACHE_ASSOCIATIVITY_MAX. Therfore this field /// is 32-bit wide. UINT32 Associativity; - /// Cache attributes (ACPI 6.3 - January 2019, PPTT, Table 5-156) + /// Cache attributes (ACPI 6.4 - January 2021, PPTT, Table 5.140) UINT8 Attributes; /// Line size in bytes UINT16 LineSize; + /// Unique ID for the cache + UINT32 CacheId; } CM_ARM_CACHE_INFO; /** A structure that describes a reference to another Configuration Manager diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c index 3d416ca78ec16a1929ede87abbe4f8f4464ef0cf..6b74572ea2dd8478f14d013e6cb7394216e45d8d 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c @@ -726,6 +726,35 @@ AddProcHierarchyNodes ( return Status; } +/** + Test whether CacheId is unique among the CacheIdList. + + @param [in] CacheId Cache ID to check. + @param [in] CacheIdList List of already existing cache IDs. + @param [in] CacheIdListSize Size of CacheIdList. + + @retval TRUE CacheId does not exist in CacheIdList. + @retval FALSE CacheId already exists in CacheIdList. +**/ +STATIC +BOOLEAN +IsCacheIdUnique ( + IN CONST UINT32 CacheId, + IN CONST UINT32 *CacheIdList, + IN CONST UINT32 CacheIdListSize + ) +{ + UINT32 Index; + + for (Index = 0; Index < CacheIdListSize; Index++) { + if (CacheIdList[Index] == CacheId) { + return FALSE; + } + } + + return TRUE; +} + /** Update the Cache Type Structure (Type 1) information. @@ -738,10 +767,12 @@ AddProcHierarchyNodes ( @param [in] Pptt Pointer to PPTT table structure. @param [in] NodesStartOffset Offset from the start of PPTT table to the start of Cache Type Structures. + @param [in] Revision Revision of the PPTT table being requested. @retval EFI_SUCCESS Structures updated successfully. @retval EFI_INVALID_PARAMETER A parameter is invalid. @retval EFI_NOT_FOUND A required object was not found. + @retval EFI_OUT_OF_RESOURCES Out of resources. **/ STATIC EFI_STATUS @@ -749,7 +780,8 @@ AddCacheTypeStructures ( IN CONST ACPI_PPTT_GENERATOR *CONST Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST EFI_ACPI_6_4_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_HEADER *Pptt, - IN CONST UINT32 NodesStartOffset + IN CONST UINT32 NodesStartOffset, + IN CONST UINT32 Revision ) { EFI_STATUS Status; @@ -758,6 +790,9 @@ AddCacheTypeStructures ( CM_ARM_CACHE_INFO *CacheInfoNode; PPTT_NODE_INDEXER *CacheNodeIterator; UINT32 NodeCount; + BOOLEAN CacheIdUnique; + UINT32 TotalNodeCount; + UINT32 *FoundCacheIds; ASSERT ( (Generator != NULL) && @@ -770,6 +805,13 @@ AddCacheTypeStructures ( CacheNodeIterator = Generator->CacheStructIndexedList; NodeCount = Generator->CacheStructCount; + TotalNodeCount = NodeCount; + + FoundCacheIds = AllocateZeroPool (TotalNodeCount * sizeof (*FoundCacheIds)); + if (FoundCacheIds == NULL) { + DEBUG ((DEBUG_ERROR, "ERROR: PPTT: Failed to allocate resources.\n")); + return EFI_OUT_OF_RESOURCES; + } while (NodeCount-- != 0) { CacheInfoNode = (CM_ARM_CACHE_INFO *)CacheNodeIterator->Object; @@ -789,6 +831,7 @@ AddCacheTypeStructures ( CacheStruct->Flags.CacheTypeValid = 1; CacheStruct->Flags.WritePolicyValid = 1; CacheStruct->Flags.LineSizeValid = 1; + CacheStruct->Flags.CacheIdValid = 1; CacheStruct->Flags.Reserved = 0; // Populate the reference to the next level of cache @@ -811,7 +854,7 @@ AddCacheTypeStructures ( CacheInfoNode->Token, Status )); - return Status; + goto cleanup; } // Update Cache Structure with the offset for the next level of cache @@ -835,7 +878,7 @@ AddCacheTypeStructures ( CacheInfoNode->NumberOfSets, Status )); - return Status; + goto cleanup; } if (CacheInfoNode->NumberOfSets > PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX) { @@ -862,7 +905,7 @@ AddCacheTypeStructures ( CacheInfoNode->Associativity, Status )); - return Status; + goto cleanup; } // Validate the Associativity field based on the architecture specification @@ -881,7 +924,7 @@ AddCacheTypeStructures ( CacheInfoNode->Associativity, Status )); - return Status; + goto cleanup; } if (CacheInfoNode->Associativity > PPTT_ARM_CACHE_ASSOCIATIVITY_MAX) { @@ -923,7 +966,7 @@ AddCacheTypeStructures ( CacheInfoNode->LineSize, Status )); - return Status; + goto cleanup; } if ((CacheInfoNode->LineSize & (CacheInfoNode->LineSize - 1)) != 0) { @@ -935,18 +978,58 @@ AddCacheTypeStructures ( CacheInfoNode->LineSize, Status )); - return Status; + goto cleanup; } CacheStruct->LineSize = CacheInfoNode->LineSize; + if (Revision >= 3) { + // Validate and populate cache id + if (CacheInfoNode->CacheId == 0) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: PPTT: The cache id cannot be zero. Status = %r\n", + Status + )); + goto cleanup; + } + + CacheIdUnique = IsCacheIdUnique ( + CacheInfoNode->CacheId, + FoundCacheIds, + TotalNodeCount + ); + if (!CacheIdUnique) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: PPTT: The cache id is not unique. " \ + "CacheId = %d. Status = %r\n", + CacheInfoNode->CacheId, + Status + )); + goto cleanup; + } + + // Store the cache id so we can check future cache ids for uniqueness + FoundCacheIds[NodeCount] = CacheInfoNode->CacheId; + + CacheStruct->CacheId = CacheInfoNode->CacheId; + } + // Next Cache Type Structure CacheStruct = (EFI_ACPI_6_4_PPTT_STRUCTURE_CACHE *)((UINT8 *)CacheStruct + CacheStruct->Length); CacheNodeIterator++; } // Cache Type Structure - return EFI_SUCCESS; + Status = EFI_SUCCESS; + +cleanup: + FreePool (FoundCacheIds); + + return Status; } /** @@ -1205,7 +1288,8 @@ BuildPpttTable ( Generator, CfgMgrProtocol, Pptt, - CacheStructOffset + CacheStructOffset, + AcpiTableInfo->AcpiTableRevision ); if (EFI_ERROR (Status)) { DEBUG (( -- Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")