public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 00/16] Un-siloing Arm common code
@ 2021-11-02 20:17 Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 01/16] ArmPkg/ArmMmuBaseLib: Disallow STANDALONE_MM Bret Barkelew
                   ` (15 more replies)
  0 siblings, 16 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Bob Feng, Jiaxin Wu, Jiewen Yao, Leif Lindholm,
	Liming Gao, Maciej Rabeda, Michael D Kinney, Ray Ni, Sami Mujawar,
	Sean Brogan, Siyuan Fu, Supreeth Venkatesh, Yuwei Chen,
	Zhichao Gao, Zhiguang Liu

This series of patch commits moves a number of modules and libraries around in order
to better un-silo the Arm-specific code. Unnecessary abstractions were removed, some
duplicate code was abstracted, and generally things were cleaned up so that common
code (e.g. MdePkg, MdeModulePkg, StandaloneMmPkg) does not require ArmPkg or
ArmPlatformPkg.

Also, some things that were previously hidden away under ArmPkg are now located
with the core functionality or build tooling that makes sense for it.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>

Bret Barkelew (15):
  ArmPkg/ArmMmuBaseLib: Disallow STANDALONE_MM
  ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib
  ArmPkg/StandaloneMmCoreEntryPoint: Swap to ArmMmuLib
  ArmPkg: Disavow StandaloneMmMmuLib. It's just ArmMmuLib
  ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg
  ArmPkg and BaseTools: Move the GccLto binaries from ArmPkg to
    BaseTools
  ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg
  MdePkg: Create the MMU access lib to abstract memory protection
    settings
  MdeModulePkg: Swap to MmuLib instead of Arm-specific lib
  StandaloneMmPkg: Switch to the MmuLib abstraction
  ArmPkg: Move the StandaloneMmCpu driver to ArmPkg
  ArmPkg: Move the StandaloneMmCoreEntryPoint lib to ArmPkg
  ArmPkg/Library: Convert StandaloneMmCoreEntryPoint to Arm-only
  ArmPkg/ArmPkg.dsc: Resolve build errors resulting from package moves
  ArmPlatformPkg: Resolve build errors resulting from package moves

Sean Brogan (1):
  ArmPkg: Add Basic MMU Lib for Arm silicon

 {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/EventHandle.c                                                                   |   0
 {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.c                                                               |   0
 ArmPkg/Library/MmuLib/MmuLib.c                                                                                                      | 120 ++++++++++++++++++++
 {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c                                                  |   0
 {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c                                                 |   0
 {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c                                     |   0
 ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c                                                                           |  37 ++++++
 MdeModulePkg/Core/DxeIplPeim/Arm/DxeLoadFunc.c                                                                                      |   4 +-
 MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.c                                                                                      |  86 ++++++++++++++
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c                                                                        |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c                                                                           |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c                                                                        |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset.c                                                                           |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c                                                                        |   0
 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c                                                 |  71 ------------
 StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c                                 |  50 +++++++-
 ArmPkg/ArmPkg.ci.yaml                                                                                                               |   3 +-
 ArmPkg/ArmPkg.dec                                                                                                                   |   4 -
 ArmPkg/ArmPkg.dsc                                                                                                                   |  15 ++-
 {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.h                                                               |   0
 {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf                                                             |   0
 ArmPkg/Include/Library/StandaloneMmMmuLib.h                                                                                         |  36 ------
 ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf                                                                                          |   2 +-
 ArmPkg/Library/MmuLib/BaseMmuLib.inf                                                                                                |  30 +++++
 {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf                                       |   8 +-
 ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf                                                                         |   2 +-
 ArmPlatformPkg/ArmPlatformPkg.dsc                                                                                                   |   4 +-
 {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.a                                                                           | Bin
 {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.s                                                                           |   0
 {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.a                                                                               | Bin
 {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.s                                                                               |   0
 BaseTools/Conf/tools_def.template                                                                                                   |  19 ++--
 CryptoPkg/CryptoPkg.dsc                                                                                                             |   2 +-
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf                                                                                             |   4 +-
 MdeModulePkg/MdeModulePkg.dsc                                                                                                       |   5 +-
 {ArmPkg/Include => MdePkg/Include/AArch64}/AsmMacroIoLibV8.h                                                                        |   0
 {ArmPkg/Include => MdePkg/Include/Arm}/AsmMacroIoLib.h                                                                              |   0
 MdePkg/Include/Library/MmuLib.h                                                                                                     |  75 ++++++++++++
 MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf                                                                                    |  28 +++++
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S                                                                  |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashldi3.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/clzsi2.S                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.S                                                                          |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.asm                                                                        |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divdi3.S                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divsi3.S                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.S                                                                         |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.asm                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm                                                                    |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.S                                                                         |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.asm                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.S                                                                         |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.asm                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.asm                                                                    |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/moddi3.S                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/modsi3.S                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/muldi3.S                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.S                                                                        |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.asm                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/sourcery.S                                                                     |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch.asm                                                                     |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch16.S                                                                     |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch32.S                                                                     |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch8.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switchu8.S                                                                     |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivdi3.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S                                                                   |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivsi3.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.S                                                                        |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.asm                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umoddi3.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umodsi3.S                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.S                                                                        |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.asm                                                                      |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.S                                                                       |   0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.asm                                                                     |   0
 ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf => MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf |   3 +-
 MdePkg/MdePkg.dec                                                                                                                   |   5 +
 MdePkg/MdePkg.dsc                                                                                                                   |   3 +
 NetworkPkg/NetworkPkg.dsc                                                                                                           |   2 +-
 ShellPkg/ShellPkg.dsc                                                                                                               |   2 +-
 StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf                                       |   3 +-
 StandaloneMmPkg/StandaloneMmPkg.dsc                                                                                                 |   3 +-
 UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc                                                                             |   2 +-
 91 files changed, 475 insertions(+), 153 deletions(-)
 rename {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/EventHandle.c (100%)
 rename {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.c (100%)
 create mode 100644 ArmPkg/Library/MmuLib/MmuLib.c
 rename {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c (100%)
 rename {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c (100%)
 rename {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c (100%)
 create mode 100644 MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.c
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c (100%)
 delete mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c
 rename {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.h (100%)
 rename {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf (100%)
 delete mode 100644 ArmPkg/Include/Library/StandaloneMmMmuLib.h
 create mode 100644 ArmPkg/Library/MmuLib/BaseMmuLib.inf
 rename {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf (84%)
 rename {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.a (100%)
 rename {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.s (100%)
 rename {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.a (100%)
 rename {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.s (100%)
 rename {ArmPkg/Include => MdePkg/Include/AArch64}/AsmMacroIoLibV8.h (100%)
 rename {ArmPkg/Include => MdePkg/Include/Arm}/AsmMacroIoLib.h (100%)
 create mode 100644 MdePkg/Include/Library/MmuLib.h
 create mode 100644 MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashldi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/clzsi2.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divdi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divsi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/moddi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/modsi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/muldi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/sourcery.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch16.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch32.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch8.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switchu8.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivdi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivsi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umoddi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umodsi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.asm (100%)
 rename ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf => MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf (93%)

-- 
2.31.1.windows.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v2 01/16] ArmPkg/ArmMmuBaseLib: Disallow STANDALONE_MM
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 02/16] ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib Bret Barkelew
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

Not sure what all module types this HAS been validated against, but it
doesn't work with STANDALONE_MM or STANDALONE_MM_CORE.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3647

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
---
 ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
index 2a7e7147958c..d0988b27d582 100644
--- a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
@@ -13,7 +13,7 @@ [Defines]
   FILE_GUID                      = da8f0232-fb14-42f0-922c-63104d2c70bd
   MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = ArmMmuLib
+  LIBRARY_CLASS                  = ArmMmuLib | DXE_DRIVER PEIM PEI_CORE DXE_CORE DXE_RUNTIME_DRIVER SEC
 
 [Defines.AARCH64]
   CONSTRUCTOR                    = ArmMmuBaseLibConstructor
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 02/16] ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 01/16] ArmPkg/ArmMmuBaseLib: Disallow STANDALONE_MM Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-04 12:14   ` Leif Lindholm
  2021-11-02 20:17 ` [PATCH v2 03/16] ArmPkg/StandaloneMmCoreEntryPoint: Swap to ArmMmuLib Bret Barkelew
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

Drop switch from the custom "StandaloneMmMmuLib" class to the
more generic "ArmMmuLib" class and add the missing functions
to fulfill that interface.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3647

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c   | 37 ++++++++++++++++++++
 ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  2 +-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
index 20f873e6802c..42216bf40ac7 100644
--- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
+++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
@@ -325,3 +325,40 @@ ArmClearMemoryRegionReadOnly (
   }
   return Status;
 }
+
+EFI_STATUS
+EFIAPI
+ArmConfigureMmu (
+  IN  ARM_MEMORY_REGION_DESCRIPTOR  *MemoryTable,
+  OUT VOID                          **TranslationTableBase OPTIONAL,
+  OUT UINTN                         *TranslationTableSize  OPTIONAL
+  )
+{
+  DEBUG ((DEBUG_ERROR, "%a() interface not implemented!\n", __FUNCTION__));
+  ASSERT (FALSE);
+  return EFI_UNSUPPORTED;
+}
+
+VOID
+EFIAPI
+ArmReplaceLiveTranslationEntry (
+  IN  UINT64  *Entry,
+  IN  UINT64  Value,
+  IN  UINT64  RegionStart
+  )
+{
+  DEBUG ((DEBUG_ERROR, "%a() interface not implemented!\n", __FUNCTION__));
+  ASSERT (FALSE);
+}
+
+EFI_STATUS
+ArmSetMemoryAttributes (
+  IN EFI_PHYSICAL_ADDRESS      BaseAddress,
+  IN UINT64                    Length,
+  IN UINT64                    Attributes
+  )
+{
+  DEBUG ((DEBUG_ERROR, "%a() interface not implemented!\n", __FUNCTION__));
+  ASSERT (FALSE);
+  return EFI_UNSUPPORTED;
+}
diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
index ff20e5898051..d34086853d32 100644
--- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
+++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
@@ -13,7 +13,7 @@ [Defines]
   FILE_GUID                      = 44a741c2-655f-41fc-b066-179f5a9aa78a
   MODULE_TYPE                    = MM_CORE_STANDALONE
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = StandaloneMmMmuLib
+  LIBRARY_CLASS                  = ArmMmuLib | MM_CORE_STANDALONE MM_STANDALONE
   PI_SPECIFICATION_VERSION       = 0x00010032
 
 [Sources]
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 03/16] ArmPkg/StandaloneMmCoreEntryPoint: Swap to ArmMmuLib
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 01/16] ArmPkg/ArmMmuBaseLib: Disallow STANDALONE_MM Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 02/16] ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 04/16] ArmPkg: Disavow StandaloneMmMmuLib. It's just ArmMmuLib Bret Barkelew
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Sami Mujawar, Jiewen Yao, Supreeth Venkatesh,
	Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

StandaloneMmMmuLib has been turned into an implementation of the
ArmMmuLib class (without any change to the interface itself), so
this module can now change its dependency.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3647

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index 75cfb98c0e75..a0629cbc1a6f 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -42,7 +42,7 @@ [LibraryClasses]
   DebugLib
 
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
-  StandaloneMmMmuLib
+  ArmMmuLib
   ArmSvcLib
 
 [Guids]
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 04/16] ArmPkg: Disavow StandaloneMmMmuLib. It's just ArmMmuLib
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (2 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 03/16] ArmPkg/StandaloneMmCoreEntryPoint: Swap to ArmMmuLib Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg Bret Barkelew
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

This extra interface is redundant and unnecessary. Dropping it is
more EDK2-ish.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3647

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
---
 ArmPkg/ArmPkg.dec                           |  4 ---
 ArmPkg/Include/Library/StandaloneMmMmuLib.h | 36 --------------------
 2 files changed, 40 deletions(-)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 9da1bbc9f216..f5c235ecc11b 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -88,10 +88,6 @@ [LibraryClasses.common]
   #
   SemihostLib|Include/Library/SemihostLib.h
 
-  ##  @libraryclass  Provides an interface for a StandaloneMm Mmu.
-  #
-  StandaloneMmMmuLib|Include/Library/StandaloneMmMmuLib.h
-
 [Guids.common]
   gArmTokenSpaceGuid       = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } }
 
diff --git a/ArmPkg/Include/Library/StandaloneMmMmuLib.h b/ArmPkg/Include/Library/StandaloneMmMmuLib.h
deleted file mode 100644
index ccc016d0350a..000000000000
--- a/ArmPkg/Include/Library/StandaloneMmMmuLib.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/** @file
-
-  Copyright (c) 2018, ARM Ltd. All rights reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef STANDALONE_MM_MMU_LIB_
-#define STANDALONE_MM_MMU_LIB_
-
-EFI_STATUS
-ArmSetMemoryRegionNoExec (
-  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
-  IN  UINT64                    Length
-  );
-
-EFI_STATUS
-ArmClearMemoryRegionNoExec (
-  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
-  IN  UINT64                    Length
-  );
-
-EFI_STATUS
-ArmSetMemoryRegionReadOnly (
-  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
-  IN  UINT64                    Length
-  );
-
-EFI_STATUS
-ArmClearMemoryRegionReadOnly (
-  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
-  IN  UINT64                    Length
-  );
-
-#endif /* STANDALONE_MM_MMU_LIB_ */
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (3 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 04/16] ArmPkg: Disavow StandaloneMmMmuLib. It's just ArmMmuLib Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-04 12:16   ` Leif Lindholm
  2021-11-02 20:17 ` [PATCH v2 06/16] ArmPkg and BaseTools: Move the GccLto binaries from ArmPkg to BaseTools Bret Barkelew
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel
  Cc: Leif Lindholm, Ard Biesheuvel, Michael D Kinney, Liming Gao,
	Zhiguang Liu, Sami Mujawar, Jiewen Yao, Supreeth Venkatesh,
	Maciej Rabeda, Jiaxin Wu, Siyuan Fu, Ray Ni, Zhichao Gao,
	Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

TODO: Might keep the name of the .inf. Pending discussion.

This aligns better with Mu's philosophy around dependency structuring
and is one of the steps to enable Basecore to have zero CI dependencies
on other Mu repos.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3649

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c                                                                        | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c                                                                           | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c                                                                        | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset.c                                                                           | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c                                                                        | 0
 ArmPkg/ArmPkg.dsc                                                                                                                   | 3 +--
 CryptoPkg/CryptoPkg.dsc                                                                                                             | 2 +-
 MdeModulePkg/MdeModulePkg.dsc                                                                                                       | 2 +-
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S                                                                  | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashldi3.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/clzsi2.S                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.S                                                                          | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.asm                                                                        | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divdi3.S                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divsi3.S                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.S                                                                         | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.asm                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm                                                                    | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.S                                                                         | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.asm                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.S                                                                         | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.asm                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.asm                                                                    | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/moddi3.S                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/modsi3.S                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/muldi3.S                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.S                                                                        | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.asm                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/sourcery.S                                                                     | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch.asm                                                                     | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch16.S                                                                     | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch32.S                                                                     | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch8.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switchu8.S                                                                     | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivdi3.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S                                                                   | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivsi3.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.S                                                                        | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.asm                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umoddi3.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umodsi3.S                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.S                                                                        | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.asm                                                                      | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.S                                                                       | 0
 {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.asm                                                                     | 0
 ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf => MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf | 3 +--
 MdePkg/MdePkg.dsc                                                                                                                   | 1 +
 NetworkPkg/NetworkPkg.dsc                                                                                                           | 2 +-
 ShellPkg/ShellPkg.dsc                                                                                                               | 2 +-
 StandaloneMmPkg/StandaloneMmPkg.dsc                                                                                                 | 2 +-
 UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc                                                                             | 2 +-
 58 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c b/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c b/MdePkg/Library/CompilerIntrinsicsLib/memcpy.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memcpy.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset.c b/MdePkg/Library/CompilerIntrinsicsLib/memset.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memset.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memset.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index 59fd8f295d4f..06ede068f99d 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -101,7 +101,7 @@ [LibraryClasses.common.PEIM]
   PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
 
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
-  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
 
   # Add support for GCC stack protector
   NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
@@ -109,7 +109,6 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
 [Components.common]
   ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
   ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
-  ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
   ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
   ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
   ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 0aa72ed87846..eab46e4b4fbc 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -74,7 +74,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
   # [LibraryClasses.ARM, LibraryClasses.AARCH64] and NULL mean link this library
   # into all ARM and AARCH64 images.
   #
-  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
 
   # Add support for stack protector
   NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index b1d83461865e..ab505f5bb2c6 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -183,7 +183,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
   # This library provides the instrinsic functions generated by a given compiler.
   # [LibraryClasses.ARM] and NULL mean link this library into all ARM images.
   #
-  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
 
   #
   # Since software stack checking may be heuristically enabled by the compiler
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S b/MdePkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S
rename to MdePkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/div.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/div.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/div.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/div.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switch.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch16.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switch16.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch16.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch16.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch32.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switch32.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch32.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch32.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch8.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switch8.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch8.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch8.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf b/MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
similarity index 93%
rename from ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
rename to MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
index fcf48c678119..46224f79ea85 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+++ b/MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
@@ -11,7 +11,7 @@
 
 [Defines]
   INF_VERSION                    = 0x00010005
-  BASE_NAME                      = CompilerIntrinsicsLib
+  BASE_NAME                      = ArmCompilerIntrinsicsLib
   FILE_GUID                      = 855274FA-3575-4C20-9709-C031DC5589FA
   MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
@@ -84,7 +84,6 @@ [Sources.AARCH64]
 
 [Packages]
   MdePkg/MdePkg.dec
-  ArmPkg/ArmPkg.dec
 
 [BuildOptions]
   MSFT:*_*_*_CC_FLAGS = /GL-
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index a94959169b2f..cb3907c88b4e 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -183,5 +183,6 @@ [Components.EBC]
 [Components.ARM, Components.AARCH64]
   MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicArmVirt.inf
   MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
+  MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
 
 [BuildOptions]
diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
index cf2164aefe25..1c727a9a4bf1 100644
--- a/NetworkPkg/NetworkPkg.dsc
+++ b/NetworkPkg/NetworkPkg.dsc
@@ -75,7 +75,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
   # This library provides the instrinsic functions generated by a given compiler.
   # [LibraryClasses.ARM] and NULL mean link this library into all ARM images.
   #
-  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
   NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
   ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
 
diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index 6f0d0929319d..25e8831bf36e 100644
--- a/ShellPkg/ShellPkg.dsc
+++ b/ShellPkg/ShellPkg.dsc
@@ -69,7 +69,7 @@ [LibraryClasses.ARM,LibraryClasses.AARCH64]
   # This library provides the instrinsic functions generate by a given compiler.
   # [LibraryClasses.ARM] and NULL mean link this library into all ARM images.
   #
-  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
 
   # Add support for GCC stack protector
   NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/StandaloneMmPkg.dsc
index 8012f93b7dcc..2c0c9396d633 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dsc
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -67,7 +67,7 @@ [LibraryClasses.AARCH64, LibraryClasses.ARM]
   CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
   PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
 
-  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
   NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
 
 [LibraryClasses.common.MM_CORE_STANDALONE]
diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc b/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
index 8adf690098ae..2bbf2398b7e9 100644
--- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
+++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
@@ -37,7 +37,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
   # This library provides the instrinsic functions generated by a given compiler.
   # [LibraryClasses.ARM] and NULL mean link this library into all ARM images.
   #
-  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
 
   #
   # Since software stack checking may be heuristically enabled by the compiler
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 06/16] ArmPkg and BaseTools: Move the GccLto binaries from ArmPkg to BaseTools
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (4 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 07/16] ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg Bret Barkelew
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel
  Cc: Leif Lindholm, Ard Biesheuvel, Bob Feng, Liming Gao, Yuwei Chen,
	Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

This aligns better with Mu's philosophy around dependency structuring
and is one of the steps to enable Basecore to have zero CI dependencies
on other Mu repos.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3650

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.a | Bin
 {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.s |   0
 {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.a     | Bin
 {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.s     |   0
 BaseTools/Conf/tools_def.template                         |  19 ++++++++++---------
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/ArmPkg/Library/GccLto/liblto-aarch64.a b/BaseTools/Bin/GccLto/liblto-aarch64.a
similarity index 100%
rename from ArmPkg/Library/GccLto/liblto-aarch64.a
rename to BaseTools/Bin/GccLto/liblto-aarch64.a
diff --git a/ArmPkg/Library/GccLto/liblto-aarch64.s b/BaseTools/Bin/GccLto/liblto-aarch64.s
similarity index 100%
rename from ArmPkg/Library/GccLto/liblto-aarch64.s
rename to BaseTools/Bin/GccLto/liblto-aarch64.s
diff --git a/ArmPkg/Library/GccLto/liblto-arm.a b/BaseTools/Bin/GccLto/liblto-arm.a
similarity index 100%
rename from ArmPkg/Library/GccLto/liblto-arm.a
rename to BaseTools/Bin/GccLto/liblto-arm.a
diff --git a/ArmPkg/Library/GccLto/liblto-arm.s b/BaseTools/Bin/GccLto/liblto-arm.s
similarity index 100%
rename from ArmPkg/Library/GccLto/liblto-arm.s
rename to BaseTools/Bin/GccLto/liblto-arm.s
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 2e6b382ab623..cd8899d24d4a 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -15,7 +15,8 @@
 # 2.00 - Initial version with changes for CI
 #      - Change RC path to use plugin
 #
-#!VERSION=2.00
+# 2.10 - Move GccLto files to a tools path to be more repository layout agnostic
+#!VERSION=2.10
 
 IDENTIFIER = Default TOOL_CHAIN_CONF
 
@@ -2386,10 +2387,10 @@ RELEASE_GCC5_X64_DLINK_FLAGS     = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os
 *_GCC5_ARM_CC_XIPFLAGS           = DEF(GCC5_ARM_CC_XIPFLAGS)
 
   DEBUG_GCC5_ARM_CC_FLAGS        = DEF(GCC5_ARM_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
-  DEBUG_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
+  DEBUG_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
 
 RELEASE_GCC5_ARM_CC_FLAGS        = DEF(GCC5_ARM_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
-RELEASE_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
+RELEASE_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
 
   NOOPT_GCC5_ARM_CC_FLAGS        = DEF(GCC5_ARM_CC_FLAGS) -O0
   NOOPT_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -O0
@@ -2420,11 +2421,11 @@ RELEASE_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKS
 *_GCC5_AARCH64_CC_XIPFLAGS       = DEF(GCC5_AARCH64_CC_XIPFLAGS)
 
   DEBUG_GCC5_AARCH64_CC_FLAGS    = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
-  DEBUG_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
+  DEBUG_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
   DEBUG_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
 
 RELEASE_GCC5_AARCH64_CC_FLAGS    = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
-RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
+RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
 RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
 
   NOOPT_GCC5_AARCH64_CC_FLAGS    = DEF(GCC5_AARCH64_CC_FLAGS) -O0
@@ -2681,11 +2682,11 @@ DEFINE CLANG38_ARM_DLINK_FLAGS   = DEF(CLANG38_ARM_TARGET) DEF(GCC_ARM_DLINK_FLA
 *_CLANG38_ARM_CC_XIPFLAGS        = DEF(GCC_ARM_CC_XIPFLAGS)
 
   DEBUG_CLANG38_ARM_CC_FLAGS     = DEF(CLANG38_ARM_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O1
-  DEBUG_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
+  DEBUG_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
   NOOPT_CLANG38_ARM_CC_FLAGS     = DEF(CLANG38_ARM_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -O0
   NOOPT_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS)
 RELEASE_CLANG38_ARM_CC_FLAGS     = DEF(CLANG38_ARM_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O3
-RELEASE_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
+RELEASE_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
 
 ##################
 # CLANG38 AARCH64 definitions
@@ -2727,11 +2728,11 @@ DEFINE CLANG38_AARCH64_DLINK_FLAGS  = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH6
 *_CLANG38_AARCH64_CC_XIPFLAGS    = DEF(GCC_AARCH64_CC_XIPFLAGS)
 
   DEBUG_CLANG38_AARCH64_CC_FLAGS    = DEF(CLANG38_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O1
-  DEBUG_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
+  DEBUG_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
   NOOPT_CLANG38_AARCH64_CC_FLAGS    = DEF(CLANG38_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -O0
   NOOPT_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS)
 RELEASE_CLANG38_AARCH64_CC_FLAGS    = DEF(CLANG38_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O3
-RELEASE_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
+RELEASE_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
 
 ####################################################################################
 #
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 07/16] ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (5 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 06/16] ArmPkg and BaseTools: Move the GccLto binaries from ArmPkg to BaseTools Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-04 12:17   ` Leif Lindholm
  2021-11-02 20:17 ` [PATCH v2 08/16] MdePkg: Create the MMU access lib to abstract memory protection settings Bret Barkelew
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel
  Cc: Leif Lindholm, Ard Biesheuvel, Michael D Kinney, Liming Gao,
	Zhiguang Liu, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 {ArmPkg/Include => MdePkg/Include/AArch64}/AsmMacroIoLibV8.h | 0
 {ArmPkg/Include => MdePkg/Include/Arm}/AsmMacroIoLib.h       | 0
 2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/MdePkg/Include/AArch64/AsmMacroIoLibV8.h
similarity index 100%
rename from ArmPkg/Include/AsmMacroIoLibV8.h
rename to MdePkg/Include/AArch64/AsmMacroIoLibV8.h
diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/MdePkg/Include/Arm/AsmMacroIoLib.h
similarity index 100%
rename from ArmPkg/Include/AsmMacroIoLib.h
rename to MdePkg/Include/Arm/AsmMacroIoLib.h
-- 
2.31.1.windows.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v2 08/16] MdePkg: Create the MMU access lib to abstract memory protection settings
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (6 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 07/16] ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 09/16] MdeModulePkg: Swap to MmuLib instead of Arm-specific lib Bret Barkelew
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel; +Cc: Michael D Kinney, Liming Gao, Zhiguang Liu, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

There are a number of Arm-specific accesses that are abstracted
behind this. It may need to be refactored to work better across
architectures.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.c   | 86 ++++++++++++++++++++
 MdePkg/Include/Library/MmuLib.h                  | 75 +++++++++++++++++
 MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf | 28 +++++++
 MdePkg/MdePkg.dec                                |  5 ++
 MdePkg/MdePkg.dsc                                |  2 +
 5 files changed, 196 insertions(+)

diff --git a/MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.c b/MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.c
new file mode 100644
index 000000000000..0398bc03f8f7
--- /dev/null
+++ b/MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.c
@@ -0,0 +1,86 @@
+/** @file
+This lib abstracts some of the MMU accesses currently hardcoded against
+an Arm lib. It's likely that this will need to be refactored at some point.
+
+Copyright (c) Microsoft Corporation.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/DebugLib.h>
+
+/**
+  Bitwise sets the memory attributes on a range of memory based on an attributes mask.
+
+  @param  BaseAddress           The start of the range for which to set attributes.
+  @param  Length                The length of the range.
+  @param  Attributes            A bitmask of the attributes to set. See "Physical memory
+                                protection attributes" in UefiSpec.h
+
+  @return EFI_SUCCESS
+  @return Others
+
+**/
+EFI_STATUS
+EFIAPI
+MmuSetAttributes (
+  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
+  IN  UINT64                    Length,
+  IN  UINT64                    Attributes
+  )
+{
+  DEBUG ((DEBUG_ERROR, "%a() NULL implementation used!\n", __FUNCTION__));
+  ASSERT (FALSE);
+  return EFI_UNSUPPORTED;
+}
+
+
+/**
+  Bitwise clears the memory attributes on a range of memory based on an attributes mask.
+
+  @param  BaseAddress           The start of the range for which to clear attributes.
+  @param  Length                The length of the range.
+  @param  Attributes            A bitmask of the attributes to clear. See "Physical memory
+                                protection attributes" in UefiSpec.h
+
+  @return EFI_SUCCESS
+  @return Others
+
+**/
+EFI_STATUS
+EFIAPI
+MmuClearAttributes (
+  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
+  IN  UINT64                    Length,
+  IN  UINT64                    Attributes
+  )
+{
+  DEBUG ((DEBUG_ERROR, "%a() NULL implementation used!\n", __FUNCTION__));
+  ASSERT (FALSE);
+  return EFI_UNSUPPORTED;
+}
+
+
+/**
+  Returns the memory attributes on a range of memory.
+
+  @param  BaseAddress           The start of the range for which to set attributes.
+  @param  Attributes            A return pointer for the attributes.
+
+  @return EFI_SUCCESS
+  @return EFI_INVALID_PARAMETER   A return pointer is NULL.
+  @return Others
+
+**/
+EFI_STATUS
+EFIAPI
+MmuGetAttributes (
+  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
+  OUT UINT64                    *Attributes
+  )
+{
+  DEBUG ((DEBUG_ERROR, "%a() NULL implementation used!\n", __FUNCTION__));
+  ASSERT (FALSE);
+  return EFI_UNSUPPORTED;
+}
diff --git a/MdePkg/Include/Library/MmuLib.h b/MdePkg/Include/Library/MmuLib.h
new file mode 100644
index 000000000000..170670f7d52a
--- /dev/null
+++ b/MdePkg/Include/Library/MmuLib.h
@@ -0,0 +1,75 @@
+/** @file
+This lib abstracts some of the MMU accesses currently hardcoded against
+an Arm lib. It's likely that this will need to be refactored at some point.
+
+Copyright (c) Microsoft Corporation.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _MMU_LIB_H_
+#define _MMU_LIB_H_
+
+#include <Uefi.h>
+
+/**
+  Bitwise sets the memory attributes on a range of memory based on an attributes mask.
+
+  @param  BaseAddress           The start of the range for which to set attributes.
+  @param  Length                The length of the range.
+  @param  Attributes            A bitmask of the attributes to set. See "Physical memory
+                                protection attributes" in UefiSpec.h
+
+  @return EFI_SUCCESS
+  @return Others
+
+**/
+EFI_STATUS
+EFIAPI
+MmuSetAttributes (
+  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
+  IN  UINT64                    Length,
+  IN  UINT64                    Attributes
+  );
+
+
+/**
+  Bitwise clears the memory attributes on a range of memory based on an attributes mask.
+
+  @param  BaseAddress           The start of the range for which to clear attributes.
+  @param  Length                The length of the range.
+  @param  Attributes            A bitmask of the attributes to clear. See "Physical memory
+                                protection attributes" in UefiSpec.h
+
+  @return EFI_SUCCESS
+  @return Others
+
+**/
+EFI_STATUS
+EFIAPI
+MmuClearAttributes (
+  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
+  IN  UINT64                    Length,
+  IN  UINT64                    Attributes
+  );
+
+
+/**
+  Returns the memory attributes on a range of memory.
+
+  @param  BaseAddress           The start of the range for which to set attributes.
+  @param  Attributes            A return pointer for the attributes.
+
+  @return EFI_SUCCESS
+  @return EFI_INVALID_PARAMETER   A return pointer is NULL.
+  @return Others
+
+**/
+EFI_STATUS
+EFIAPI
+MmuGetAttributes (
+  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
+  OUT UINT64                    *Attributes
+  );
+
+#endif // _MMU_LIB_H_
diff --git a/MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf b/MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf
new file mode 100644
index 000000000000..9f1b4422cc04
--- /dev/null
+++ b/MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf
@@ -0,0 +1,28 @@
+## @file
+# This lib abstracts some of the MMU accesses currently hardcoded against
+# an Arm lib. It's likely that this will need to be refactored at some point.
+#
+# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+
+[Defines]
+  INF_VERSION         = 0x00010017
+  BASE_NAME           = BaseMmuLibNull
+  FILE_GUID           = 97196A48-00C0-4487-802A-CC5540583EEB
+  VERSION_STRING      = 1.0
+  MODULE_TYPE         = BASE
+  LIBRARY_CLASS       = MmuLib
+
+
+[Sources]
+  BaseMmuLibNull.c
+
+
+[LibraryClasses]
+  DebugLib
+
+
+[Packages]
+  MdePkg/MdePkg.dec
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 8b18415b107a..43ad9726bf7f 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -267,6 +267,11 @@ [LibraryClasses]
   #
   RegisterFilterLib|Include/Library/RegisterFilterLib.h
 
+  ##  @libraryclass This lib abstracts some of the MMU accesses currently hardcoded against
+  #                 an Arm lib. It's likely that this will need to be refactored at some point.
+  #
+  MmuLib|Include/Library/MmuLib.h
+
 [LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64]
   ##  @libraryclass  Provides services to generate random number.
   #
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index cb3907c88b4e..a9c67b72e4e0 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -131,6 +131,8 @@ [Components]
 
   MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf
 
+  MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf
+
 [Components.IA32, Components.X64, Components.ARM, Components.AARCH64]
   #
   # Add UEFI Target Based Unit Tests
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 09/16] MdeModulePkg: Swap to MmuLib instead of Arm-specific lib
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (7 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 08/16] MdePkg: Create the MMU access lib to abstract memory protection settings Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 10/16] StandaloneMmPkg: Switch to the MmuLib abstraction Bret Barkelew
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel; +Cc: Jian J Wang, Liming Gao, Dandan Bi, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 MdeModulePkg/Core/DxeIplPeim/Arm/DxeLoadFunc.c | 4 ++--
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf        | 4 +---
 MdeModulePkg/MdeModulePkg.dsc                  | 3 +--
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/Arm/DxeLoadFunc.c b/MdeModulePkg/Core/DxeIplPeim/Arm/DxeLoadFunc.c
index 6619a650661b..16c20930a662 100644
--- a/MdeModulePkg/Core/DxeIplPeim/Arm/DxeLoadFunc.c
+++ b/MdeModulePkg/Core/DxeIplPeim/Arm/DxeLoadFunc.c
@@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include "DxeIpl.h"
 
-#include <Library/ArmMmuLib.h>
+#include <Library/MmuLib.h>
 
 /**
    Transfers control to DxeCore.
@@ -40,7 +40,7 @@ HandOffToDxeCore (
   ASSERT (BaseOfStack != NULL);
 
   if (PcdGetBool (PcdSetNxForStack)) {
-    Status = ArmSetMemoryRegionNoExec ((UINTN)BaseOfStack, STACK_SIZE);
+    Status = MmuSetAttributes ((UINTN)BaseOfStack, STACK_SIZE, EFI_MEMORY_XP);
     ASSERT_EFI_ERROR (Status);
   }
 
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index 19b8a4c8aefa..3634d836548f 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -57,8 +57,6 @@ [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
 
-[Packages.ARM, Packages.AARCH64]
-  ArmPkg/ArmPkg.dec
 
 [LibraryClasses]
   PcdLib
@@ -77,7 +75,7 @@ [LibraryClasses]
   PerformanceLib
 
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
-  ArmMmuLib
+  MmuLib
 
 [Ppis]
   gEfiDxeIplPpiGuid                      ## PRODUCES
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index ab505f5bb2c6..20790145d5bf 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -103,6 +103,7 @@ [LibraryClasses]
   DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf
   VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
   MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
+  MmuLib|MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf
 
 [LibraryClasses.EBC.PEIM]
   IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
@@ -174,8 +175,6 @@ [LibraryClasses.common.MM_STANDALONE]
   MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
 
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
-  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
-  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
   LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
 
   #
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 10/16] StandaloneMmPkg: Switch to the MmuLib abstraction
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (8 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 09/16] MdeModulePkg: Swap to MmuLib instead of Arm-specific lib Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon Bret Barkelew
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Sami Mujawar, Jiewen Yao, Supreeth Venkatesh,
	Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (9 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 10/16] StandaloneMmPkg: Switch to the MmuLib abstraction Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-04 12:43   ` Leif Lindholm
  2021-11-02 20:17 ` [PATCH v2 12/16] ArmPkg: Move the StandaloneMmCpu driver to ArmPkg Bret Barkelew
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Sean Brogan

From: Sean Brogan <sean.brogan@microsoft.com>

The previously Arm-specific "ArmMmuLib" has been generalized
as "MmuLib". The Arm implementation of this lib can still use
the existing library logic to back it.

As such, this implementation is currently just a shim to the
old library, while enabling higher-level code to be more
common.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 ArmPkg/Library/MmuLib/MmuLib.c       | 120 ++++++++++++++++++++
 ArmPkg/ArmPkg.dsc                    |   1 +
 ArmPkg/Library/MmuLib/BaseMmuLib.inf |  30 +++++
 3 files changed, 151 insertions(+)

diff --git a/ArmPkg/Library/MmuLib/MmuLib.c b/ArmPkg/Library/MmuLib/MmuLib.c
new file mode 100644
index 000000000000..70840c26f489
--- /dev/null
+++ b/ArmPkg/Library/MmuLib/MmuLib.c
@@ -0,0 +1,120 @@
+/** @file
+This library instance implements a very limited MMU Lib instance
+for the ARM/AARCH64 architectures.  This library shims a common library
+interface to the ArmPkg defined ArmMmuLib.ib.
+
+Copyright (c) Microsoft Corporation.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/ArmMmuLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MmuLib.h>
+
+/**
+  Bitwise sets the memory attributes on a range of memory based on an attributes mask.
+
+  @param  BaseAddress           The start of the range for which to set attributes.
+  @param  Length                The length of the range.
+  @param  Attributes            A bitmask of the attributes to set. See "Physical memory
+                                protection attributes" in UefiSpec.h
+
+  @return EFI_SUCCESS
+  @return Others
+
+**/
+EFI_STATUS
+EFIAPI
+MmuSetAttributes (
+  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
+  IN  UINT64                    Length,
+  IN  UINT64                    Attributes
+  )
+  {
+    EFI_STATUS Status;
+
+    Status = EFI_UNSUPPORTED;
+
+    if (Attributes & EFI_MEMORY_XP) {
+      Status = ArmSetMemoryRegionNoExec (BaseAddress, Length);
+      if (EFI_ERROR(Status)) {
+        DEBUG((DEBUG_ERROR, "%a - Failed to set NX.  Status = %r\n", __FUNCTION__, Status));
+      }
+    }
+
+    ASSERT_EFI_ERROR(Status);
+    return Status;
+  }
+
+
+/**
+  Bitwise clears the memory attributes on a range of memory based on an attributes mask.
+
+  @param  BaseAddress           The start of the range for which to clear attributes.
+  @param  Length                The length of the range.
+  @param  Attributes            A bitmask of the attributes to clear. See "Physical memory
+                                protection attributes" in UefiSpec.h
+
+  @return EFI_SUCCESS
+  @return Others
+
+**/
+EFI_STATUS
+EFIAPI
+MmuClearAttributes (
+  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
+  IN  UINT64                    Length,
+  IN  UINT64                    Attributes
+  )
+  {
+    EFI_STATUS Status;
+
+    Status = EFI_UNSUPPORTED;
+
+    if (Attributes & EFI_MEMORY_XP) {
+      Status = ArmClearMemoryRegionNoExec (BaseAddress, Length);
+      if (EFI_ERROR(Status)) {
+        DEBUG((DEBUG_ERROR, "%a - Failed to clear NX.  Status = %r\n", __FUNCTION__, Status));
+      }
+    }
+
+    if (Attributes & EFI_MEMORY_RO) {
+      Status = ArmClearMemoryRegionReadOnly(BaseAddress, Length);
+      if (EFI_ERROR(Status)) {
+        DEBUG((DEBUG_ERROR, "%a - Failed to clear RO.  Status = %r\n", __FUNCTION__, Status));
+      }
+    }
+
+    ASSERT_EFI_ERROR(Status);
+    return Status;
+  }
+
+
+/**
+  Returns the memory attributes on a range of memory.
+
+  @param  BaseAddress           The start of the range for which to set attributes.
+  @param  Attributes            A return pointer for the attributes.
+
+  @return EFI_SUCCESS
+  @return EFI_INVALID_PARAMETER   A return pointer is NULL.
+  @return Others
+
+**/
+EFI_STATUS
+EFIAPI
+MmuGetAttributes (
+  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
+  OUT UINT64                    *Attributes
+  )
+  {
+    EFI_STATUS Status;
+
+    Status = EFI_UNSUPPORTED;
+
+    DEBUG ((DEBUG_ERROR, "%a() API not implemented\n", __FUNCTION__));
+
+    ASSERT_EFI_ERROR(Status);
+    return Status;
+  }
diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index 06ede068f99d..cbc67daa7696 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -165,3 +165,4 @@ [Components.AARCH64]
 
 [Components.AARCH64, Components.ARM]
   ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
+  ArmPkg/Library/MmuLib/BaseMmuLib.inf
diff --git a/ArmPkg/Library/MmuLib/BaseMmuLib.inf b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
new file mode 100644
index 000000000000..15095abee9c3
--- /dev/null
+++ b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
@@ -0,0 +1,30 @@
+## @file
+# This library instance implements a very limited MMU Lib instance
+# for the ARM/AARCH64 architectures.  This library shims a common library
+# interface to the ArmPkg defined ArmMmuLib.
+#
+# Copyright (c) Microsoft Corporation.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = MmuLib
+  FILE_GUID                      = 6f2ee9a4-79b3-4b77-9a47-e2bd4b917b75
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = MmuLib
+
+[Sources]
+  MmuLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  ArmPkg/ArmPkg.dec
+
+[LibraryClasses]
+  DebugLib
+  ArmMmuLib
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 12/16] ArmPkg: Move the StandaloneMmCpu driver to ArmPkg
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (10 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 13/16] ArmPkg: Move the StandaloneMmCoreEntryPoint lib " Bret Barkelew
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel
  Cc: Leif Lindholm, Ard Biesheuvel, Sami Mujawar, Jiewen Yao,
	Supreeth Venkatesh, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

This aligns better with Mu's philosophy around dependency structuring
and is one of the steps to enable Basecore to have zero CI dependencies
on other Mu repos.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3652

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/EventHandle.c       | 0
 {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.c   | 0
 {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.h   | 0
 {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf | 0
 4 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c b/ArmPkg/Drivers/StandaloneMmCpu/EventHandle.c
similarity index 100%
rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c
rename to ArmPkg/Drivers/StandaloneMmCpu/EventHandle.c
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c b/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c
similarity index 100%
rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c
rename to ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h b/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h
similarity index 100%
rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h
rename to ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf b/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf
similarity index 100%
rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf
rename to ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf
-- 
2.31.1.windows.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v2 13/16] ArmPkg: Move the StandaloneMmCoreEntryPoint lib to ArmPkg
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (11 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 12/16] ArmPkg: Move the StandaloneMmCpu driver to ArmPkg Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 14/16] ArmPkg/Library: Convert StandaloneMmCoreEntryPoint to Arm-only Bret Barkelew
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel
  Cc: Leif Lindholm, Ard Biesheuvel, Sami Mujawar, Jiewen Yao,
	Supreeth Venkatesh, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

This aligns better with Mu's philosophy around dependency structuring
and is one of the steps to enable Basecore to have zero CI dependencies
on other Mu repos.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3652

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c              | 0
 {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c             | 0
 {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 0
 {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c | 0
 ArmPkg/ArmPkg.ci.yaml                                                                           | 3 ++-
 ArmPkg/ArmPkg.dsc                                                                               | 3 +++
 {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf   | 0
 7 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c b/ArmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
similarity index 100%
rename from StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
rename to ArmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c b/ArmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c
similarity index 100%
rename from StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c
rename to ArmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/ArmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
similarity index 100%
rename from StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
rename to ArmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c b/ArmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c
similarity index 100%
rename from StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c
rename to ArmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c
diff --git a/ArmPkg/ArmPkg.ci.yaml b/ArmPkg/ArmPkg.ci.yaml
index a0d6a75fe881..de6926c82e67 100644
--- a/ArmPkg/ArmPkg.ci.yaml
+++ b/ArmPkg/ArmPkg.ci.yaml
@@ -46,7 +46,8 @@
             "EmbeddedPkg/EmbeddedPkg.dec",
             "MdeModulePkg/MdeModulePkg.dec",
             "MdePkg/MdePkg.dec",
-            "ShellPkg/ShellPkg.dec"
+            "ShellPkg/ShellPkg.dec",
+            "StandaloneMmPkg/StandaloneMmPkg.dec"
         ],
         # For host based unit tests
         "AcceptableDependencies-HOST_APPLICATION":[
diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index cbc67daa7696..4741a93f609a 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -159,6 +159,9 @@ [Components.common]
   ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
   ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLibNull.inf
 
+  ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf
+  ArmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+
 [Components.AARCH64]
   ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
   ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/ArmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
similarity index 100%
rename from StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
rename to ArmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 14/16] ArmPkg/Library: Convert StandaloneMmCoreEntryPoint to Arm-only
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (12 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 13/16] ArmPkg: Move the StandaloneMmCoreEntryPoint lib " Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 15/16] ArmPkg/ArmPkg.dsc: Resolve build errors resulting from package moves Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 16/16] ArmPlatformPkg: " Bret Barkelew
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel
  Cc: Leif Lindholm, Ard Biesheuvel, Sami Mujawar, Jiewen Yao,
	Supreeth Venkatesh, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

Drop X64 references. Update GUID.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3652

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 ArmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c | 71 --------------------
 ArmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf   |  6 +-
 2 files changed, 2 insertions(+), 75 deletions(-)

diff --git a/ArmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c b/ArmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c
deleted file mode 100644
index dffa965b8425..000000000000
--- a/ArmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/** @file
-  Entry point to the Standalone Mm Core.
-
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
-Copyright (c) Microsoft Corporation.
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-
-#include <PiMm.h>
-
-#include <Library/StandaloneMmCoreEntryPoint.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseLib.h>
-
-//
-// Cache copy of HobList pointer.
-//
-VOID *gHobList = NULL;
-
-/**
-  The entry point of PE/COFF Image for the STANDALONE MM Core.
-
-  This function is the entry point for the STANDALONE MM Core. This function is required to call
-  ProcessModuleEntryPointList() and ProcessModuleEntryPointList() is never expected to return.
-  The STANDALONE MM Core is responsible for calling ProcessLibraryConstructorList() as soon as the EFI
-  System Table and the image handle for the STANDALONE MM Core itself have been established.
-  If ProcessModuleEntryPointList() returns, then ASSERT() and halt the system.
-
-  @param  HobStart  Pointer to the beginning of the HOB List passed in from the PEI Phase.
-
-**/
-VOID
-EFIAPI
-_ModuleEntryPoint (
-  IN VOID  *HobStart
-  )
-{
-  //
-  // Cache a pointer to the HobList
-  //
-  gHobList = HobStart;
-
-  //
-  // Call the Standalone MM Core entry point
-  //
-  ProcessModuleEntryPointList (HobStart);
-
-  //
-  // TODO: Set page table here?? AARCH64 has this step for some reason
-  //
-}
-
-
-/**
-  Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
-
-  This function is required to call _ModuleEntryPoint() passing in HobStart.
-
-  @param  HobStart  Pointer to the beginning of the HOB List passed in from the PEI Phase.
-
-**/
-VOID
-EFIAPI
-EfiMain (
-  IN VOID  *HobStart
-  )
-{
-  _ModuleEntryPoint (HobStart);
-}
diff --git a/ArmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/ArmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index a0629cbc1a6f..c6b283653882 100644
--- a/ArmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ b/ArmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -10,8 +10,8 @@
 
 [Defines]
   INF_VERSION                    = 0x0001001A
-  BASE_NAME                      = StandaloneMmCoreEntryPoint
-  FILE_GUID                      = C97AC593-109A-4C63-905C-675FDE2689E8
+  BASE_NAME                      = ArmStandaloneMmCoreEntryPoint
+  FILE_GUID                      = 0D7C6883-E1A8-4A7A-A35C-E0C200775B43
   MODULE_TYPE                    = MM_CORE_STANDALONE
   VERSION_STRING                 = 1.0
   PI_SPECIFICATION_VERSION       = 0x00010032
@@ -26,8 +26,6 @@ [Sources.AARCH64, Sources.ARM]
   Arm/SetPermissions.c
   Arm/CreateHobList.c
 
-[Sources.X64]
-  X64/StandaloneMmCoreEntryPoint.c
 
 [Packages]
   MdePkg/MdePkg.dec
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 15/16] ArmPkg/ArmPkg.dsc: Resolve build errors resulting from package moves
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (13 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 14/16] ArmPkg/Library: Convert StandaloneMmCoreEntryPoint to Arm-only Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-02 20:17 ` [PATCH v2 16/16] ArmPlatformPkg: " Bret Barkelew
  15 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3652

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 ArmPkg/ArmPkg.dsc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index 4741a93f609a..add19f7db163 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -93,6 +93,8 @@ [LibraryClasses.common]
 
   OemMiscLib|ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLibNull.inf
 
