From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.50]) by mx.groups.io with SMTP id smtpd.web11.37700.1634569882636246996 for ; Mon, 18 Oct 2021 08:11:23 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=xMmbypi+; spf=pass (domain: arm.com, ip: 40.107.22.50, 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=IuiUvsGxTYI7igq/sEFjsLwzV5vcEsg93ggJYevqiAo=; b=xMmbypi+ScUMhO2UovSXyyAF/PN5XitrwZSCDGMbVryb+b/a8uXMp2SUAzrByeB4AD87DnL3hUW3lVth87acz24MpahtCK3TjtVz6WgWsokAgKsmiZ1C4TH/ASwzxM0HchdLU8BHPdlblZ5GBiFLCOPp/xwBIkRSp8ns0KT2EfI= Received: from AM5PR0701CA0054.eurprd07.prod.outlook.com (2603:10a6:203:2::16) by DB6PR0801MB1656.eurprd08.prod.outlook.com (2603:10a6:4:39::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Mon, 18 Oct 2021 15:11:18 +0000 Received: from AM5EUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:2:cafe::6b) by AM5PR0701CA0054.outlook.office365.com (2603:10a6:203:2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.9 via Frontend Transport; Mon, 18 Oct 2021 15:11:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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 AM5EUR03FT010.mail.protection.outlook.com (10.152.16.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Mon, 18 Oct 2021 15:11:17 +0000 Received: ("Tessian outbound e27daf245730:v103"); Mon, 18 Oct 2021 15:11:17 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b7edc2078446f6c9 X-CR-MTA-TID: 64aa7808 Received: from 2b66d16932d1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id ED74DE8E-EFCA-424B-9479-B46F53F92952.1; Mon, 18 Oct 2021 15:11:11 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2b66d16932d1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Oct 2021 15:11:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kg9KIA7v0AJzswWVq+GwSStHcdzwgbqmM+notShF2q5oZjvV77JlELCkJ8f4DsY0Nsn5OgVghA9apxuWRL0y9X+8NY54Sp71Nn1j/DF3Y+EOLFItzcFMDw+LSvwpSp+kpbNT+oVmnVnqXaXRxteQ5z+hkLmWqUnovYj0S/gMoTc29qeB9ReR2hGFt6r8dOwXLBpad7ldqm+EVp+aeGG+O1jNarLDO0Mne51hpnGt1TE6ZTfEe7Sl+Apsne9Nb/SBPaDFWcKa7tv+NB2FaxHrdDgbEuft2mY8JGe2qf0zceNG7I5/MVDmneSy+QLGqUReMD7Te+6xATS6ZcR/NN0qkQ== 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=IuiUvsGxTYI7igq/sEFjsLwzV5vcEsg93ggJYevqiAo=; b=VCwwN350razp2P9tP4pmEDfKTjnYxNu5qD4Z99H77p2aBMdIHAEL+5N8xcspxEwLvbrNei0HRBxVG2FkOJlDxZR2kJVd6ecJt4IxO98wPBA7Z86JlVHSYkB96EXVTMn9ymKrmGKqohtta04hGwxpUGVCPELWdX+Y+r+M3UAELU9RDnbFHrubGnLY9yJlglRxvGTFLQL2TGly9cLAns64cZ8IwLf7z9Qi74+YTGmpUoSWvKdX562H9jvtKiXOsX+8/A1f0RJryJGZe3rDx1YjrUG3Mi+7ou3pP6aUP3W+N9emlOUlGzXSAXKlv4Y6QIrJZ2J/zB5OMfy25X9b+YBrAg== 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=IuiUvsGxTYI7igq/sEFjsLwzV5vcEsg93ggJYevqiAo=; b=xMmbypi+ScUMhO2UovSXyyAF/PN5XitrwZSCDGMbVryb+b/a8uXMp2SUAzrByeB4AD87DnL3hUW3lVth87acz24MpahtCK3TjtVz6WgWsokAgKsmiZ1C4TH/ASwzxM0HchdLU8BHPdlblZ5GBiFLCOPp/xwBIkRSp8ns0KT2EfI= Received: from AS8P251CA0021.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::18) by HE1PR0802MB2459.eurprd08.prod.outlook.com (2603:10a6:3:e1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.18; Mon, 18 Oct 2021 15:11:06 +0000 Received: from AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::11) by AS8P251CA0021.outlook.office365.com (2603:10a6:20b:2f2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16 via Frontend Transport; Mon, 18 Oct 2021 15:11:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (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=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 AM5EUR03FT042.mail.protection.outlook.com (10.152.17.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Mon, 18 Oct 2021 15:11:05 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.14; Mon, 18 Oct 2021 15:10:52 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Mon, 18 Oct 2021 15:10:51 +0000 Received: from e125153.arm.com (10.57.27.61) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.14 via Frontend Transport; Mon, 18 Oct 2021 15:10:51 +0000 From: "Chris Jones" To: CC: , , , , , , , Subject: [PATCH v1 7/7] DynamicTablesPkg: Add CacheId to PPTT generator Date: Mon, 18 Oct 2021 16:10:46 +0100 Message-ID: <20211018151046.31232-8-christopher.jones@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211018151046.31232-1-christopher.jones@arm.com> References: <20211018151046.31232-1-christopher.jones@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70ebd46b-c4aa-40dd-3669-08d99249890c X-MS-TrafficTypeDiagnostic: HE1PR0802MB2459:|DB6PR0801MB1656: 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: MoZakWjJFezaUzEd2ZVHFQA2mxEIfT0RsSQOkPzSdJb0+Vhb6fbz619Jte8Gl2BQLajwzmDj7RUm56d50pIgIE5fXjOaSou/+XzeBqy0uU3FbVP76HQ6SGrRv5u9zsy4lL4pT1y4i2qJqHao42PIYqo0+Qatmozf/gSUueWqQhqaio62dqWhgCTuxC/ZVR+z0cB5IQwiHl0c1lsDzz4ak8T1gZq41sTnVpzUYc17qkbBhN/caR5noc76U8Ve1bAFdtY07rSWlKqvSkDar3Bqx7YzA1H1TBU2U7DlSPHBhKo1D8prBJFaVsAas8X9nK4pmhdK7GbFOrPaB2dxxQ//a0oYimKlrwaIhw4JhNppMKZazwMF7AFifIKqpITEalfTs6qEMI8enE+DKdcfWC3kUyJcGmGHWPnbODFDlWU4KoM0so9Wkap7o9RxGlQVCPRo8Am6lbwfulUexmDM3ycXZRoDVNpCpce2K0qTKd84qQCEFP+H1S8xUIPDwLBskbvRMFyE33emu1mOR7FiQGM/uwmkjUWL7p44rsBFiaA1Gxm2lAlur/CCkM5GOdq+aVcZ0sgGqepBE+c9Ui65xCltIp09004BEjda7Dmk9dgMuWWCvxthet/MqtFQVGNXoo5+uVNTjfcqRo0KrCiG2SN0DTT62pbrSvFJ5cQBZn3/z9yhAx1xNVhWdvmRjbMjFWVuLkEwEg02wVSkz+8QC2j43X/juO88Kss7yYS0GSstUePoLOiYmVt1279f7uO0K4H/R6XrWamhZiFzNPG90V7P/pjAGEAyWYowKgd3jXHxydKiiHZtLuniB+/xLojPyhZE 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)(2906002)(8676002)(336012)(36860700001)(2616005)(4326008)(6666004)(81166007)(1076003)(426003)(6916009)(316002)(8936002)(36756003)(83380400001)(47076005)(86362001)(5660300002)(26005)(7696005)(70206006)(356005)(70586007)(82310400003)(186003)(54906003)(508600001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2459 Return-Path: Christopher.Jones@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: d1668c2d-aaf2-44eb-0a64-08d9924981bb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sCieqa3oLTxddS+bWZUZr/+o5nlT2WBO4rgaWmlPFXcA1opgACvI4cF0WYdTe/t4j32+LSEokeOnMldAtYHrIieMEBU0j0x5brBrWkkrT2C5lMfEYfLdupbYdJRTHpF1nhqUN0dcO83y6hlltzw/zPvv5DwENwLswBonrbxveoFS6uEBqwD6MY+GGX6DudLYFkK7iDZ/hZhk5BqCndbQpYE1qwuYP05kab8Kt2VmwUm4HTSqBPV7Es2GNiYD2+/9qO6SJl9hbvXSvWhERg+W2yLz+aboigpupvHf3wr1Z+1ZNnW/dLmm6u1G0CJc9iqBXESpqo+MU+Lt1RJFfYG5giOfASh18PcLFET2kHMUe206LvRTRQyEpPRwZ5XZ1AScZE633PoXV+zYY6rASxZWeWA6rYd8WUdQZl9AjLTySRU4SSky9p2s+XAlXxlAu8VmV1xs0SJujfRtkJTOS/lciFT1VNIFipPIZ53QeTaZFHEOio6HMLbKQ4StSsXubERaY0zaXvxWqTBn3hN4b8wnLfT59ZZRtEU0qE573aHKiH/5vZcRZrn6wj+G8jcKlTRd9VwTth6RP+3EUMD1D/yLHqT532oSPvFS0CwOmYc0tUvYyLg7WE2ftTAekTRDSFC2VLtgpW0FyQLoBuPQzHfnndUNLbSK8JafW0T2hY164wcMTq3oo5ETY89GOy/wCFpj0WTVBy0ON3lIvMTq1YOYINytdGLVEsFCuvvnspD+QkNXbF+EgQZBt3DMJgUrUJ0MF4H6LW3ZOkdFEPj97vXFosd8AaQ1ivxTHpWD/OQ+mjI= 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)(336012)(70586007)(2616005)(36756003)(426003)(1076003)(86362001)(186003)(6916009)(81166007)(8936002)(47076005)(36860700001)(26005)(8676002)(4326008)(70206006)(7696005)(2906002)(5660300002)(316002)(82310400003)(83380400001)(508600001)(54906003)(6666004);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2021 15:11:17.8602 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70ebd46b-c4aa-40dd-3669-08d99249890c 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: AM5EUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1656 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 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..0c22de11c584cfebfcc1600d86290c758a99140a 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 +EFI_STATUS +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")