From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail03.groups.io (mail03.groups.io [45.79.227.220]) by spool.mail.gandi.net (Postfix) with ESMTPS id 47C559418BA for ; Fri, 12 Apr 2024 14:33:58 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=abme4kh/F3HR1j3q0tEjTT5qyTZE0+Hc/qU+UuNIOOc=; c=relaxed/simple; d=groups.io; h=Received-SPF:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:NoDisclaimer:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1712932436; v=1; b=HiDTm/410Vc6kQy+uF48YJp6Z2IYDtdW/G5/KzeV2wg6ZbwhecjYjp8cqLagVWVZ0IAy/ouP qX/TeQ4AghMPlXP6/Zo+WefIHYcMG61UxJfNBVh1lmtpnDEQFeNsbKtS4iFlZXvYQDYMAyfPkFJ mqtOmPEpv73vq5eMC/5yU2UyWC+Y+5xWt2ozTiRfxeySSjj5gxLrwSj399AfdUPL2LgdjRwJmy+ h9ci2zhvDnXBzJMWoCkLRYIwCENevpMbZ6dUU5WMuw2wjTBmMr+0Cm3e3zoZ9WfcNA/hTnF7uq+ K9rCK05FNicHiGKC5A2yBLdubTYeD5dYPkZGaFjLHY7sg== X-Received: by 127.0.0.2 with SMTP id 3KE6YY7687511xWQm8L4vVi2; Fri, 12 Apr 2024 07:33:56 -0700 X-Received: from EUR03-DBA-obe.outbound.protection.outlook.com (EUR03-DBA-obe.outbound.protection.outlook.com [40.107.104.64]) by mx.groups.io with SMTP id smtpd.web10.48538.1712932432317443836 for ; Fri, 12 Apr 2024 07:33:52 -0700 X-Received: from AM0PR02CA0130.eurprd02.prod.outlook.com (2603:10a6:20b:28c::27) by DB9PR08MB6473.eurprd08.prod.outlook.com (2603:10a6:10:257::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Fri, 12 Apr 2024 14:33:42 +0000 X-Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:28c:cafe::93) by AM0PR02CA0130.outlook.office365.com (2603:10a6:20b:28c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 14:33:42 +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; pr=C X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS0EPF000001A8.mail.protection.outlook.com (10.167.16.148) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 14:33:42 +0000 X-Received: ("Tessian outbound caed45120527:v313"); Fri, 12 Apr 2024 14:33:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 360d6d6e4611418d X-CR-MTA-TID: 64aa7808 X-Received: from 666251870e33.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 47B2B361-C17A-4E79-B9C9-C5BCB1C88B88.1; Fri, 12 Apr 2024 14:33:35 +0000 X-Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 666251870e33.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Apr 2024 14:33:35 +0000 X-Received: from DB7PR03CA0082.eurprd03.prod.outlook.com (2603:10a6:10:72::23) by PA6PR08MB10858.eurprd08.prod.outlook.com (2603:10a6:102:3d8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.54; Fri, 12 Apr 2024 14:33:33 +0000 X-Received: from DU2PEPF00028D02.eurprd03.prod.outlook.com (2603:10a6:10:72:cafe::e0) by DB7PR03CA0082.outlook.office365.com (2603:10a6:10:72::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 14:33:32 +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; pr=C X-Received: from nebula.arm.com (40.67.248.234) by DU2PEPF00028D02.mail.protection.outlook.com (10.167.242.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 14:33:32 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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.2507.35; Fri, 12 Apr 2024 14:33:31 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Apr 2024 14:33:31 +0000 X-Received: from E114225.Arm.com (10.1.196.56) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 12 Apr 2024 14:33:30 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [edk2-devel] [PATCH v2 12/45] ArmVirtPkg: Add library for Arm CCA helper functions Date: Fri, 12 Apr 2024 15:32:49 +0100 Message-ID: <20240412143322.5244-13-sami.mujawar@arm.com> In-Reply-To: <20240412143322.5244-1-sami.mujawar@arm.com> References: <20240412143322.5244-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DU2PEPF00028D02:EE_|PA6PR08MB10858:EE_|AMS0EPF000001A8:EE_|DB9PR08MB6473:EE_ X-MS-Office365-Filtering-Correlation-Id: a7a02823-e2b5-4c9d-402e-08dc5afd8d57 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: PC5nyx2q6yOjh3ad7MXVPjSZKww1vUYG1SiI7kWTZJXPwFgb/0XhZzwEXl1XjuIwPzh7xDrQw+lz9ZeB1Nm9gbPlIha6rzc61YYrqDub8fCMRnSD3ovxtUZcp9bE/yqA+QJCHjDf2eGLzodYcMvhXcePX+yAIjHE+87CKKQzbiBK8wO3pNuHLGFSbCuE2CQYGC0bRZo8ywdsIykO0n8Ly4MhxxH6PrQeJa461mxrVZ4VQk6pkTrd7XZTLRXKGaPDfnzG5CAX3L2S61pHXyyIV9F54QI47UbRCmoGrHIgpbkxUyFntREF1TfA7i29+ScvlN/NtjkoOejrLYm4PJ2GAOOJMsFSy8+gYglyL6YeNHjKwpyMVnwxi61FsjSm6ZLfeU0JoIyqZtfVFZhZVepq7S5YuwWkcoLdSdyl2CFmxKa4Q3RT7ZBHfiFwGwIDXxI/tGXhsrBJAMcliHqZJs2hmkPqeMl6MGaf5wqHhTPSnSoSWmymwTfNv/rxkN4qQQTDPD7iq8ljNTdfhaWZ+envXFwH+IJPzGihhVmrZSBXFPLAmwh5xnmstOWkFVbzU2m+6r5FEHE1KX+LBCIthiLE79Jrzt2ZkEiLNnh/zjbccb/hvo8QhV35smgm+rvzaK0xbHUwGUaG6acF1mys7BTp1YJqJblBq9+mivgXvmDnWL6CTF0Msgre21MC3sSHiF9zrjBfczXmLcAvKD05rHoUGwXV4soDiGaSKqVC/XF9I9gZ7wJD563Hy1F3zJA5Tcs8 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:(13230031)(1800799015)(36860700004)(376005)(82310400014);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA6PR08MB10858 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0e44958d-7201-4cf4-d83c-08dc5afd87b1 X-Microsoft-Antispam-Message-Info: OEu4xlD1RvShYWiHCCXHn7EXxYsYMzMcME139QFNU0q2JPlEGqvBsu8/pSSn9iQAT7Y+BWwimoNwYH3BK/dDKAlysK7WRmf6yBRvpNohnf9xuDQtEL5iS48/8BSEpj98xkYHCN+vS0UHw752uXmwPB8BdcugMkjeQBMOumypbC/hq0a1qM+Eo41X5804Ob+S81Al+kKBV0czFJrorw/cCLQtydn/CsJBRh4ZOdQALGugwkwze2cHXnOB3rQxRstDKQI+Qpie94OmlSUcnwSS+mWi8l8qnrq/gAXXKgI7x12JFBnYu8UNOfVN45J6t5C7VsTm2bDrwffYQuBGm58AGIqsiYZM/uK4fVB4IxpzIrbiHnNZZx1HpksY+lv10LRepNTmb+sz90AvHvPX3l0WTsyeyE3WW/3I4kRh3fCl3V3w5f6Pa0vG68vUN06A9Y5f/1f+YHUUkziWrY5bFf+DTlP+vm31jSo3lRjucqOmyZ08pUO3XDMzw2VE/F1uinEFj3LWpreUNRimGy7yomQ7rStKJhHLa/qd4bN6yi+4DNvcjEZDf/k4JDT7gFWuXz1CF8MHWz/jELl1L4xnecH7ti2P8kHNthrWLqvIKDUP1taLEsJq64VkCwRKjbKo725eH7Ar+LfgL91MPUPdbEmyqxh1TVK2YgRc6WwpdTivGZzGoXZARbCUOgb43pGorIxf3t3Ji5BB6F95aICIRZDP0XYLgzGD14WEfLY3RulI7g5LeMfRJT6cgEY16lbMWrhE X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 14:33:42.3674 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7a02823-e2b5-4c9d-402e-08dc5afd8d57 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: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6473 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 12 Apr 2024 07:33:52 -0700 Resent-From: sami.mujawar@arm.com Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: fVPYXlmzKBpKqHParRZoOFOAx7686176AA= Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="HiDTm/41"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.227.220 as permitted sender) smtp.mailfrom=bounce@groups.io Introduce ArmCcaLib library that implements helper functions to: - probe if the code is executing in a Realm context - configure the protection attribute in page tables for the memory regions shared with the host - get the IPA width of the Realm which was stored in the GUID HOB gArmCcaIpaWidthGuid. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Gerd Hoffmann Signed-off-by: Sami Mujawar --- ArmVirtPkg/ArmVirtPkg.dec | 1 + ArmVirtPkg/Include/Library/ArmCcaLib.h | 114 +++++++++++++ ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c | 174 ++++++++++++++++++++ ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.inf | 34 ++++ 4 files changed, 323 insertions(+) diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index 23179c89704db789ab649de81873924c3958ab2a..d521e107ddff15e6dc585e3a63567e3ad817189f 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -27,6 +27,7 @@ [Includes.common] [LibraryClasses] ArmCcaInitPeiLib|Include/Library/ArmCcaInitPeiLib.h + ArmCcaLib|Include/Library/ArmCcaLib.h ArmCcaRsiLib|Include/Library/ArmCcaRsiLib.h ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h diff --git a/ArmVirtPkg/Include/Library/ArmCcaLib.h b/ArmVirtPkg/Include/Library/ArmCcaLib.h new file mode 100644 index 0000000000000000000000000000000000000000..a47e14b507f1bfd1feece636063eb2ba83357a5b --- /dev/null +++ b/ArmVirtPkg/Include/Library/ArmCcaLib.h @@ -0,0 +1,114 @@ +/** @file + Library that implements the Arm CCA helper functions. + + Copyright (c) 2022 - 2023, Arm Ltd. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + - Rsi or RSI - Realm Service Interface + - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state +**/ + +#ifndef ARM_CCA_LIB_ +#define ARM_CCA_LIB_ + +#include +#include + +/** + Check if running in a Realm. + + @retval TRUE The execution is within the context of a Realm. + @retval FALSE The execution is not within the context of a Realm. +**/ +BOOLEAN +EFIAPI +IsRealm ( + VOID + ); + +/** + Configure the protection attribute for the page tables + describing the memory region. + + The IPA space of a Realm is divided into two halves: + - Protected IPA space and + - Unprotected IPA space. + + Software in a Realm should treat the most significant bit of an + IPA as a protection attribute. + + A Protected IPA is an address in the lower half of a Realms IPA + space. The most significant bit of a Protected IPA is 0. + + An Unprotected IPA is an address in the upper half of a Realms + IPA space. The most significant bit of an Unprotected IPA is 1. + + Note: + - Configuring the memory region as Unprotected IPA enables the + Realm to share the memory region with the Host. + - This function updates the page table entries to reflect the + protection attribute. + - A separate call to transition the memory range using the Realm + Service Interface (RSI) RSI_IPA_STATE_SET command is additionally + required and is expected to be done outside this function. + + @param [in] BaseAddress Base address of the memory region. + @param [in] Length Length of the memory region. + @param [in] IpaWidth IPA width of the Realm. + @param [in] Share If TRUE, set the most significant + bit of the IPA to configure the memory + region as Unprotected IPA. + If FALSE, clear the most significant + bit of the IPA to configure the memory + region as Protected IPA. + + @retval RETURN_SUCCESS IPA protection attribute updated. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The request is not initiated in a + Realm. +**/ +RETURN_STATUS +EFIAPI +ArmCcaSetMemoryProtectAttribute ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 IpaWidth, + IN BOOLEAN Share + ); + +/** + Return the IPA width of the Realm. + + The IPA width of the Realm is used to configure the protection attribute + for memory regions, see ArmCcaSetMemoryProtectAttribute(). + + The IPA width of the Realm is present in the Realm config which is read + when the ArmCcaInitPeiLib library hook function ArmCcaInitialize () is + called in the PrePi phase. ArmCcaInitialize () stores the IPA width of + the Realm in a GUID HOB gArmCcaIpaWidthGuid. + + This function searches the GUID HOB gArmCcaIpaWidthGuid and returns the + IPA width value stored therein. + + Note: + - This function must only be called after ArmCcaInitialize () has setup + the GUID HOB gArmCcaIpaWidthGuid. + + @param [out] IpaWidth IPA width of the Realm. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_NOT_FOUND The GUID HOB gArmCcaIpaWidthGuid is not + found and could mean that this function + was called before ArmCcaInitialize () + has created and initialised the GUID + HOB gArmCcaIpaWidthGuid. +**/ +RETURN_STATUS +EFIAPI +GetIpaWidth ( + OUT UINT64 *IpaWidth + ); + +#endif // ARM_CCA_LIB_ diff --git a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c new file mode 100644 index 0000000000000000000000000000000000000000..57b05f308377cf931c5f43fc7793c260dfdc36fb --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c @@ -0,0 +1,174 @@ +/** @file + Library that implements the Arm CCA helper functions. + + Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Rsi or RSI - Realm Service Interface + - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state +**/ +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +/** + Check if running in a Realm. + + @retval TRUE The execution is within the context of a Realm. + @retval FALSE The execution is not within the context of a Realm. +**/ +BOOLEAN +EFIAPI +IsRealm ( + VOID + ) +{ + RETURN_STATUS Status; + UINT16 Major; + UINT16 Minor; + + if (ArmHasRme ()) { + Status = RsiGetVersion (&Major, &Minor); + if (!RETURN_ERROR (Status)) { + return TRUE; + } + } + + return FALSE; +} + +/** + Configure the protection attribute for the page tables + describing the memory region. + + The IPA space of a Realm is divided into two halves: + - Protected IPA space and + - Unprotected IPA space. + + Software in a Realm should treat the most significant bit of an + IPA as a protection attribute. + + A Protected IPA is an address in the lower half of a Realms IPA + space. The most significant bit of a Protected IPA is 0. + + An Unprotected IPA is an address in the upper half of a Realms + IPA space. The most significant bit of an Unprotected IPA is 1. + + Note: + - Configuring the memory region as Unprotected IPA enables the + Realm to share the memory region with the Host. + - This function updates the page table entries to reflect the + protection attribute. + - A separate call to transition the memory range using the Realm + Service Interface (RSI) RSI_IPA_STATE_SET command is additionally + required and is expected to be done outside this function. + + @param [in] BaseAddress Base address of the memory region. + @param [in] Length Length of the memory region. + @param [in] IpaWidth IPA width of the Realm. + @param [in] Share If TRUE, set the most significant + bit of the IPA to configure the memory + region as Unprotected IPA. + If FALSE, clear the most significant + bit of the IPA to configure the memory + region as Protected IPA. + + @retval RETURN_SUCCESS IPA protection attribute updated. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_UNSUPPORTED The request is not initiated in a + Realm. +**/ +RETURN_STATUS +EFIAPI +ArmCcaSetMemoryProtectAttribute ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 IpaWidth, + IN BOOLEAN Share + ) +{ + if (!IsRealm ()) { + return RETURN_UNSUPPORTED; + } + + if ((Length == 0) || (IpaWidth == 0)) { + return RETURN_INVALID_PARAMETER; + } + + return SetMemoryProtectionAttribute ( + BaseAddress, + Length, + IpaWidth, + Share + ); +} + +/** + Return the IPA width of the Realm. + + The IPA width of the Realm is used to configure the protection attribute + for memory regions, see ArmCcaSetMemoryProtectAttribute(). + + The IPA width of the Realm is present in the Realm config which is read + when the ArmCcaInitPeiLib library hook function ArmCcaInitialize () is + called in the PrePi phase. ArmCcaInitialize () stores the IPA width of + the Realm in a GUID HOB gArmCcaIpaWidthGuid. + + This function searches the GUID HOB gArmCcaIpaWidthGuid and returns the + IPA width value stored therein. + + Note: + - This function must only be called after ArmCcaInitialize () has setup + the GUID HOB gArmCcaIpaWidthGuid. + + @param [out] IpaWidth IPA width of the Realm. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_NOT_FOUND The GUID HOB gArmCcaIpaWidthGuid is not + found and could mean that this function + was called before ArmCcaInitialize () + has created and initialised the GUID + HOB gArmCcaIpaWidthGuid. +**/ +RETURN_STATUS +EFIAPI +GetIpaWidth ( + OUT UINT64 *IpaWidth + ) +{ + VOID *Hob; + UINT64 *CcaIpaWidth; + + if (IpaWidth == NULL) { + return RETURN_INVALID_PARAMETER; + } + + Hob = GetFirstGuidHob (&gArmCcaIpaWidthGuid); + if ((Hob == NULL) || + (GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (UINT64))) + { + return RETURN_NOT_FOUND; + } + + CcaIpaWidth = GET_GUID_HOB_DATA (Hob); + if ((UINT64)*CcaIpaWidth == 0) { + return RETURN_NOT_FOUND; + } + + *IpaWidth = *CcaIpaWidth; + + return RETURN_SUCCESS; +} diff --git a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.inf b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..7d90b4535d69c12672af5de3d7cab63a3cd528a6 --- /dev/null +++ b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.inf @@ -0,0 +1,34 @@ +## @file +# Library that implements the Arm CCA helper functions. +# +# Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x0001001B + BASE_NAME = ArmCcaLib + FILE_GUID = 11C18743-52F9-405E-B35B-D7BE91A26F9F + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = ArmCcaLib + +[Sources] + ArmCcaLib.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + ArmCcaRsiLib + ArmLib + ArmMmuLib + BaseLib + HobLib + +[Guids] + gArmCcaIpaWidthGuid -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117682): https://edk2.groups.io/g/devel/message/117682 Mute This Topic: https://groups.io/mt/105483420/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-