From nobody Mon Feb 9 00:07:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103555+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682438696100725.9831052123666; Tue, 25 Apr 2023 09:04:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 18TuYY1788612xsa9hjuq0pl; Tue, 25 Apr 2023 09:04:55 -0700 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.80]) by mx.groups.io with SMTP id smtpd.web10.83962.1682438694691617593 for ; Tue, 25 Apr 2023 09:04:55 -0700 X-Received: from AS9PR0301CA0022.eurprd03.prod.outlook.com (2603:10a6:20b:468::18) by AM9PR08MB6676.eurprd08.prod.outlook.com (2603:10a6:20b:2ff::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: from AM7EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:468:cafe::28) by AS9PR0301CA0022.outlook.office365.com (2603:10a6:20b:468::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.54 via Frontend Transport; Tue, 25 Apr 2023 16:04: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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103555+1787277+3901457@groups.io; helo=mail02.groups.io; 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 AM7EUR03FT014.mail.protection.outlook.com (100.127.140.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Tue, 25 Apr 2023 16:04:47 +0000 X-Received: ("Tessian outbound 3a01b65b5aad:v136"); Tue, 25 Apr 2023 16:04:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1ae188d6bdfd72db X-CR-MTA-TID: 64aa7808 X-Received: from cb4b7a39bab1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CB9FC1E5-C047-4DC3-9AA9-C1D508A253A8.1; Tue, 25 Apr 2023 16:04:40 +0000 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cb4b7a39bab1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jj2/I5dIfVc2N59Fr7weJ9EnYpl3dSfnrmHi3zfRHCQZQDEP8XfJ1jidkfj7RfisJgeRuGUtl6mSWLzkntBNYFTBbXjE56gdkwq44GZGesgfMV6Ay6YNA4ZEgMIJBNHOZE4UwEwF/mj+We/r6n03WHxyOCjzwlYH90Ce73aGMiRaJy+fE3bHTyobOm7FAqQo1IoBPt7z++OE5zfHfpU0xx0ob5pVd6MAY3ToGjhSq1gagZdllxAtfnnzFheAQxwX2MweYhtDXZDy4PP8NRVTW4nT5bDiLtQNRW2OhWu59eElrAuRkjVJYdaNhvF4fuXBmDltfNVlah1oO+ZM9Pftfw== 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=sdgl81LEDTHHrd63wk5/yLnJtSJVvnfqgcSdkEnEkPw=; b=IML1HYXmcK6Tv6r0vgGWhkGIOm2oagPXCCv0MicxGffW1WDpG/YO5a0/fhs33aFbFRNq9fus+bOsI6ZA6mcEKrbM7raENOexQrLRPu3hZFoHj/cz82JJotTUjDd+ETS0nE8+tkJ0365OW2vUYCV0rvhUJnrOWVEJTR1NADY/FLCPaynXjAoNgxgsvsKgJoelwr9ZcbHdKUEx1N1dhnZ6Mvcihq08n5dNNF/VWbe2Yz8bHXQ8409yPl4OyB+inZjkTZwWnEuWQTKRMeB5J4NINl7I8ZrBa4ANgiWJyCx0iPJRkY9ldXzQ8GbgtgiMcAl/MIUmnuSKRrHuKxSXmZPwGg== 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 X-Received: from DU2PR04CA0269.eurprd04.prod.outlook.com (2603:10a6:10:28e::34) by AS8PR08MB10170.eurprd08.prod.outlook.com (2603:10a6:20b:63f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:04:38 +0000 X-Received: from DBAEUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::e0) by DU2PR04CA0269.outlook.office365.com (2603:10a6:10:28e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34 via Frontend Transport; Tue, 25 Apr 2023 16:04:38 +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 DBAEUR03FT055.mail.protection.outlook.com (100.127.142.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:04:38 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.23; Tue, 25 Apr 2023 16:04:37 +0000 X-Received: from E114225.Arm.com (10.1.196.36) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 25 Apr 2023 16:04:36 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [edk2-devel] [RFC PATCH v1 07/30] ArmVirtPkg: ArmCcaRsiLib: Add interfaces to manage the Realm IPA state Date: Tue, 25 Apr 2023 17:04:05 +0100 Message-ID: <20230425160428.27980-8-sami.mujawar@arm.com> In-Reply-To: <20230425160428.27980-1-sami.mujawar@arm.com> References: <20230425160428.27980-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT055:EE_|AS8PR08MB10170:EE_|AM7EUR03FT014:EE_|AM9PR08MB6676:EE_ X-MS-Office365-Filtering-Correlation-Id: b2e972f1-2f26-4e37-e60f-08db45a6cb05 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: mMwH5MgCcQ+kvW71y9QASI6AK+xi7bhpxepx/+qV4s+FITqJcp+TgUEORns+We75IqkZnazXq1ZHhFBwhGRA6YRw2UVi2Xm+MYWKB/diezb1mDt49jnyFI96VwlHW4qFu30QcUzmhdBbf+nsEm+c0IPHIbhHhWSMUhIgn5pVl6PKKwh6RoGJFED9qGwN20rB1Fz8pV3Ye3RheimskRYYESTr9IqbnuibHNK0jd32OxBmlg5+Qv2dT6NG8sTPPXvz8DPE6BAGE+UwaUCuQUi/MlyN6QXMKiuVhHPR6GtK6rlrpzLfI/7WZYMJNORX5kuz6mvHiw59/IgH4uTg1btVSBeJa7lysgTCBWJfZQsXdtFTFvtfVFPaos7h59VaszRuh2DpFc/gPwdnV6eWPUpVrupimI3sNYWUZEQ6nj+BMlbS+sl9VMUbmiUMa9RQhgAfVn4g5JZcZKwfieggKECi/AiEtDF2BGqVtfriLHDKpFcHfjAEx5j1Sj96PjzpdTXngTEKfukqyknZNV4z9wU7syPGnW7Tvn2cP7JMKj2idLaNYL0QWNSaR39e9um5rHwjiXn1/UNNqs2A52GG31vj0REDH8Rq5fp41k7b2ZSHAKZ5R4Avbgg2OIINFRXoiHLZ4SsBplQe3wBjZZERgarOFCP12mu2305+fjgY9xc4gir5Yoh+nX/MKj1jIZ52FlzORi7AYhKAZi5j+lavxPJvD7sQRKm7L7uwN8Dz66FGTNk= 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:(13230028)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199021)(36840700001)(46966006)(1076003)(26005)(40480700001)(426003)(336012)(2616005)(36756003)(34070700002)(83380400001)(36860700001)(47076005)(186003)(82740400003)(356005)(81166007)(70206006)(86362001)(70586007)(478600001)(6916009)(8676002)(8936002)(54906003)(44832011)(5660300002)(7696005)(41300700001)(2906002)(82310400005)(4326008)(6666004)(316002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10170 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1ff1f0a5-9772-46b8-c4a3-08db45a6c584 X-Microsoft-Antispam-Message-Info: pohMm1rXWVGpANXa4zAmxkNkZiwn9+5hP/+Xm7AkL++myFVfg9R5myzM1m7SgmotKic0gDO7xSWIUFjrOCfLwRoIgPOlP4G2TxM6OZSq+ZMd5+evPt6/6y3umPL9clmE+iU1JjKNE9bJor90Bw5LFnwBmbadhNot5etMBvqsKBgilXYpf1nmD7ThWazDoBh1ny537L29URrJD3UQi4rN2T/ALlMWeJIHoNmD1y9vrUEKauQ6Ui0/bcspshng9udOQbyihXfuAwb7UJHK8C3bFANSldO/WbPEyA9DhtETZCGBJw2bhpUzkNWCEnAQGTfO3EXRlmQZBjSxWkfA8DTx4jQF5hIXgPSetTAs2U6PN7mRUTqPsyXv+oF3gbFtnlPdb0cWV3mwAfyOtfzEVqxipcD1I4E1cp0rP4YzatanC8pjrezbP4Wmva7f/k66HTE7DD4wTw3/mrwzmcPtlk0c10lhc8MC92gSr3N3zsy8VYH70pMvhsB/lX4aiG/8BEq6ezQvhbMHcIS7jFwp1KfZlol1z66OBH/q8y6S42yAC+YfpAmiEx9VKfGmKb57LIWfEDmwCQEJuUCvzmXbvEIZ4/7YxaP6Sm7k+O2nkMP6rTSOxNmgq8lfCFvxFCWblDyryGN9LPLMLgwbYUb1GUGrz9Ty/WjD3hpHzFmZdz8HVfY82M/X999W2jA2w0Lwg+m+82Q24UjUdEixsSBZX2DCjIy1HupJArfNCRK8VHJg8hQ= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:04:47.5325 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2e972f1-2f26-4e37-e60f-08db45a6cb05 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: AM7EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6676 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: EjwcBNMp0Zstmf9Pi6MZJ7S9x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682438695; bh=gf0vF+aGkbmR+UKyO8XwQA2ZI6KkVU4c36CVf7e9kZQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=tqY+Oz7hMUEvmL/05UoserRp62yy48Z6S1e1n0BjRZM0ifWhNDJ68rnq7TSHHXX2MzP CCayVKooE0QoPUGrySkkbgE7dsx4ut4xe8JxSuG1G25fk6DTbHOAWCnPAxlq9ZVyz+Aj+ XRSfAyg6LxA1PNtISTRBVN3JuX2GmKMyrJo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682438696705100017 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Realm's IPA space. An Unprotected IPA is an address in the upper half of a Realm's IPA space. A Protected IPA has an associated Realm IPA state (RIPAS). The RIPAS values are: * EMPTY - Unused address * RAM - Private code or data owned by the Realm. Software in the Realm needs to share memory with the host to communicate with the outside world, e.g. network, disk image, etc. To share memory, the software in the Realm first transitions the RIPAS of memory region it wants to share with the host from RAM to EMPTY. The Realm software can then access the shared memory region using the Unprotected IPA address. The RMM specification defines the following Realm Service Interfaces for managing the IPA state: * RSI_IPA_STATE_GET * RSI_IPA_STATE_SET Therefore, update the ArmCcaRsiLib to add interfaces to get and set the IPA state of Realm memory pages. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Include/Library/ArmCcaRsiLib.h | 50 +++++++++++ ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h | 7 +- ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c | 92 ++++++++++++++++++++ 3 files changed, 147 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h b/ArmVirtPkg/Include= /Library/ArmCcaRsiLib.h index ab70240b3ab2979996f20190ddf669b53183556b..ae798a2feb9c3c417f06b7c2dfd= b49479731df52 100644 --- a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h +++ b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h @@ -6,6 +6,7 @@ =20 - Rsi or RSI - Realm Service Interface - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state =20 @par Reference(s): - Realm Management Monitor (RMM) Specification, version A-bet0 @@ -24,6 +25,21 @@ */ #define REALM_GRANULE_SIZE SIZE_4KB =20 +/** + A macro defining the mask for the RSI RIPAS type. + See Section B4.4.5 RsiRipas type, RMM Specification, version A-bet0. +*/ +#define RIPAS_TYPE_MASK 0xFF + +/** An enum describing the RSI RIPAS. + See Section A5.2.2 Realm IPA state, RMM Specification, version A-bet0 +*/ +typedef enum Ripas { + RIPAS_EMPTY, ///< Unused IPA location. + RIPAS_RAM, ///< Private code or data owned by the Realm. + RIPAS_MAX ///< A valid RIPAS type value is less than RIPAS_MAX. +} RIPAS; + /** A structure describing the Realm Configuration. See Section B4.4.4 RsiRealmConfig type, RMM Specification, version A-bet0 The width of the RsiRealmConfig structure is 4096 (0x1000) bytes. @@ -35,6 +51,40 @@ typedef struct RealmConfig { UINT8 Reserved[SIZE_4KB - sizeof (UINT64)]; } REALM_CONFIG; =20 +/** + Returns the IPA state for the page pointed by the address. + + @param [in] Address Address to retrive IPA state. + @param [out] State The RIPAS state for the address specified. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiGetIpaState ( + IN UINT64 *Address, + OUT RIPAS *State + ); + +/** + Sets the IPA state for the pages pointed by the memory range. + + @param [in] Address Address to the start of the memory range. + @param [in] Size Length of the memory range. + @param [in] State The RIPAS state to be configured. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiSetIpaState ( + IN UINT64 *Address, + IN UINT64 Size, + IN RIPAS State + ); + /** Read the Realm Configuration. =20 diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Libra= ry/ArmCcaRsiLib/ArmCcaRsi.h index 90e9dbb609679c82cd8e8ee8081428fd97021f97..9cc12bc5a70b457367077d0b260= 11c3b91fa63c9 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h @@ -7,6 +7,7 @@ @par Glossary: - Rsi or RSI - Realm Service Interface - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state =20 @par Reference(s): - Realm Management Monitor (RMM) Specification, version A-bet0 @@ -17,8 +18,10 @@ #define ARM_CCA_RSI_H_ =20 // FIDs for Realm Service Interface calls. -#define FID_RSI_REALM_CONFIG 0xC4000196 -#define FID_RSI_VERSION 0xC4000190 +#define FID_RSI_IPA_STATE_GET 0xC4000198 +#define FID_RSI_IPA_STATE_SET 0xC4000197 +#define FID_RSI_REALM_CONFIG 0xC4000196 +#define FID_RSI_VERSION 0xC4000190 =20 /** RSI Command Return codes See Section B4.4.1, RMM Specification, version A-bet0. diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c b/ArmVirtPkg/Li= brary/ArmCcaRsiLib/ArmCcaRsiLib.c index 42b99fb7a71c8b38512a2f7472f9bc8a034fe1e9..546df9a94cb86533b37fef7e42f= daf7b8563052d 100644 --- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c +++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c @@ -7,6 +7,7 @@ @par Glossary: - Rsi or RSI - Realm Service Interface - IPA - Intermediate Physical Address + - RIPAS - Realm IPA state =20 @par Reference(s): - Realm Management Monitor (RMM) Specification, version A-bet0 @@ -81,6 +82,97 @@ AddrIsGranuleAligned ( return TRUE; } =20 +/** + Returns the IPA state for the page pointed by the address. + + @param [in] Address Address to retrive IPA state. + @param [out] State The RIPAS state for the address specified. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiGetIpaState ( + IN UINT64 *Address, + OUT RIPAS *State + ) +{ + RETURN_STATUS Status; + ARM_SMC_ARGS SmcCmd; + + if ((State =3D=3D NULL) || (!AddrIsGranuleAligned (Address))) { + return RETURN_INVALID_PARAMETER; + } + + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_IPA_STATE_GET; + SmcCmd.Arg1 =3D (UINTN)Address; + + ArmCallSmc (&SmcCmd); + Status =3D RsiCmdStatusToEfiStatus (SmcCmd.Arg0); + if (!RETURN_ERROR (Status)) { + *State =3D (RIPAS)(SmcCmd.Arg1 & RIPAS_TYPE_MASK); + } + + return Status; +} + +/** + Sets the IPA state for the pages pointed by the memory range. + + @param [in] Address Address to the start of the memory range. + @param [in] Size Length of the memory range. + @param [in] State The RIPAS state to be configured. + + @retval RETURN_SUCCESS Success. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. +**/ +RETURN_STATUS +EFIAPI +RsiSetIpaState ( + IN UINT64 *Address, + IN UINT64 Size, + IN RIPAS State + ) +{ + RETURN_STATUS Status; + UINT64 *BaseAddress; + UINT64 *EndAddress; + ARM_SMC_ARGS SmcCmd; + + if ((Size =3D=3D 0) || + ((Size & (REALM_GRANULE_SIZE - 1)) !=3D 0) || + (!AddrIsGranuleAligned (Address))) + { + return RETURN_INVALID_PARAMETER; + } + + BaseAddress =3D Address; + // Divide Size by 8 for the pointer arithmetic + // to work, as we are adding to UINT64*. + EndAddress =3D Address + (Size >> 3); + + while (Size > 0) { + ZeroMem (&SmcCmd, sizeof (SmcCmd)); + SmcCmd.Arg0 =3D FID_RSI_IPA_STATE_SET; + SmcCmd.Arg1 =3D (UINTN)BaseAddress; + SmcCmd.Arg2 =3D (UINTN)Size; + SmcCmd.Arg3 =3D (UINTN)State; + + ArmCallSmc (&SmcCmd); + Status =3D RsiCmdStatusToEfiStatus (SmcCmd.Arg0); + if (RETURN_ERROR (Status)) { + break; + } + + BaseAddress =3D (UINT64 *)SmcCmd.Arg1; + Size =3D EndAddress - BaseAddress; + } // while + + return Status; +} + /** Read the Realm Configuration. =20 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103555): https://edk2.groups.io/g/devel/message/103555 Mute This Topic: https://groups.io/mt/98495959/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-