[edk2-devel] [RFC PATCH v1 03/30] ArmPkg: Export SetMemoryRegionAttribute in ArmMmuLib

Sami Mujawar sami.mujawar at arm.com
Tue Apr 25 16:04:01 UTC 2023


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 <sami.mujawar at arm.com>
---
 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.<BR>
+  Copyright (c) 2023, Arm Limited. All rights reserved.<BR>
 
   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.<BR>
 *
@@ -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)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103579): https://edk2.groups.io/g/devel/message/103579
Mute This Topic: https://groups.io/mt/98496026/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list