From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.58]) by mx.groups.io with SMTP id smtpd.web10.84039.1682438844238277239 for ; Tue, 25 Apr 2023 09:07:24 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=jVLRAHwA; spf=pass (domain: arm.com, ip: 40.107.8.58, 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=xMJBssLvPEw0pNBQIlUf4y3Z3aX/noymdxuuTd/c0R4=; b=jVLRAHwAETPoAFhbjoCmolDQg6lMWKs2ElDbgPJ65OwZa2K3kdzclDth6dWCGf6VgCUIH5pbg2chGXf82mfd1Md2GigjKeu1enD8RUUw77Z9XBzICGvf7UqyfFkgpQYWS7l49UTDthbuQQrdOvM8hmU2+/CBGwDNyGj4/ffjJfU= Received: from DB9PR06CA0029.eurprd06.prod.outlook.com (2603:10a6:10:1db::34) by PAVPR08MB8797.eurprd08.prod.outlook.com (2603:10a6:102:32e::8) 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:07:20 +0000 Received: from DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1db:cafe::5f) by DB9PR06CA0029.outlook.office365.com (2603:10a6:10:1db::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:07:20 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT041.mail.protection.outlook.com (100.127.142.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20 via Frontend Transport; Tue, 25 Apr 2023 16:07:20 +0000 Received: ("Tessian outbound 3570909035da:v136"); Tue, 25 Apr 2023 16:07:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b45b49e43d2f4a26 X-CR-MTA-TID: 64aa7808 Received: from 508e8378810d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BBC5FBBB-5E70-45A0-A86A-B74B27D2F5B6.1; Tue, 25 Apr 2023 16:04:35 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 508e8378810d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Apr 2023 16:04:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JMzvD5GUW0zEf+PZiObpkCw1hwkDVQH3WIXRgLdZBvCdxLXXwrPOmvR2ewICkH7ODc65XThyzg6oc/3YcONVhdXJNU1o2eMfMVoAXJrNXk7gxsmaX+XiOVyitJAj0S1v5A8qQ9PB1AWgIyG1mPXqCtwKG1QChECDoUEh7lXmodst2bPDt9iZBjrtbZQfBQvbS6959LHc0LzJ55DBNVYW/w9ifLB+CYTciY/wqhqfu5W2S8GJ/2OA4exYDBk7Av3ntURcvaY0gbhPgyMfqtYrQfVP39Vb7xJcq+iDtt7izaECaojnKl8Sg4eyeQZOHfGAYsz0+Y50g3G3XRyOBsf0Nw== 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=xMJBssLvPEw0pNBQIlUf4y3Z3aX/noymdxuuTd/c0R4=; b=ONjTCQxiLh5lQ+GX3dTTFCEZc7zw1xJFTHKW7ElG0Ra2x5O/m0tRvk14bXPKnIRDlgu2us/GGnlT0PldmpUeTXMZmrHQmhER7CCWF8QDUCL++7j/+yF0UE426ED1PdzzhsuQGfo/6AbxXVRDgB+AqkerlyA85k5elmTgJk72/G8rl8AF4W/lkZ12Cdxvd3KeD6P4vfB/1fPSv5qAzO9M5OuuSlrmhanjfbrKZnkn+9eJFBzVGVDjFvGPCF9Km+/bSFor6DwP3APZzgtfojK2F4N20t0nTIPBn8nZTCGIcTLt10CkfLSEqIo1sFbBbkusdkLO6BV55XQGyUSw6wgNXA== 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=xMJBssLvPEw0pNBQIlUf4y3Z3aX/noymdxuuTd/c0R4=; b=jVLRAHwAETPoAFhbjoCmolDQg6lMWKs2ElDbgPJ65OwZa2K3kdzclDth6dWCGf6VgCUIH5pbg2chGXf82mfd1Md2GigjKeu1enD8RUUw77Z9XBzICGvf7UqyfFkgpQYWS7l49UTDthbuQQrdOvM8hmU2+/CBGwDNyGj4/ffjJfU= Received: from DB6PR0601CA0042.eurprd06.prod.outlook.com (2603:10a6:4:17::28) by PAXPR08MB6480.eurprd08.prod.outlook.com (2603:10a6:102:155::10) 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:33 +0000 Received: from DBAEUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:17:cafe::16) by DB6PR0601CA0042.outlook.office365.com (2603:10a6:4:17::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33 via Frontend Transport; Tue, 25 Apr 2023 16:04:33 +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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT052.mail.protection.outlook.com (100.127.142.144) 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:33 +0000 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.23; Tue, 25 Apr 2023 16:04:33 +0000 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.23; Tue, 25 Apr 2023 16:04:32 +0000 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:32 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Subject: [RFC PATCH v1 03/30] ArmPkg: Export SetMemoryRegionAttribute in ArmMmuLib Date: Tue, 25 Apr 2023 17:04:01 +0100 Message-ID: <20230425160428.27980-4-sami.mujawar@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 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: DBAEUR03FT052:EE_|PAXPR08MB6480:EE_|DBAEUR03FT041:EE_|PAVPR08MB8797:EE_ X-MS-Office365-Filtering-Correlation-Id: cfc2ab42-c9d3-40fc-c2fc-08db45a725ee 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: rUEXsd6VDVAonnL5QVXXj+R9JPSaLh+ePuFiGeQqARd+D4xr34/NmkuZnuPmRm3mKNkTowzLRW6sENET/WKQSy6CWcpxsqzc2SFvUXShCEI/gT5nMaaoTa6CVMnHCSH35TOPiFZyuPNxIB6JZelJpfnaP/R1XgCgpKHLLY3dVSAd+3jXJrZhPDqoqNJDKaqULdYtaYT7zVNXinSy6KZaSyUEMWnyYlI3u4cHsKyXoWQ1KuQen0VltDGzcQV1uVoeOnu82Xsrqiroav+08LItYI4BTluvRia7VzkkAjcGD8QujthPNJiJEiiVX6pf/HP473YiuWIfmDX4gwozJSmPYJ3yUCpd97q2WGT9CMm7mpQhupaaB9MRzZRtxsnSVPljJZ5Nmmlf14brdf9ODfrxSW7LDsO92QI4zp6INuNuhUhzv2IlNx5mq9iTCEx0/K9hyoS2S67BrEvJbkHtNcNZej3bpAi9QrL+dK9G8MukjG6bfopb96PtSGuOALSI+zc/jIHbqLg3ybOsTLPZLZ8TrUtRKR5wtB5K1PA91ZYtyhe/ytNdoMrlgBNbDEHnnm64cW8CUU/PmelsBUlOD+WMjdqGTchvSZr62Akkk0fw1cgjQQp8CMSrxfHJ9m3EQtyEcvVKKCkp1ykK55C6dlIMTiuhTX8gwjjIkf0dn+faKyzTEfW9HBm9H9DbIzxUn/h580rya+o9v1YmwxcskjOv5+Lem/jeUkuyqYrPyej5lm8= 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)(19627235002)(5660300002)(7696005)(41300700001)(2906002)(82310400005)(4326008)(6666004)(316002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6480 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1ce76983-2b44-4b1c-7fc9-08db45a6c2c4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FrTPcRtCmXAgmZGtKEGNWtv94skIWWxF5R1jRAIc4G9ScgbHe9fBe9V+UkuxJKDwbdG6khapYeVuqqht+4roKFzHCVtPLkc0sMg4F3T5DYUMnw8ZwatzwZRLupiCVuQBy+s+Go01QMINGDmsSF3PrwxO4zdPsa2oC3mqJ8iRXx6X1bdJuQani/J9qMFptTv4wqZdW7EmhQ8GFEWv7CTB48yMEclDSNjFV3Nyyaqd+z1+E6r0rcN1dPkrYYZCCvPl+r+NXVFoXwEK8xqWhVeKzxGWCYugs7XxKBVcgRICEkytdcj1JqbLwJIM8xONTaUvRHtzK73nZsUmEQH5Xynjw26rA7o/yt8Lp4vX6JIVmx52FzoZ3XkFX2W70JPFzYnvdgFd6/LDVT9tsBhZrcSfInqxE5m7NkCLAvokgTPtX0oKHG9GP2dXA/aYfdnMRCzc239a9QrqvIJhrbHeaXlginF3U17zFafTleRFwFR+BO+WUeige5y0GCvwiGYkrWTvXVv9+uP5T6n1Yvo50pin9q7UroUtYvMzl3dG/wqNi6u7atqSVSW7HDi99dbwkA5fIGmu468uSbNLOrVRGBTepT22d7pNwvEPNgB8ODisDLu3pH7Y54EbBfwGYtLUzJAxb/5vh0L3mDlo0rdO2p5RaNlJsKTZwhsQTeW5iaOfiUHMZSlLlXdSwwCKptfShAd1kgzI8u8ZjsKWLnb6YmGtomaakLl2Fb6Qixi4C2MN1GA= 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:(13230028)(4636009)(376002)(346002)(136003)(39860400002)(396003)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(81166007)(41300700001)(82740400003)(186003)(7696005)(5660300002)(1076003)(26005)(54906003)(8676002)(8936002)(86362001)(44832011)(36756003)(40480700001)(316002)(6916009)(2616005)(19627235002)(70586007)(70206006)(36860700001)(4326008)(6666004)(34070700002)(83380400001)(2906002)(82310400005)(478600001)(426003)(336012)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:07:20.1160 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cfc2ab42-c9d3-40fc-c2fc-08db45a725ee 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: DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB8797 Content-Type: text/plain Arm CCA requires the software in a Realm to treat the most significant bit of an IPA as a protection attribute. To enable/disable sharing of memory regions with the host, the protection attribute needs to be set/cleared accordingly. Instead of implementing the functionality to Set/Clear the protection attribute in ArmMmuLib, defer this to an Arm CCA specific library so that additional dependencies for ArmMmuLib can be avoided. Therefore, export the SetMemoryRegionAttribute () in ArmMmuLib so that the Realm software can configure the protection attribute. Signed-off-by: Sami Mujawar --- ArmPkg/Include/Library/ArmMmuLib.h | 22 ++++++++++++++++++++ ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 16 ++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ArmPkg/Include/Library/ArmMmuLib.h b/ArmPkg/Include/Library/ArmMmuLib.h index 4cf59a1e376b123c036f80b0f545245334f87dcd..97e44b49f45728693d2cf147c416b96643596df0 100644 --- a/ArmPkg/Include/Library/ArmMmuLib.h +++ b/ArmPkg/Include/Library/ArmMmuLib.h @@ -1,6 +1,7 @@ /** @file Copyright (c) 2015 - 2016, Linaro Ltd. All rights reserved.
+ Copyright (c) 2023, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -99,4 +100,25 @@ ArmSetMemoryAttributes ( IN UINT64 Attributes ); +/** + Set the attributes for the memory region. + + @param[in] BaseAddress Start address of the memory region. + @param[in] Length Length memory region. + @param[in] Attributes Attributes to set for the memory region. + @param[in] BlockEntryMask Mask to be used for the block entry. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +SetMemoryRegionAttribute ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes, + IN UINT64 BlockEntryMask + ); + #endif // ARM_MMU_LIB_H_ diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c index 7ed758fbbc699732a720149ffce6078d312f27c3..defe266a6c5afe6cbeaf89b11c7304665b98f011 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -1,7 +1,7 @@ /** @file * File managing the MMU for ARMv8 architecture * -* Copyright (c) 2011-2020, ARM Limited. All rights reserved. +* Copyright (c) 2011-2023, ARM Limited. All rights reserved. * Copyright (c) 2016, Linaro Limited. All rights reserved. * Copyright (c) 2017, Intel Corporation. All rights reserved.
* @@ -502,8 +502,20 @@ ArmSetMemoryAttributes ( ); } -STATIC +/** + Set the attributes for the memory region. + + @param[in] BaseAddress Start address of the memory region. + @param[in] Length Length memory region. + @param[in] Attributes Attributes to set for the memory region. + @param[in] BlockEntryMask Mask to be used for the block entry. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ EFI_STATUS +EFIAPI SetMemoryRegionAttribute ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'