From: Bret Barkelew <[email protected]> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651
Cc: Ard Biesheuvel <[email protected]> Cc: Sami Mujawar <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Supreeth Venkatesh <[email protected]> Cc: Sean Brogan <[email protected]> Signed-off-by: Bret Barkelew <[email protected]> --- StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c | 82 ++++++++++++++++++-- StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf | 3 +- StandaloneMmPkg/StandaloneMmPkg.dsc | 1 + 3 files changed, 79 insertions(+), 7 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c index ca8b1244a313..986f6ade5f47 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,78 @@ UpdatePeCoffPermissions ( return RETURN_SUCCESS; } +/** + Internal function to parameterize the call int MmuSetAttributes. + + @param [in] BaseAddress + @param [in] Length + + @retval EFI_STATUS Returned by MmuSetAttributes +**/ +STATIC +EFI_STATUS +ArmPeSetMemoryRegionNoExec ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + return MmuSetAttributes (BaseAddress, Length, EFI_MEMORY_XP); +} + +/** + Internal function to parameterize the call int MmuSetAttributes. + + @param [in] BaseAddress + @param [in] Length + + @retval EFI_STATUS Returned by MmuSetAttributes +**/ +STATIC +EFI_STATUS +ArmPeClearMemoryRegionNoExec ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + return MmuClearAttributes (BaseAddress, Length, EFI_MEMORY_XP); +} + +/** + Internal function to parameterize the call int MmuSetAttributes. + + @param [in] BaseAddress + @param [in] Length + + @retval EFI_STATUS Returned by MmuSetAttributes +**/ +STATIC +EFI_STATUS +ArmPeSetMemoryRegionReadOnly ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + return MmuSetAttributes (BaseAddress, Length, EFI_MEMORY_RO); +} + +/** + Internal function to parameterize the call int MmuSetAttributes. + + @param [in] BaseAddress + @param [in] Length + + @retval EFI_STATUS Returned by MmuSetAttributes +**/ +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 +252,8 @@ PeCoffLoaderRelocateImageExtraAction ( { UpdatePeCoffPermissions ( ImageContext, - ArmClearMemoryRegionNoExec, - ArmSetMemoryRegionReadOnly + ArmPeClearMemoryRegionNoExec, + ArmPeSetMemoryRegionReadOnly ); } @@ -205,7 +277,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 e9488538cb21..da3488e0d3fe 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 (#83623): https://edk2.groups.io/g/devel/message/83623 Mute This Topic: https://groups.io/mt/86971571/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
