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.46]) by mx.groups.io with SMTP id smtpd.web09.11470.1639055973825459337 for ; Thu, 09 Dec 2021 05:19:34 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=thuqf+ak; spf=pass (domain: arm.com, ip: 40.107.4.46, mailfrom: sami.mujawar@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=bovVQ1xTNCp1Kg6tXGjR4d00ARPdOJD9BwMYVac1D3E=; b=thuqf+ak3uXJZ04kWMI1pjDoTHWE/OaGXEIyAgTyKsE03gPLE53XVnk5ZQHY2S2+qnmsPjYP8O6A2dGg4Oth95F2F1gBwrBqwrR1IZgtUmzTIry2vuUi6Gt/ExYKZr3eSDQmm0dqi7IzIdhwFrxCjV4m2oH5t3AhdHmSGAtYUK4= Received: from AS9PR06CA0159.eurprd06.prod.outlook.com (2603:10a6:20b:45c::26) by DB7PR08MB3017.eurprd08.prod.outlook.com (2603:10a6:5:1f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16; Thu, 9 Dec 2021 13:19:30 +0000 Received: from VE1EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45c:cafe::2d) by AS9PR06CA0159.outlook.office365.com (2603:10a6:20b:45c::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.17 via Frontend Transport; Thu, 9 Dec 2021 13:19:30 +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 VE1EUR03FT050.mail.protection.outlook.com (10.152.19.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12 via Frontend Transport; Thu, 9 Dec 2021 13:19:29 +0000 Received: ("Tessian outbound f493ab4f1fb8:v110"); Thu, 09 Dec 2021 13:19:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7bb1e2351b6f3ecc X-CR-MTA-TID: 64aa7808 Received: from 3fba157729f5.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4580D78F-EC27-4C0B-A27C-5FAB305D6B71.1; Thu, 09 Dec 2021 13:19:21 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3fba157729f5.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 09 Dec 2021 13:19:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GCQbxeAyBX6xSYksPb0QG5umU7WWk3DcW1NQiH0an69yhEj4MG1RtazNaX1f8ePJAUrSzxVZaV608XdJdjGXQSBjI/XfDepZyfqayCq5ocaiOnUsc8cgD3bLHv3lXx2VkHPZkYlrdYNtQSCwPGucB/DtIFSTsuk0GNIVaut30cyd7/apGhCRnzRQlGV8XUqLaA21XRYYM9+aNtUGWbY9u19P9T+vwf+pKsL8XQgBJHSGtlV9I7l6FSmk2NNc9xboOV5ApFQtICGsSseAFdEM4sfJw4leHkdrLzQ0Q/ySGmKe37u+KRT31+aIbk6IS0Elmu6OMbtkQQIhurKuwl5A5w== 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=bovVQ1xTNCp1Kg6tXGjR4d00ARPdOJD9BwMYVac1D3E=; b=PuGiwEH18CcJtalVFUXnhAwNWQFLOI3LBsvy6tsYFeg7WKgbVtl3Ode9FAsgL1MvepUE6QaCy1WVK7G/TSPx5vfOCeonXKjBz7napx/qNi0IpcG33ofV6+KAQdBNT030kha/eMn9wWldCPuqQL6BUpNUuOAwsZlpUTrEUcNqXZJLUYxnfCO7Pd9R5vnX8xyoSnGlGKrVQn0B5g0P9XFIlHougUevNAZebWZS1PYNbfzpWFeOW7+XZtjQ6mw+YS+IV5Kj0r1T+2PcbiTEk6U/VHsjybECkpFvjlUADZALtsUQ/Jl6eijj0m1TJ7PbQ3sXCZE71jFKgxCBhvBGByEzfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; 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=bovVQ1xTNCp1Kg6tXGjR4d00ARPdOJD9BwMYVac1D3E=; b=thuqf+ak3uXJZ04kWMI1pjDoTHWE/OaGXEIyAgTyKsE03gPLE53XVnk5ZQHY2S2+qnmsPjYP8O6A2dGg4Oth95F2F1gBwrBqwrR1IZgtUmzTIry2vuUi6Gt/ExYKZr3eSDQmm0dqi7IzIdhwFrxCjV4m2oH5t3AhdHmSGAtYUK4= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by AM6PR08MB3717.eurprd08.prod.outlook.com (2603:10a6:20b:8e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.22; Thu, 9 Dec 2021 13:19:18 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::bdcf:cfa6:b2bb:38ac]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::bdcf:cfa6:b2bb:38ac%6]) with mapi id 15.20.4755.021; Thu, 9 Dec 2021 13:19:18 +0000 Subject: Re: [PATCH v3 7/7] DynamicTablesPkg: Add CacheId to PPTT generator To: Chris Jones , devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, ray.ni@intel.com, zhichao.gao@intel.com, Alexei.Fedorov@arm.com, nd@arm.com References: <20211208160630.10923-1-christopher.jones@arm.com> <20211208160630.10923-8-christopher.jones@arm.com> From: "Sami Mujawar" Message-ID: <0d19cc10-6b30-d48d-d407-0f5a12228b35@arm.com> Date: Thu, 9 Dec 2021 13:19:21 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 In-Reply-To: <20211208160630.10923-8-christopher.jones@arm.com> X-ClientProxiedBy: LO4P123CA0065.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::16) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 Received: from [10.1.196.43] (217.140.106.50) by LO4P123CA0065.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.17 via Frontend Transport; Thu, 9 Dec 2021 13:19:17 +0000 X-MS-Office365-Filtering-Correlation-Id: 23b11c6d-2215-4013-835c-08d9bb16882a X-MS-TrafficTypeDiagnostic: AM6PR08MB3717:EE_|VE1EUR03FT050:EE_|DB7PR08MB3017: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: zgAhIo83xdaK0MlCroFHPMlea0iXWsjK/FKkXy9p8p5q9mpk2VqMEsU4kws5aGRuUIaTegGNHVvNTGM/nADXpxkiYYoNddQ69a/ucs9TEEys0LrKeXM/DAj+U1JGKK/k8ZB6lLKYen8AGvqqZJDgWNY7QjY/6GggiC40er1fXdl9PmhSEakFTayEd2/9wbmPNjuh2v9YsZG5yYyDsLAvGHIeyaRzaYgjERshRpO28Pk+lknXn0EdW3hGgZRPjg/cmGpAFkayR5Sjb+D0zKjTV4r7+223mPOFtkmqb++udmb92DUBF9IZoj1B6O6F0pc/stqcxGcBRAc/hnNAkxz0Z4bNi39juHWVNLJMpuiebjHw11cgJc98uKR53MfCNP65JgJ6I0vJwD0sTF43KCWO9TACph3si1wIZPblrwg17akntMSN3FN5y8aWfOjngLjyBA1+CFBAxbPnukNjDkfiCby1H01x4QLebMG3fMMw+zgn7mBqLULUCAGWajHFT9yig34un2NQMn1h7mN8jB9EEm6u4mS7bbGQsI4QvS+/gZU67JL2a0dxCAil61eUSc1XiqyPQr4My0a2dMDuFbFASonFRMcCu/hQCcSBUKztCMSobV2cOMZuL0eH9wGnhp3DOWVKdVKI2383OUivLn5uqX2GXTg1DVKxjWkc1u4gNIu62fdooYwJ33g9xpPDnB5bHSHzjOyvaJmrYCZapmq9XmP0hagxsDutqpWEGyH8/qSVyffiPQKUcXW5y/VVww5qIqQxV3PEKLk9L6+BLUz2R5yIW8HI0JOru9Lli96oVQvPs9HbGk9X7naF4jTz1v1GoAGVh6bVZ5IYzQiGnihVww== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(86362001)(31686004)(52116002)(186003)(53546011)(44832011)(2616005)(66556008)(66946007)(83380400001)(8676002)(4326008)(26005)(956004)(6486002)(66476007)(38100700002)(36756003)(8936002)(38350700002)(316002)(2906002)(6666004)(5660300002)(31696002)(16576012)(508600001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3717 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 274407fc-76d7-472c-debc-08d9bb16811d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v1v8ue5h1LLKV38WATJHVUMcLDrWYho2iJI2d7boDaQxx0DGlhYIMgzdLuBVSavr2cUBrU8BVGJ0fHq5bethEzzRBQMmoMJ9DZc7J50UNEymnojyA1hn4RMDr5OMHZtTEgDRJtiWb3NBoux5TT+qZtcf+tXmh45rFR/UuBw1HODIiz9dQQaFpQnu0QCquaMX/i4rqyNxYJbs9aDrKEM6hy/fobM3QHht8TBwSkNWxHQX3CrNG/neUM2Js02Ma3EJKMspZKhrMnvqmoHTfxNLy3cbo5CT5k157fVmccKY8CoMUwbagosuYaKWIdCiWoWw0cxzQzxp6bXfUl5057ks7iPWM5Wy9Gwek5F020yZeJoSh/vZPoTIiMqWFNJehTc2mTXSRsoHavN9VVFLvOn7pWQEJxERrHteT3mIlmju/wcKZqxYA6OmzH6pCAaCJnpg+PnIZ5qA6gkzIVlQu209LNmfGyIqgpoOZ7Sv8R9VDyqbZVL7mnYR2y1Tks9NUi6Sg0tVZB3JIvhwEPTQ1Lrbm25ejCVhMq0Job3L+X41ATjBzQ5U8VvhmeBcugy9bbh88qw4W4/sEKSXJSMR1zGlBzD759lhDoPsaHpE54h8EvJrZy2N1m4zOsTiNovkvLQWjxLZHWnzF2cp4eko6c1S6WhdJuE1KRD5zapx7D2wXZb/vPhidwfVcP0NZKMnCOeswNKstuFcA7iZ1FG4egj/Wkm2sH1OHmR3C7uRi5lnNHKdouFzZbQNZ/6+F3sz0o8c+6vHYrMgbtmff9do6Yf/4kYtjQJSXDkjWkWIMKGavBRmI1XrCth7wbvSIr5dlT9XGCbO7GL/Rv/E7stbwCaN9dejNHwo2GLcs7pbDPsN7MyIUSZEfSxoeVCBeVHKXp7f 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)(40470700001)(6666004)(2906002)(70206006)(336012)(70586007)(36860700001)(16576012)(81166007)(508600001)(47076005)(6486002)(4326008)(44832011)(40460700001)(356005)(31686004)(26005)(186003)(8936002)(5660300002)(86362001)(8676002)(82310400004)(36756003)(53546011)(316002)(83380400001)(956004)(31696002)(2616005)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 13:19:29.6235 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23b11c6d-2215-4013-835c-08d9bb16882a 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: VE1EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3017 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Hi Chris, Thank you for this patch. Please see my feedback below inline marked [SAMI]. Regards, Sami Mujawar On 08/12/2021 04:06 PM, Chris Jones wrote: > 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; [SAMI] I think we could do slight optimisation by doing the following below: (a) change TotalNode Count to NodeIndex. > + UINT32 *FoundCacheIds; > > ASSERT ( > (Generator != NULL) && > @@ -770,6 +805,13 @@ AddCacheTypeStructures ( > > CacheNodeIterator = Generator->CacheStructIndexedList; > NodeCount = Generator->CacheStructCount; > + TotalNodeCount = NodeCount; > + > + FoundCacheIds = AllocateZeroPool (TotalNodeCount * sizeof (*FoundCacheIds)); [SAMI] (b) Change TotalNodeCount to NodeCount. > + if (FoundCacheIds == NULL) { > + DEBUG ((DEBUG_ERROR, "ERROR: PPTT: Failed to allocate resources.\n")); > + return EFI_OUT_OF_RESOURCES; > + } > > while (NodeCount-- != 0) { [SAMI] (c) Replace while loop to a for loop where NodeIndes = 0 to NodeCount. > 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 [SAMI] (d) Replace TotalNodeCount with NodeIndex in call above. By doing (a) to (d) and (e) below we can reduce the number of iterations in IsCacheIdUnique (). If you agree I will make the adjustments before pushing this patch series. [/SAMI] > + ); > + 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; [SAMI] (e) Replace NodeCount with NodeIndex above. > + > + 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 ((