[edk2-devel] [PATCH v1 10/16] StandaloneMmPkg: Switch to the MmuLib abstraction

Yao, Jiewen jiewen.yao at intel.com
Tue Nov 2 00:25:51 UTC 2021


Acked-by: Jiewen Yao <Jiewen.yao at intel.com>

> -----Original Message-----
> From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Bret
> Barkelew
> Sent: Tuesday, November 2, 2021 3:57 AM
> To: devel at edk2.groups.io
> Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>; Sami Mujawar
> <sami.mujawar at arm.com>; Yao, Jiewen <jiewen.yao at intel.com>; Supreeth
> Venkatesh <supreeth.venkatesh at arm.com>; Sean Brogan
> <sean.brogan at microsoft.com>
> Subject: [edk2-devel] [PATCH v1 10/16] StandaloneMmPkg: Switch to the
> MmuLib abstraction
> 
> 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/Stand
> aloneMmPeCoffExtraActionLib.c | 50 ++++++++++++++++++--
> 
> StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMm
> PeCoffExtraActionLib.inf       |  3 +-
>  StandaloneMmPkg/StandaloneMmPkg.dsc                                                                 |
> 1 +
>  3 files changed, 47 insertions(+), 7 deletions(-)
> 
> diff --git
> a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/Sta
> ndaloneMmPeCoffExtraActionLib.c
> b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/Sta
> ndaloneMmPeCoffExtraActionLib.c
> index ca8b1244a313..ca3b9de26a6f 100644
> ---
> a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/Sta
> ndaloneMmPeCoffExtraActionLib.c
> +++
> b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/Sta
> ndaloneMmPeCoffExtraActionLib.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/StandaloneM
> mPeCoffExtraActionLib.inf
> b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneM
> mPeCoffExtraActionLib.inf
> index 89083df679a1..25306dd3e707 100644
> ---
> a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneM
> mPeCoffExtraActionLib.inf
> +++
> b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneM
> mPeCoffExtraActionLib.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/StandaloneMmCoreE
> ntryPoint/StandaloneMmCoreEntryPoint.inf
> 
> 
> StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoin
> t/StandaloneMmDriverEntryPoint.inf
> 
> 
> VariableMmDependency|StandaloneMmPkg/Library/VariableMmDependency/V
> ariableMmDependency.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 (#83040): https://edk2.groups.io/g/devel/message/83040
> Mute This Topic: https://groups.io/mt/86750657/1772286
> Group Owner: devel+owner at edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [jiewen.yao at intel.com]
> -=-=-=-=-=-=
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83067): https://edk2.groups.io/g/devel/message/83067
Mute This Topic: https://groups.io/mt/86750657/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