+  ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
+
 [LibraryClasses.common.PEIM]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
   PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
@@ -106,6 +108,12 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
   # Add support for GCC stack protector
   NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
 
+[LibraryClasses.common.MM_STANDALONE]
+  HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
+  MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
+  MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
+  StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
+
 [Components.common]
   ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
   ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 16/16] ArmPlatformPkg: Resolve build errors resulting from package moves
  2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
                   ` (14 preceding siblings ...)
  2021-11-02 20:17 ` [PATCH v2 15/16] ArmPkg/ArmPkg.dsc: Resolve build errors resulting from package moves Bret Barkelew
@ 2021-11-02 20:17 ` Bret Barkelew
  2021-11-06  9:50   ` [edk2-devel] " Marvin Häuser
  15 siblings, 1 reply; 25+ messages in thread
From: Bret Barkelew @ 2021-11-02 20:17 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Sean Brogan

From: Bret Barkelew <brbarkel@microsoft.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3652

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
---
 ArmPlatformPkg/ArmPlatformPkg.dsc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc
index 661a4cea220d..3ed0bae87c41 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
@@ -79,6 +79,8 @@ [LibraryClasses.common]
   NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
   NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
 
+  ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
+
 [LibraryClasses.common.PEIM]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
   MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
@@ -92,7 +94,7 @@ [LibraryClasses.common.SEC]
   MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
   PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
 
