[edk2-devel] [PATCH v2 10/16] StandaloneMmPkg: Switch to the MmuLib abstraction
Bret Barkelew
bret at corthon.com
Tue Nov 2 20:17:42 UTC 2021
From: Bret Barkelew <brbarkel at microsoft.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651
Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>
Cc: Sami Mujawar <sami.mujawar at arm.com>
Cc: Jiewen Yao <jiewen.yao at intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh at arm.com>
Cc: Sean Brogan <sean.brogan at microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew at microsoft.com>
---
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c | 50 ++++++++++++++++++--
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf | 3 +-
StandaloneMmPkg/StandaloneMmPkg.dsc | 1 +
3 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c
index ca8b1244a313..ca3b9de26a6f 100644
--- a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c
+++ b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c
@@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiDxe.h>
-#include <Library/ArmMmuLib.h>
+#include <Library/MmuLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
@@ -163,6 +163,46 @@ UpdatePeCoffPermissions (
return RETURN_SUCCESS;
}
+STATIC
+EFI_STATUS
+ArmPeSetMemoryRegionNoExec (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ return MmuSetAttributes (BaseAddress, Length, EFI_MEMORY_XP);
+}
+
+STATIC
+EFI_STATUS
+ArmPeClearMemoryRegionNoExec (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ return MmuClearAttributes (BaseAddress, Length, EFI_MEMORY_XP);
+}
+
+STATIC
+EFI_STATUS
+ArmPeSetMemoryRegionReadOnly (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ return MmuSetAttributes (BaseAddress, Length, EFI_MEMORY_RO);
+}
+
+STATIC
+EFI_STATUS
+ArmPeClearMemoryRegionReadOnly (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ return MmuClearAttributes (BaseAddress, Length, EFI_MEMORY_RO);
+}
+
/**
Performs additional actions after a PE/COFF image has been loaded and relocated.
@@ -180,8 +220,8 @@ PeCoffLoaderRelocateImageExtraAction (
{
UpdatePeCoffPermissions (
ImageContext,
- ArmClearMemoryRegionNoExec,
- ArmSetMemoryRegionReadOnly
+ ArmPeClearMemoryRegionNoExec,
+ ArmPeSetMemoryRegionReadOnly
);
}
@@ -205,7 +245,7 @@ PeCoffLoaderUnloadImageExtraAction (
{
UpdatePeCoffPermissions (
ImageContext,
- ArmSetMemoryRegionNoExec,
- ArmClearMemoryRegionReadOnly
+ ArmPeSetMemoryRegionNoExec,
+ ArmPeClearMemoryRegionReadOnly
);
}
diff --git a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
index 89083df679a1..25306dd3e707 100644
--- a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
+++ b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
@@ -27,10 +27,9 @@ [Sources.common]
AArch64/StandaloneMmPeCoffExtraActionLib.c
[Packages]
- ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec
StandaloneMmPkg/StandaloneMmPkg.dec
[LibraryClasses]
- StandaloneMmMmuLib
+ MmuLib
PcdLib
diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/StandaloneMmPkg.dsc
index 2c0c9396d633..d3e8d250d972 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dsc
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -59,6 +59,7 @@ [LibraryClasses]
StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
VariableMmDependency|StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf
+ MmuLib|MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf
[LibraryClasses.AARCH64, LibraryClasses.ARM]
ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
--
2.31.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83169): https://edk2.groups.io/g/devel/message/83169
Mute This Topic: https://groups.io/mt/86776052/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