From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.89]) by mx.groups.io with SMTP id smtpd.web08.9432.1635954112014602655 for ; Wed, 03 Nov 2021 08:41:52 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=VMHN3JxG; spf=pass (domain: arm.com, ip: 40.107.7.89, 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=7mq61y6skqPqcfIvCsgwmeuKYCKCvWFGf/R/fN42h9M=; b=VMHN3JxGvz4a2ZtoYeZDBMApbqXGW4TmF6bVi1tOUqv3jp6BbrjTY8+5wPdjZp48jZsUcFMhK0DipOZIPzpUjhLRxVppVtfShPW71G57ERoOpT3BF+lpOdockPQrdhXBMvKITAjckrVzFGpgHArWarh1RRYWwsTX3yCEFowYTfo= Received: from AS8P250CA0030.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::35) by AM6PR08MB3253.eurprd08.prod.outlook.com (2603:10a6:209:49::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.18; Wed, 3 Nov 2021 15:41:47 +0000 Received: from AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:330:cafe::36) by AS8P250CA0030.outlook.office365.com (2603:10a6:20b:330::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 3 Nov 2021 15:41:47 +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 AM5EUR03FT014.mail.protection.outlook.com (10.152.16.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Wed, 3 Nov 2021 15:41:46 +0000 Received: ("Tessian outbound 2bb1f94ba47e:v108"); Wed, 03 Nov 2021 15:41:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 26e23fa5a3949cc8 X-CR-MTA-TID: 64aa7808 Received: from bb8f3a552368.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C0522BBC-92AE-4D3D-A6F4-C531206C69A2.1; Wed, 03 Nov 2021 15:41:40 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id bb8f3a552368.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 03 Nov 2021 15:41:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q4MUmt5tDZ3VMOYYg58ltHZq9kmFOPBBRgOyIs3X+VLrr/8kNtozmY3HvcdnwC5aFSmwpVMFdGRD8thRWT8OUPWJeH1rWKTenaEhRECjBRsQGVkfv+SosQ2Y4/jVBSsUYGD3WdBYG1Ljo0MTKjNQUemVglf+9fmGHm1YQy5IeNxDRgDBw4QjYr3HrnDvEtllHTtZhn2RvCHzlzVx70q6hLJVZim7ZDWN5Y1RW/y/bhw/khHO14j8AvMucjtuk3iNqgdlpkdA116pqAbUzi7//573vwba0UA0ZRyRLSRUHm8nE0r2mph+0yHvbsdNnf3qHA5AiGuW4lz+PPvzMV1g3w== 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=7mq61y6skqPqcfIvCsgwmeuKYCKCvWFGf/R/fN42h9M=; b=V+vQnorVxsrO/pW3sVaebO5tHAfKeEvNJFK0Sp4qNZlDMkaqwL5rziOnyITv0j3M4+Nl71ae+K/pqvGWXzb5X2mh0Mob4bOtDbvwKIh7O8xe1MdpBtInirCoO/yFrmSRGYyzHDj+00bB3oSpNrwAGtx47dMcwJxXi/g+Ua8QIT8my9a9EPaTI7EV2djWydoGXoEXipCrESpUCf76PbBagvQBbiQyt0q9XbfCRecg+PHvmopFwdjCQ2VZBIM39ec/X9OtJBp90VOTMYf7kt6EnMWDM5/vuWInjM0lvaqoibzTS8vzASkL2eOGb/ycTv3scmMzG2GmDYofNa0wPM6wxQ== 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=7mq61y6skqPqcfIvCsgwmeuKYCKCvWFGf/R/fN42h9M=; b=VMHN3JxGvz4a2ZtoYeZDBMApbqXGW4TmF6bVi1tOUqv3jp6BbrjTY8+5wPdjZp48jZsUcFMhK0DipOZIPzpUjhLRxVppVtfShPW71G57ERoOpT3BF+lpOdockPQrdhXBMvKITAjckrVzFGpgHArWarh1RRYWwsTX3yCEFowYTfo= Received: from AM6P193CA0060.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::37) by VI1PR0802MB2334.eurprd08.prod.outlook.com (2603:10a6:800:9d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.18; Wed, 3 Nov 2021 15:41:36 +0000 Received: from AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8e:cafe::b8) by AM6P193CA0060.outlook.office365.com (2603:10a6:209:8e::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 3 Nov 2021 15:41:36 +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 AM5EUR03FT029.mail.protection.outlook.com (10.152.16.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4649.14 via Frontend Transport; Wed, 3 Nov 2021 15:41:35 +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.14; Wed, 3 Nov 2021 15:41:18 +0000 Received: from e125153.arm.com (10.57.26.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.14 via Frontend Transport; Wed, 3 Nov 2021 15:41:18 +0000 From: "Chris Jones" To: CC: , , , , , , , Subject: [PATCH v2 7/7] DynamicTablesPkg: Add CacheId to PPTT generator Date: Wed, 3 Nov 2021 15:41:08 +0000 Message-ID: <20211103154108.6534-8-christopher.jones@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211103154108.6534-1-christopher.jones@arm.com> References: <20211103154108.6534-1-christopher.jones@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d9ed7c20-0ee8-427f-bb79-08d99ee071d7 X-MS-TrafficTypeDiagnostic: VI1PR0802MB2334:|AM6PR08MB3253: 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: JpEtZ5/fd6q3ktLTAL3W+QZx6L9yYQiOeh4Ohh6m+gW2hExrvvhO+qB92gh7SACk/88kTpkqpeD7Dkb+AaLrFviw2HmYZZL1ZylcpMSuzvxhTf3l+K2Zu3BqLk+719yCbkzLzxqGv7C+nsh7DDpqiwAKug9aIrp0vcQDTr0zqXkfdyX1BGJJASv8jlc7iaAui0tj2qlXE/EXUO2xXPYNts7p+ApPOcSVNl0cU127r/H2Fg+u8ll4H6gdGJ7xv4jt2KBGV1YvOw4dlpV0MFKlCqibrKZdAWaQaYt1iJuXFS16XDLXTF2J7MIBfLKOo4egTyZyed+0QucQ0+436HF+WjOsfRje2vE9gwLYo81Psad3tjSnx4hfSBNKbdB0rcFXX5zz5aJ01+YyHZH/1KmVB2LxRnrnUN0cenp4LJRX4SkXYvHrXygHkq9d3WTckqbbXnohD8WXHWAyYRo6pztZpwwNLfeaYQPZAYB3TCI3Ztq4pLOcb6yrQWMLLY6IMAwRQQp0/eKye0K2hrR2ZZL7BHrTnPhVbwUny0+R4pQb6nY6D8dTWtholMk+bAC3/kD8v3V30oL4r3zEt9rhAG11MeYun0xr+YMzsGCJmIKZg3U2AkaTqRdYntV8cz4fNeNRh8VFMe8f5vp2llt94XF2ZMNQRnsJbhHzUVR3wDsI7kzWnHequBu21TOFgj1+j2RM3lpAOCeVEIbAFewAD04eyQH9B3AMntSgp3A91zrF0SPYdQ1KwoA+u96a59+BkCUkbftlnyWGUFhXJ/E8k4bnJWTW5TxIyynh1GDpn/6xu3IkFsN7JD3Wy5B0QaEAKsHk 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)(46966006)(36840700001)(426003)(336012)(186003)(2616005)(508600001)(36860700001)(26005)(82310400003)(2906002)(70586007)(70206006)(54906003)(8676002)(316002)(6666004)(7696005)(6916009)(8936002)(83380400001)(81166007)(47076005)(4326008)(356005)(86362001)(5660300002)(36756003)(1076003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2334 Return-Path: Christopher.Jones@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 99730a53-1350-43e8-e5e9-08d99ee06b4e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MoMLrdDF/z67fxLoNJDyQwLNgB8FBJVDaQj6l7QD8AvRE4Mk5La1tfa2SvBZwJRh+pjCssY3unyZ5BA/+jEOR6pTpaq+U4cYi+aL94ex2yYRk3aUexZEgg8BWEaaitMRz8TbO5x7hlB5O40LUIJb7w5rRZ7aNwS3267FuepaUFO25f6G4ONo/HakzqnnPgUJiPjQWEaUCYjiXFhXigcC7NMEa+dX/0ALW4YRhHuX1iXjciLtRBWfGLKjjSwzsWh53S//sXUkK8oyGnhjgehB2lupjLNJw6NUtkDxuuSErQPsfin03L3ds1qAxJTVy49FPwg4p+kR1+yuvx7JDa0nVffeUQVfPzFamUT+2YbAdQ40iLBJnFuvciJFfNsMXIhcc1B1NE/WkjcVH7nOmxLjQz23f5UEW7oVz6y/PZMra1hH2FBah3XzUDMvrP8VHMCZ9NyUnmFLGekSg+BHeog1+E4gdNQMjyAKpSSrpu/qzzt5g1C2+siHl5TsI8cUXKAwIXcSVVDKXsi9TcoZiwHDqqmkIjtLoFSxPO72iwPNyYdXe9C9vf7G7GxZhjy4WA3AvkLziy0rDwUwIcRI3+q/KKJqf4Fejp0YD7bbzIpAMiBgoezO0dTBMRGuSa0d6lK3ZloO+sGwMh21sC8IG5zyC0baGeNyCwNk417HxlgyGucJ0QgoO7QxPIr8elGagO0VJXt9vbMbCzYYn7D70BCslvVsKwqkOZQCAAVHleAYxxgOcyjCJ7fg5EDBMo1jCa6x4ebreGmVKYmKNwlynqlYYOTJo87QYiNu9ssbA2TIm00= 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)(36840700001)(46966006)(5660300002)(8936002)(83380400001)(7696005)(508600001)(4326008)(6916009)(54906003)(86362001)(70206006)(82310400003)(70586007)(36756003)(8676002)(6666004)(47076005)(2616005)(316002)(336012)(81166007)(36860700001)(426003)(2906002)(1076003)(26005)(186003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2021 15:41:46.8752 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d9ed7c20-0ee8-427f-bb79-08d99ee071d7 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: AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3253 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 --- Notes: v2: - Make IsCacheIdUnique() return BOOLEAN instead of EFI_STATUS. - Added a missing space to the definition of 'IsCacheIdUnique'. 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 6bc5ab6b2b28424c1afddc26cc89a54b81941aeb..6e27158d720947efb22a350a7e5ffcfdd3005361 100644 --- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h @@ -740,10 +740,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 18f093998db57ea4698953ed06a9826df559c1b7..b74ab0b157b89aed576d6d100fadbf28182f80fa 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c @@ -722,6 +722,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. @@ -734,10 +763,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 @@ -745,7 +776,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; @@ -754,6 +786,9 @@ AddCacheTypeStructures ( CM_ARM_CACHE_INFO * CacheInfoNode; PPTT_NODE_INDEXER * CacheNodeIterator; UINT32 NodeCount; + BOOLEAN CacheIdUnique; + UINT32 TotalNodeCount; + UINT32 * FoundCacheIds; ASSERT ( (Generator != NULL) && @@ -766,6 +801,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; @@ -785,6 +827,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 @@ -807,7 +850,7 @@ AddCacheTypeStructures ( CacheInfoNode->Token, Status )); - return Status; + goto cleanup; } // Update Cache Structure with the offset for the next level of cache @@ -831,7 +874,7 @@ AddCacheTypeStructures ( CacheInfoNode->NumberOfSets, Status )); - return Status; + goto cleanup; } if (CacheInfoNode->NumberOfSets > PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX) { @@ -858,7 +901,7 @@ AddCacheTypeStructures ( CacheInfoNode->Associativity, Status )); - return Status; + goto cleanup; } // Validate the Associativity field based on the architecture specification @@ -877,7 +920,7 @@ AddCacheTypeStructures ( CacheInfoNode->Associativity, Status )); - return Status; + goto cleanup; } if (CacheInfoNode->Associativity > PPTT_ARM_CACHE_ASSOCIATIVITY_MAX) { @@ -918,7 +961,7 @@ AddCacheTypeStructures ( CacheInfoNode->LineSize, Status )); - return Status; + goto cleanup; } if ((CacheInfoNode->LineSize & (CacheInfoNode->LineSize - 1)) != 0) { @@ -930,18 +973,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; } /** @@ -1200,7 +1283,8 @@ BuildPpttTable ( Generator, CfgMgrProtocol, Pptt, - CacheStructOffset + CacheStructOffset, + AcpiTableInfo->AcpiTableRevision ); if (EFI_ERROR (Status)) { DEBUG (( -- Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")