-[LibraryClasses.AARCH64.MM_STANDALONE]
+[LibraryClasses.common.MM_STANDALONE]
   HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
   MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
   MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 02/16] ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib
  2021-11-02 20:17 ` [PATCH v2 02/16] ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib Bret Barkelew
@ 2021-11-04 12:14   ` Leif Lindholm
  0 siblings, 0 replies; 25+ messages in thread
From: Leif Lindholm @ 2021-11-04 12:14 UTC (permalink / raw)
  To: brbarkel@microsoft.com; +Cc: devel, Ard Biesheuvel, Sean Brogan

On Tue, Nov 02, 2021 at 13:17:34 -0700, brbarkel@microsoft.com wrote:
> From: Bret Barkelew <brbarkel@microsoft.com>
> 
> Drop switch from the custom "StandaloneMmMmuLib" class to the
> more generic "ArmMmuLib" class and add the missing functions
> to fulfill that interface.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3647
> 
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>

Reviewed-by: Leif Lindholm <leif@nuviainc.com>

> ---
>  ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c   | 37 ++++++++++++++++++++
>  ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf |  2 +-
>  2 files changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
> index 20f873e6802c..42216bf40ac7 100644
> --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
> +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
> @@ -325,3 +325,40 @@ ArmClearMemoryRegionReadOnly (
>    }
>    return Status;
>  }
> +
> +EFI_STATUS
> +EFIAPI
> +ArmConfigureMmu (
> +  IN  ARM_MEMORY_REGION_DESCRIPTOR  *MemoryTable,
> +  OUT VOID                          **TranslationTableBase OPTIONAL,
> +  OUT UINTN                         *TranslationTableSize  OPTIONAL
> +  )
> +{
> +  DEBUG ((DEBUG_ERROR, "%a() interface not implemented!\n", __FUNCTION__));
> +  ASSERT (FALSE);
> +  return EFI_UNSUPPORTED;
> +}
> +
> +VOID
> +EFIAPI
> +ArmReplaceLiveTranslationEntry (
> +  IN  UINT64  *Entry,
> +  IN  UINT64  Value,
> +  IN  UINT64  RegionStart
> +  )
> +{
> +  DEBUG ((DEBUG_ERROR, "%a() interface not implemented!\n", __FUNCTION__));
> +  ASSERT (FALSE);
> +}
> +
> +EFI_STATUS
> +ArmSetMemoryAttributes (
> +  IN EFI_PHYSICAL_ADDRESS      BaseAddress,
> +  IN UINT64                    Length,
> +  IN UINT64                    Attributes
> +  )
> +{
> +  DEBUG ((DEBUG_ERROR, "%a() interface not implemented!\n", __FUNCTION__));
> +  ASSERT (FALSE);
> +  return EFI_UNSUPPORTED;
> +}
> diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> index ff20e5898051..d34086853d32 100644
> --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> @@ -13,7 +13,7 @@ [Defines]
>    FILE_GUID                      = 44a741c2-655f-41fc-b066-179f5a9aa78a
>    MODULE_TYPE                    = MM_CORE_STANDALONE
>    VERSION_STRING                 = 1.0
> -  LIBRARY_CLASS                  = StandaloneMmMmuLib
> +  LIBRARY_CLASS                  = ArmMmuLib | MM_CORE_STANDALONE MM_STANDALONE
>    PI_SPECIFICATION_VERSION       = 0x00010032
>  
>  [Sources]
> -- 
> 2.31.1.windows.1
> 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg
  2021-11-02 20:17 ` [PATCH v2 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg Bret Barkelew
@ 2021-11-04 12:16   ` Leif Lindholm
  0 siblings, 0 replies; 25+ messages in thread
From: Leif Lindholm @ 2021-11-04 12:16 UTC (permalink / raw)
  To: brbarkel@microsoft.com
  Cc: devel, Ard Biesheuvel, Michael D Kinney, Liming Gao, Zhiguang Liu,
	Sami Mujawar, Jiewen Yao, Supreeth Venkatesh, Maciej Rabeda,
	Jiaxin Wu, Siyuan Fu, Ray Ni, Zhichao Gao, Sean Brogan

On Tue, Nov 02, 2021 at 13:17:37 -0700, brbarkel@microsoft.com wrote:
> From: Bret Barkelew <brbarkel@microsoft.com>
> 
> TODO: Might keep the name of the .inf. Pending discussion.

Seems a yes on that.
If so:
Reviewed-by: Leif Lindholm <leif@nuviainc.com>


> This aligns better with Mu's philosophy around dependency structuring
> and is one of the steps to enable Basecore to have zero CI dependencies
> on other Mu repos.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3649
> 
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
> Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
> ---
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c                                                                        | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c                                                                           | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c                                                                        | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset.c                                                                           | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c                                                                        | 0
>  ArmPkg/ArmPkg.dsc                                                                                                                   | 3 +--
>  CryptoPkg/CryptoPkg.dsc                                                                                                             | 2 +-
>  MdeModulePkg/MdeModulePkg.dsc                                                                                                       | 2 +-
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S                                                                  | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashldi3.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/clzsi2.S                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.S                                                                          | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.asm                                                                        | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divdi3.S                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divsi3.S                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.S                                                                         | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.asm                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm                                                                    | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.S                                                                         | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.asm                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.S                                                                         | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.asm                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.asm                                                                    | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/moddi3.S                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/modsi3.S                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/muldi3.S                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.S                                                                        | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.asm                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/sourcery.S                                                                     | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch.asm                                                                     | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch16.S                                                                     | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch32.S                                                                     | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch8.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switchu8.S                                                                     | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivdi3.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S                                                                   | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivsi3.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.S                                                                        | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.asm                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umoddi3.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umodsi3.S                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.S                                                                        | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.asm                                                                      | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.S                                                                       | 0
>  {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.asm                                                                     | 0
>  ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf => MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf | 3 +--
>  MdePkg/MdePkg.dsc                                                                                                                   | 1 +
>  NetworkPkg/NetworkPkg.dsc                                                                                                           | 2 +-
>  ShellPkg/ShellPkg.dsc                                                                                                               | 2 +-
>  StandaloneMmPkg/StandaloneMmPkg.dsc                                                                                                 | 2 +-
>  UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc                                                                             | 2 +-
>  58 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c b/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
> rename to MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c b/MdePkg/Library/CompilerIntrinsicsLib/memcpy.c
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
> rename to MdePkg/Library/CompilerIntrinsicsLib/memcpy.c
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
> rename to MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
> rename to MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset.c b/MdePkg/Library/CompilerIntrinsicsLib/memset.c
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/memset.c
> rename to MdePkg/Library/CompilerIntrinsicsLib/memset.c
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
> rename to MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
> diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
> index 59fd8f295d4f..06ede068f99d 100644
> --- a/ArmPkg/ArmPkg.dsc
> +++ b/ArmPkg/ArmPkg.dsc
> @@ -101,7 +101,7 @@ [LibraryClasses.common.PEIM]
>    PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>  
>  [LibraryClasses.ARM, LibraryClasses.AARCH64]
> -  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> +  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
>  
>    # Add support for GCC stack protector
>    NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
> @@ -109,7 +109,6 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
>  [Components.common]
>    ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
>    ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
> -  ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
>    ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
>    ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
>    ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
> diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
> index 0aa72ed87846..eab46e4b4fbc 100644
> --- a/CryptoPkg/CryptoPkg.dsc
> +++ b/CryptoPkg/CryptoPkg.dsc
> @@ -74,7 +74,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
>    # [LibraryClasses.ARM, LibraryClasses.AARCH64] and NULL mean link this library
>    # into all ARM and AARCH64 images.
>    #
> -  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> +  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
>  
>    # Add support for stack protector
>    NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
> diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
> index b1d83461865e..ab505f5bb2c6 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -183,7 +183,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
>    # This library provides the instrinsic functions generated by a given compiler.
>    # [LibraryClasses.ARM] and NULL mean link this library into all ARM images.
>    #
> -  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> +  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
>  
>    #
>    # Since software stack checking may be heuristically enabled by the compiler
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S b/MdePkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/div.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/div.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/div.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switch.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch16.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switch16.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch16.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch16.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch32.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switch32.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch32.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch32.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch8.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switch8.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch8.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch8.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm b/MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm
> similarity index 100%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm
> rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm
> diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf b/MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
> similarity index 93%
> rename from ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> rename to MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
> index fcf48c678119..46224f79ea85 100644
> --- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> +++ b/MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
> @@ -11,7 +11,7 @@
>  
>  [Defines]
>    INF_VERSION                    = 0x00010005
> -  BASE_NAME                      = CompilerIntrinsicsLib
> +  BASE_NAME                      = ArmCompilerIntrinsicsLib
>    FILE_GUID                      = 855274FA-3575-4C20-9709-C031DC5589FA
>    MODULE_TYPE                    = BASE
>    VERSION_STRING                 = 1.0
> @@ -84,7 +84,6 @@ [Sources.AARCH64]
>  
>  [Packages]
>    MdePkg/MdePkg.dec
> -  ArmPkg/ArmPkg.dec
>  
>  [BuildOptions]
>    MSFT:*_*_*_CC_FLAGS = /GL-
> diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
> index a94959169b2f..cb3907c88b4e 100644
> --- a/MdePkg/MdePkg.dsc
> +++ b/MdePkg/MdePkg.dsc
> @@ -183,5 +183,6 @@ [Components.EBC]
>  [Components.ARM, Components.AARCH64]
>    MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicArmVirt.inf
>    MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
> +  MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
>  
>  [BuildOptions]
> diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
> index cf2164aefe25..1c727a9a4bf1 100644
> --- a/NetworkPkg/NetworkPkg.dsc
> +++ b/NetworkPkg/NetworkPkg.dsc
> @@ -75,7 +75,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
>    # This library provides the instrinsic functions generated by a given compiler.
>    # [LibraryClasses.ARM] and NULL mean link this library into all ARM images.
>    #
> -  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> +  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
>    NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
>    ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
>  
> diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
> index 6f0d0929319d..25e8831bf36e 100644
> --- a/ShellPkg/ShellPkg.dsc
> +++ b/ShellPkg/ShellPkg.dsc
> @@ -69,7 +69,7 @@ [LibraryClasses.ARM,LibraryClasses.AARCH64]
>    # This library provides the instrinsic functions generate by a given compiler.
>    # [LibraryClasses.ARM] and NULL mean link this library into all ARM images.
>    #
> -  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> +  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
>  
>    # Add support for GCC stack protector
>    NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
> diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/StandaloneMmPkg.dsc
> index 8012f93b7dcc..2c0c9396d633 100644
> --- a/StandaloneMmPkg/StandaloneMmPkg.dsc
> +++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
> @@ -67,7 +67,7 @@ [LibraryClasses.AARCH64, LibraryClasses.ARM]
>    CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
>    PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
>  
> -  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> +  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
>    NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
>  
>  [LibraryClasses.common.MM_CORE_STANDALONE]
> diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc b/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
> index 8adf690098ae..2bbf2398b7e9 100644
> --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
> +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
> @@ -37,7 +37,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
>    # This library provides the instrinsic functions generated by a given compiler.
>    # [LibraryClasses.ARM] and NULL mean link this library into all ARM images.
>    #
> -  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
> +  NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
>  
>    #
>    # Since software stack checking may be heuristically enabled by the compiler
> -- 
> 2.31.1.windows.1
> 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 07/16] ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg
  2021-11-02 20:17 ` [PATCH v2 07/16] ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg Bret Barkelew
@ 2021-11-04 12:17   ` Leif Lindholm
  2021-11-05  5:12     ` 回复: [edk2-devel] " gaoliming
  0 siblings, 1 reply; 25+ messages in thread
From: Leif Lindholm @ 2021-11-04 12:17 UTC (permalink / raw)
  To: brbarkel@microsoft.com
  Cc: devel, Ard Biesheuvel, Michael D Kinney, Liming Gao, Zhiguang Liu,
	Sean Brogan

On Tue, Nov 02, 2021 at 13:17:39 -0700, brbarkel@microsoft.com wrote:
> From: Bret Barkelew <brbarkel@microsoft.com>
> 
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>

For the moving out part:
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Need one of the MdePkg maintainers to acknowledge the moving in
part.

/
    Leif

> ---
>  {ArmPkg/Include => MdePkg/Include/AArch64}/AsmMacroIoLibV8.h | 0
>  {ArmPkg/Include => MdePkg/Include/Arm}/AsmMacroIoLib.h       | 0
>  2 files changed, 0 insertions(+), 0 deletions(-)
> 
> diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/MdePkg/Include/AArch64/AsmMacroIoLibV8.h
> similarity index 100%
> rename from ArmPkg/Include/AsmMacroIoLibV8.h
> rename to MdePkg/Include/AArch64/AsmMacroIoLibV8.h
> diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/MdePkg/Include/Arm/AsmMacroIoLib.h
> similarity index 100%
> rename from ArmPkg/Include/AsmMacroIoLib.h
> rename to MdePkg/Include/Arm/AsmMacroIoLib.h
> -- 
> 2.31.1.windows.1
> 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon
  2021-11-02 20:17 ` [PATCH v2 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon Bret Barkelew
@ 2021-11-04 12:43   ` Leif Lindholm
  2021-11-10 20:39     ` Bret Barkelew
  0 siblings, 1 reply; 25+ messages in thread
From: Leif Lindholm @ 2021-11-04 12:43 UTC (permalink / raw)
  To: brbarkel@microsoft.com; +Cc: devel, Ard Biesheuvel, Sean Brogan

On Tue, Nov 02, 2021 at 13:17:43 -0700, brbarkel@microsoft.com wrote:
> From: Sean Brogan <sean.brogan@microsoft.com>
> 
> The previously Arm-specific "ArmMmuLib" has been generalized
> as "MmuLib". The Arm implementation of this lib can still use
> the existing library logic to back it.
> 
> As such, this implementation is currently just a shim to the
> old library, while enabling higher-level code to be more
> common.

This commit message still required me to go and cross refecence a few
patches to (I think) understand what's going on.
(not least because it relies on a patch to MdePkg which I wasn't cc:d
on, so hadn't spotted.)

Correct me if I've got this wrong, but here's my theory:
- 8/16 adds a library class that currently basically amounts to an
  unabstracted version of ArmMmuLib, but in MdePkg, minus the Arm
  prefixes.
- 9/16 switches MdeModulePkg to use the new MmuLib instead of
  ArmMmuLib.
- 10/16 does the same for StandaloneMmPkg.
- 11/16 adds an actual implementation of this library class under
  ArmPkg - backed by ArmMmuLib.

If that's accurate...

Starting with the commit message - could we reduce the use of passive
voice a bit? Suggestion:

---
After adding the abstract MmuLib to MdePkg, add an implementation
backed by the existing ArmMmuLib to ArmPkg.
---

While not required functionality-wise, it would also feel more logical
to me to add the arch-specific implementation immediately after the
abstract version rather than a few patches down the set (kees the
reviewer in the same context).

/
    Leif

> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651
> 
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
> ---
>  ArmPkg/Library/MmuLib/MmuLib.c       | 120 ++++++++++++++++++++
>  ArmPkg/ArmPkg.dsc                    |   1 +
>  ArmPkg/Library/MmuLib/BaseMmuLib.inf |  30 +++++
>  3 files changed, 151 insertions(+)
> 
> diff --git a/ArmPkg/Library/MmuLib/MmuLib.c b/ArmPkg/Library/MmuLib/MmuLib.c
> new file mode 100644
> index 000000000000..70840c26f489
> --- /dev/null
> +++ b/ArmPkg/Library/MmuLib/MmuLib.c
> @@ -0,0 +1,120 @@
> +/** @file
> +This library instance implements a very limited MMU Lib instance
> +for the ARM/AARCH64 architectures.  This library shims a common library
> +interface to the ArmPkg defined ArmMmuLib.ib.
> +
> +Copyright (c) Microsoft Corporation.
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/ArmMmuLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/MmuLib.h>
> +
> +/**
> +  Bitwise sets the memory attributes on a range of memory based on an attributes mask.
> +
> +  @param  BaseAddress           The start of the range for which to set attributes.
> +  @param  Length                The length of the range.
> +  @param  Attributes            A bitmask of the attributes to set. See "Physical memory
> +                                protection attributes" in UefiSpec.h
> +
> +  @return EFI_SUCCESS
> +  @return Others
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmuSetAttributes (
> +  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
> +  IN  UINT64                    Length,
> +  IN  UINT64                    Attributes
> +  )
> +  {
> +    EFI_STATUS Status;
> +
> +    Status = EFI_UNSUPPORTED;
> +
> +    if (Attributes & EFI_MEMORY_XP) {
> +      Status = ArmSetMemoryRegionNoExec (BaseAddress, Length);
> +      if (EFI_ERROR(Status)) {
> +        DEBUG((DEBUG_ERROR, "%a - Failed to set NX.  Status = %r\n", __FUNCTION__, Status));
> +      }
> +    }
> +
> +    ASSERT_EFI_ERROR(Status);
> +    return Status;
> +  }
> +
> +
> +/**
> +  Bitwise clears the memory attributes on a range of memory based on an attributes mask.
> +
> +  @param  BaseAddress           The start of the range for which to clear attributes.
> +  @param  Length                The length of the range.
> +  @param  Attributes            A bitmask of the attributes to clear. See "Physical memory
> +                                protection attributes" in UefiSpec.h
> +
> +  @return EFI_SUCCESS
> +  @return Others
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmuClearAttributes (
> +  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
> +  IN  UINT64                    Length,
> +  IN  UINT64                    Attributes
> +  )
> +  {
> +    EFI_STATUS Status;
> +
> +    Status = EFI_UNSUPPORTED;
> +
> +    if (Attributes & EFI_MEMORY_XP) {
> +      Status = ArmClearMemoryRegionNoExec (BaseAddress, Length);
> +      if (EFI_ERROR(Status)) {
> +        DEBUG((DEBUG_ERROR, "%a - Failed to clear NX.  Status = %r\n", __FUNCTION__, Status));
> +      }
> +    }
> +
> +    if (Attributes & EFI_MEMORY_RO) {
> +      Status = ArmClearMemoryRegionReadOnly(BaseAddress, Length);
> +      if (EFI_ERROR(Status)) {
> +        DEBUG((DEBUG_ERROR, "%a - Failed to clear RO.  Status = %r\n", __FUNCTION__, Status));
> +      }
> +    }
> +
> +    ASSERT_EFI_ERROR(Status);
> +    return Status;
> +  }
> +
> +
> +/**
> +  Returns the memory attributes on a range of memory.
> +
> +  @param  BaseAddress           The start of the range for which to set attributes.
> +  @param  Attributes            A return pointer for the attributes.
> +
> +  @return EFI_SUCCESS
> +  @return EFI_INVALID_PARAMETER   A return pointer is NULL.
> +  @return Others
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmuGetAttributes (
> +  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
> +  OUT UINT64                    *Attributes
> +  )
> +  {
> +    EFI_STATUS Status;
> +
> +    Status = EFI_UNSUPPORTED;
> +
> +    DEBUG ((DEBUG_ERROR, "%a() API not implemented\n", __FUNCTION__));
> +
> +    ASSERT_EFI_ERROR(Status);
> +    return Status;
> +  }
> diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
> index 06ede068f99d..cbc67daa7696 100644
> --- a/ArmPkg/ArmPkg.dsc
> +++ b/ArmPkg/ArmPkg.dsc
> @@ -165,3 +165,4 @@ [Components.AARCH64]
>  
>  [Components.AARCH64, Components.ARM]
>    ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> +  ArmPkg/Library/MmuLib/BaseMmuLib.inf
> diff --git a/ArmPkg/Library/MmuLib/BaseMmuLib.inf b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> new file mode 100644
> index 000000000000..15095abee9c3
> --- /dev/null
> +++ b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> @@ -0,0 +1,30 @@
> +## @file
> +# This library instance implements a very limited MMU Lib instance
> +# for the ARM/AARCH64 architectures.  This library shims a common library
> +# interface to the ArmPkg defined ArmMmuLib.
> +#
> +# Copyright (c) Microsoft Corporation.
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010005
> +  BASE_NAME                      = MmuLib
> +  FILE_GUID                      = 6f2ee9a4-79b3-4b77-9a47-e2bd4b917b75
> +  MODULE_TYPE                    = BASE
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = MmuLib
> +
> +[Sources]
> +  MmuLib.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  ArmPkg/ArmPkg.dec
> +
> +[LibraryClasses]
> +  DebugLib
> +  ArmMmuLib
> -- 
> 2.31.1.windows.1
> 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* 回复: [edk2-devel] [PATCH v2 07/16] ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg
  2021-11-04 12:17   ` Leif Lindholm
@ 2021-11-05  5:12     ` gaoliming
  0 siblings, 0 replies; 25+ messages in thread
From: gaoliming @ 2021-11-05  5:12 UTC (permalink / raw)
  To: devel, leif, 'brbarkel@microsoft.com'
  Cc: 'Ard Biesheuvel', 'Michael D Kinney',
	'Zhiguang Liu', 'Sean Brogan'

Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Leif Lindholm
> 发送时间: 2021年11月4日 20:18
> 收件人: brbarkel@microsoft.com <bret@corthon.com>
> 抄送: devel@edk2.groups.io; Ard Biesheuvel <ardb+tianocore@kernel.org>;
> Michael D Kinney <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Zhiguang Liu <zhiguang.liu@intel.com>; Sean
> Brogan <sean.brogan@microsoft.com>
> 主题: Re: [edk2-devel] [PATCH v2 07/16] ArmPkg and MdePkg: Move the
> AsmMacroIoLib from ArmPkg to MdePkg
> 
> On Tue, Nov 02, 2021 at 13:17:39 -0700, brbarkel@microsoft.com wrote:
> > From: Bret Barkelew <brbarkel@microsoft.com>
> >
> > Cc: Leif Lindholm <leif@nuviainc.com>
> > Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
> 
> For the moving out part:
> Reviewed-by: Leif Lindholm <leif@nuviainc.com>
> Need one of the MdePkg maintainers to acknowledge the moving in
> part.
> 
> /
>     Leif
> 
> > ---
> >  {ArmPkg/Include => MdePkg/Include/AArch64}/AsmMacroIoLibV8.h | 0
> >  {ArmPkg/Include => MdePkg/Include/Arm}/AsmMacroIoLib.h       | 0
> >  2 files changed, 0 insertions(+), 0 deletions(-)
> >
> > diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h
> b/MdePkg/Include/AArch64/AsmMacroIoLibV8.h
> > similarity index 100%
> > rename from ArmPkg/Include/AsmMacroIoLibV8.h
> > rename to MdePkg/Include/AArch64/AsmMacroIoLibV8.h
> > diff --git a/ArmPkg/Include/AsmMacroIoLib.h
> b/MdePkg/Include/Arm/AsmMacroIoLib.h
> > similarity index 100%
> > rename from ArmPkg/Include/AsmMacroIoLib.h
> > rename to MdePkg/Include/Arm/AsmMacroIoLib.h
> > --
> > 2.31.1.windows.1
> >
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [edk2-devel] [PATCH v2 16/16] ArmPlatformPkg: Resolve build errors resulting from package moves
  2021-11-02 20:17 ` [PATCH v2 16/16] ArmPlatformPkg: " Bret Barkelew
@ 2021-11-06  9:50   ` Marvin Häuser
  2021-11-08 19:25     ` [EXTERNAL] " Bret Barkelew
  0 siblings, 1 reply; 25+ messages in thread
From: Marvin Häuser @ 2021-11-06  9:50 UTC (permalink / raw)
  To: devel, bret; +Cc: devel, Leif Lindholm, Ard Biesheuvel, Sean Brogan

Hey Bret,

If I understood this correctly, this fixes build issues introduced with 
the move patch of the same series? In that case, is there no edk2 rule 
that every commit must compile for the whole tree? We have such a rule 
downstream that overrides any colliding rules (e.g. "mod only one 
package at a time") to not break bisectioning. We actually have 
per-commit builds readily available in a database for some projects to 
ease it further. No big deal for us as we don't do that with edk2 (yet), 
but maybe worth considering for the future? :)

I'll just ask about another patch here because it doesn't matter for 
review, but why move the ARM entry point to ArmPkg? I guess because 
abstracting the ARM-specific things would more or less just make the 
StandaloneMm library a trivial wrapper? My "issue" with this is that ARM 
kind of has its own ecosystem in edk2 and without keeping up, it's hard 
to tell whether to look for ARM implementations of modules and libraries 
in the "generic" or the ARM packages.

Thanks a lot for the series!

Best regards,
Marvin

02.11.2021 21:21:59 Bret Barkelew <bret@corthon.com>:

> From: Bret Barkelew <brbarkel@microsoft.com>
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3652
> 
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
> ---
> ArmPlatformPkg/ArmPlatformPkg.dsc | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc
> index 661a4cea220d..3ed0bae87c41 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dsc
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
> @@ -79,6 +79,8 @@ [LibraryClasses.common]
>    NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
>    NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
> 
> +  ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
> +
> [LibraryClasses.common.PEIM]
>    HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
>    MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
> @@ -92,7 +94,7 @@ [LibraryClasses.common.SEC]
>    MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
>    PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
> 
> -[LibraryClasses.AARCH64.MM_STANDALONE]
> +[LibraryClasses.common.MM_STANDALONE]
>    HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
>    MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
>    MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
> -- 
> 2.31.1.windows.1
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [EXTERNAL] Re: [edk2-devel] [PATCH v2 16/16] ArmPlatformPkg: Resolve build errors resulting from package moves
  2021-11-06  9:50   ` [edk2-devel] " Marvin Häuser
@ 2021-11-08 19:25     ` Bret Barkelew
  0 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-08 19:25 UTC (permalink / raw)
  To: devel@edk2.groups.io, mhaeuser@posteo.de, bret@corthon.com
  Cc: devel@edk2.groups.io, Lindholm, Leif, Ard Biesheuvel, Sean Brogan

[-- Attachment #1: Type: text/plain, Size: 4664 bytes --]

Marvin,

Thanks for the question! You’re right, I need to squash this patch into the applicable patches in the series so that the build fixes are present when the initial changes are added (to maintain bisectability). Surprised no one had mentioned it yet. 😉

I would actually be happy to keep the Arm entry point in StandaloneMmPkg if someone else wanted to tackle the work needed to remove the ArmPkg interface dependencies from the implementation. The necessary abstractions are beyond my ability to bite off right now, so the most direct solution was to relocate the implementation (leveraging the abstraction at the EntryPoint level) to the ArmPkg so that the necessary platforms could consume it. I could also see an argument that it should be platform code, but I think it’s more common than that and would prefer to keep it in EDK2.

- Bret

From: Marvin Häuser via groups.io<mailto:mhaeuser=posteo.de@groups.io>
Sent: Saturday, November 6, 2021 2:50 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; bret@corthon.com<mailto:bret@corthon.com>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Lindholm, Leif<mailto:leif@nuviainc.com>; Ard Biesheuvel<mailto:ardb+tianocore@kernel.org>; Sean Brogan<mailto:sean.brogan@microsoft.com>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH v2 16/16] ArmPlatformPkg: Resolve build errors resulting from package moves

Hey Bret,

If I understood this correctly, this fixes build issues introduced with
the move patch of the same series? In that case, is there no edk2 rule
that every commit must compile for the whole tree? We have such a rule
downstream that overrides any colliding rules (e.g. "mod only one
package at a time") to not break bisectioning. We actually have
per-commit builds readily available in a database for some projects to
ease it further. No big deal for us as we don't do that with edk2 (yet),
but maybe worth considering for the future? :)

I'll just ask about another patch here because it doesn't matter for
review, but why move the ARM entry point to ArmPkg? I guess because
abstracting the ARM-specific things would more or less just make the
StandaloneMm library a trivial wrapper? My "issue" with this is that ARM
kind of has its own ecosystem in edk2 and without keeping up, it's hard
to tell whether to look for ARM implementations of modules and libraries
in the "generic" or the ARM packages.

Thanks a lot for the series!

Best regards,
Marvin

02.11.2021 21:21:59 Bret Barkelew <bret@corthon.com>:

> From: Bret Barkelew <brbarkel@microsoft.com>
>
> REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3652&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C2d061d1ff7a845914be808d9a10addee%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637717890363754993%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=r5yRvqRrCGPQLNCXfXv4KdmldhxFTpCwdsjMoPcvl4M%3D&amp;reserved=0
>
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
> ---
> ArmPlatformPkg/ArmPlatformPkg.dsc | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc
> index 661a4cea220d..3ed0bae87c41 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dsc
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
> @@ -79,6 +79,8 @@ [LibraryClasses.common]
>    NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
>    NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
>
> +  ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
> +
> [LibraryClasses.common.PEIM]
>    HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
>    MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
> @@ -92,7 +94,7 @@ [LibraryClasses.common.SEC]
>    MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
>    PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
>
> -[LibraryClasses.AARCH64.MM_STANDALONE]
> +[LibraryClasses.common.MM_STANDALONE]
>    HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
>    MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
>    MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
> --
> 2.31.1.windows.1
>
>
>
>






[-- Attachment #2: Type: text/html, Size: 7796 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon
  2021-11-04 12:43   ` Leif Lindholm
@ 2021-11-10 20:39     ` Bret Barkelew
  0 siblings, 0 replies; 25+ messages in thread
From: Bret Barkelew @ 2021-11-10 20:39 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: edk2-devel-groups-io, Ard Biesheuvel, Sean Brogan

[-- Attachment #1: Type: text/plain, Size: 7760 bytes --]

Will address in next release.

On Thu, Nov 4, 2021 at 5:43 AM Leif Lindholm <leif@nuviainc.com> wrote:

> On Tue, Nov 02, 2021 at 13:17:43 -0700, brbarkel@microsoft.com wrote:
> > From: Sean Brogan <sean.brogan@microsoft.com>
> >
> > The previously Arm-specific "ArmMmuLib" has been generalized
> > as "MmuLib". The Arm implementation of this lib can still use
> > the existing library logic to back it.
> >
> > As such, this implementation is currently just a shim to the
> > old library, while enabling higher-level code to be more
> > common.
>
> This commit message still required me to go and cross refecence a few
> patches to (I think) understand what's going on.
> (not least because it relies on a patch to MdePkg which I wasn't cc:d
> on, so hadn't spotted.)
>
> Correct me if I've got this wrong, but here's my theory:
> - 8/16 adds a library class that currently basically amounts to an
>   unabstracted version of ArmMmuLib, but in MdePkg, minus the Arm
>   prefixes.
> - 9/16 switches MdeModulePkg to use the new MmuLib instead of
>   ArmMmuLib.
> - 10/16 does the same for StandaloneMmPkg.
> - 11/16 adds an actual implementation of this library class under
>   ArmPkg - backed by ArmMmuLib.
>
> If that's accurate...
>
> Starting with the commit message - could we reduce the use of passive
> voice a bit? Suggestion:
>
> ---
> After adding the abstract MmuLib to MdePkg, add an implementation
> backed by the existing ArmMmuLib to ArmPkg.
> ---
>
> While not required functionality-wise, it would also feel more logical
> to me to add the arch-specific implementation immediately after the
> abstract version rather than a few patches down the set (kees the
> reviewer in the same context).
>
> /
>     Leif
>
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651
> >
> > Cc: Leif Lindholm <leif@nuviainc.com>
> > Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com>
> > ---
> >  ArmPkg/Library/MmuLib/MmuLib.c       | 120 ++++++++++++++++++++
> >  ArmPkg/ArmPkg.dsc                    |   1 +
> >  ArmPkg/Library/MmuLib/BaseMmuLib.inf |  30 +++++
> >  3 files changed, 151 insertions(+)
> >
> > diff --git a/ArmPkg/Library/MmuLib/MmuLib.c
> b/ArmPkg/Library/MmuLib/MmuLib.c
> > new file mode 100644
> > index 000000000000..70840c26f489
> > --- /dev/null
> > +++ b/ArmPkg/Library/MmuLib/MmuLib.c
> > @@ -0,0 +1,120 @@
> > +/** @file
> > +This library instance implements a very limited MMU Lib instance
> > +for the ARM/AARCH64 architectures.  This library shims a common library
> > +interface to the ArmPkg defined ArmMmuLib.ib.
> > +
> > +Copyright (c) Microsoft Corporation.
> > +SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include <Library/ArmMmuLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/MmuLib.h>
> > +
> > +/**
> > +  Bitwise sets the memory attributes on a range of memory based on an
> attributes mask.
> > +
> > +  @param  BaseAddress           The start of the range for which to set
> attributes.
> > +  @param  Length                The length of the range.
> > +  @param  Attributes            A bitmask of the attributes to set. See
> "Physical memory
> > +                                protection attributes" in UefiSpec.h
> > +
> > +  @return EFI_SUCCESS
> > +  @return Others
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +MmuSetAttributes (
> > +  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
> > +  IN  UINT64                    Length,
> > +  IN  UINT64                    Attributes
> > +  )
> > +  {
> > +    EFI_STATUS Status;
> > +
> > +    Status = EFI_UNSUPPORTED;
> > +
> > +    if (Attributes & EFI_MEMORY_XP) {
> > +      Status = ArmSetMemoryRegionNoExec (BaseAddress, Length);
> > +      if (EFI_ERROR(Status)) {
> > +        DEBUG((DEBUG_ERROR, "%a - Failed to set NX.  Status = %r\n",
> __FUNCTION__, Status));
> > +      }
> > +    }
> > +
> > +    ASSERT_EFI_ERROR(Status);
> > +    return Status;
> > +  }
> > +
> > +
> > +/**
> > +  Bitwise clears the memory attributes on a range of memory based on an
> attributes mask.
> > +
> > +  @param  BaseAddress           The start of the range for which to
> clear attributes.
> > +  @param  Length                The length of the range.
> > +  @param  Attributes            A bitmask of the attributes to clear.
> See "Physical memory
> > +                                protection attributes" in UefiSpec.h
> > +
> > +  @return EFI_SUCCESS
> > +  @return Others
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +MmuClearAttributes (
> > +  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
> > +  IN  UINT64                    Length,
> > +  IN  UINT64                    Attributes
> > +  )
> > +  {
> > +    EFI_STATUS Status;
> > +
> > +    Status = EFI_UNSUPPORTED;
> > +
> > +    if (Attributes & EFI_MEMORY_XP) {
> > +      Status = ArmClearMemoryRegionNoExec (BaseAddress, Length);
> > +      if (EFI_ERROR(Status)) {
> > +        DEBUG((DEBUG_ERROR, "%a - Failed to clear NX.  Status = %r\n",
> __FUNCTION__, Status));
> > +      }
> > +    }
> > +
> > +    if (Attributes & EFI_MEMORY_RO) {
> > +      Status = ArmClearMemoryRegionReadOnly(BaseAddress, Length);
> > +      if (EFI_ERROR(Status)) {
> > +        DEBUG((DEBUG_ERROR, "%a - Failed to clear RO.  Status = %r\n",
> __FUNCTION__, Status));
> > +      }
> > +    }
> > +
> > +    ASSERT_EFI_ERROR(Status);
> > +    return Status;
> > +  }
> > +
> > +
> > +/**
> > +  Returns the memory attributes on a range of memory.
> > +
> > +  @param  BaseAddress           The start of the range for which to set
> attributes.
> > +  @param  Attributes            A return pointer for the attributes.
> > +
> > +  @return EFI_SUCCESS
> > +  @return EFI_INVALID_PARAMETER   A return pointer is NULL.
> > +  @return Others
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +MmuGetAttributes (
> > +  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
> > +  OUT UINT64                    *Attributes
> > +  )
> > +  {
> > +    EFI_STATUS Status;
> > +
> > +    Status = EFI_UNSUPPORTED;
> > +
> > +    DEBUG ((DEBUG_ERROR, "%a() API not implemented\n", __FUNCTION__));
> > +
> > +    ASSERT_EFI_ERROR(Status);
> > +    return Status;
> > +  }
> > diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
> > index 06ede068f99d..cbc67daa7696 100644
> > --- a/ArmPkg/ArmPkg.dsc
> > +++ b/ArmPkg/ArmPkg.dsc
> > @@ -165,3 +165,4 @@ [Components.AARCH64]
> >
> >  [Components.AARCH64, Components.ARM]
> >    ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> > +  ArmPkg/Library/MmuLib/BaseMmuLib.inf
> > diff --git a/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> > new file mode 100644
> > index 000000000000..15095abee9c3
> > --- /dev/null
> > +++ b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> > @@ -0,0 +1,30 @@
> > +## @file
> > +# This library instance implements a very limited MMU Lib instance
> > +# for the ARM/AARCH64 architectures.  This library shims a common
> library
> > +# interface to the ArmPkg defined ArmMmuLib.
> > +#
> > +# Copyright (c) Microsoft Corporation.
> > +#
> > +# SPDX-License-Identifier: BSD-2-Clause-Patent
> > +#
> > +##
> > +
> > +[Defines]
> > +  INF_VERSION                    = 0x00010005
> > +  BASE_NAME                      = MmuLib
> > +  FILE_GUID                      = 6f2ee9a4-79b3-4b77-9a47-e2bd4b917b75
> > +  MODULE_TYPE                    = BASE
> > +  VERSION_STRING                 = 1.0
> > +  LIBRARY_CLASS                  = MmuLib
> > +
> > +[Sources]
> > +  MmuLib.c
> > +
> > +[Packages]
> > +  MdePkg/MdePkg.dec
> > +  MdeModulePkg/MdeModulePkg.dec
> > +  ArmPkg/ArmPkg.dec
> > +
> > +[LibraryClasses]
> > +  DebugLib
> > +  ArmMmuLib
> > --
> > 2.31.1.windows.1
> >
>

[-- Attachment #2: Type: text/html, Size: 10315 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2021-11-10 20:40 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-02 20:17 [PATCH v2 00/16] Un-siloing Arm common code Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 01/16] ArmPkg/ArmMmuBaseLib: Disallow STANDALONE_MM Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 02/16] ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib Bret Barkelew
2021-11-04 12:14   ` Leif Lindholm
2021-11-02 20:17 ` [PATCH v2 03/16] ArmPkg/StandaloneMmCoreEntryPoint: Swap to ArmMmuLib Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 04/16] ArmPkg: Disavow StandaloneMmMmuLib. It's just ArmMmuLib Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg Bret Barkelew
2021-11-04 12:16   ` Leif Lindholm
2021-11-02 20:17 ` [PATCH v2 06/16] ArmPkg and BaseTools: Move the GccLto binaries from ArmPkg to BaseTools Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 07/16] ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg Bret Barkelew
2021-11-04 12:17   ` Leif Lindholm
2021-11-05  5:12     ` 回复: [edk2-devel] " gaoliming
2021-11-02 20:17 ` [PATCH v2 08/16] MdePkg: Create the MMU access lib to abstract memory protection settings Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 09/16] MdeModulePkg: Swap to MmuLib instead of Arm-specific lib Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 10/16] StandaloneMmPkg: Switch to the MmuLib abstraction Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon Bret Barkelew
2021-11-04 12:43   ` Leif Lindholm
2021-11-10 20:39     ` Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 12/16] ArmPkg: Move the StandaloneMmCpu driver to ArmPkg Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 13/16] ArmPkg: Move the StandaloneMmCoreEntryPoint lib " Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 14/16] ArmPkg/Library: Convert StandaloneMmCoreEntryPoint to Arm-only Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 15/16] ArmPkg/ArmPkg.dsc: Resolve build errors resulting from package moves Bret Barkelew
2021-11-02 20:17 ` [PATCH v2 16/16] ArmPlatformPkg: " Bret Barkelew
2021-11-06  9:50   ` [edk2-devel] " Marvin Häuser
2021-11-08 19:25     ` [EXTERNAL] " Bret Barkelew

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox