diff --git a/ArmPkg/Library/CpuArchLib/AArch64/Mmu.c b/ArmPkg/Library/CpuArchLib/AArch64/Mmu.c index 922fdbbb14..c1f80aa612 100644 --- a/ArmPkg/Library/CpuArchLib/AArch64/Mmu.c +++ b/ArmPkg/Library/CpuArchLib/AArch64/Mmu.c @@ -95,6 +95,12 @@ PageAttributeToGcdAttribute ( GcdAttributes |= EFI_MEMORY_XP; } + if (((PageAttributes & TT_AP_MASK) == TT_AP_RW_RW) || + ((PageAttributes & TT_AP_MASK) == TT_AP_RO_RO)) + { + GcdAttributes |= EFI_MEMORY_USER; + } + return GcdAttributes; } diff --git a/ArmPkg/Library/CpuArchLib/CpuDxe.c b/ArmPkg/Library/CpuArchLib/CpuDxe.c index 15787e781f..44994be396 100644 --- a/ArmPkg/Library/CpuArchLib/CpuDxe.c +++ b/ArmPkg/Library/CpuArchLib/CpuDxe.c @@ -218,6 +218,7 @@ EFI_CPU_ARCH_PROTOCOL mCpu = { CpuSetMemoryAttributes, 0, // NumberOfTimers 2048, // DmaBufferAlignment + CpuGetMemoryAttributes }; STATIC diff --git a/ArmPkg/Library/CpuArchLib/CpuDxe.h b/ArmPkg/Library/CpuArchLib/CpuDxe.h index 8e82ffb9e8..85e3a0adc0 100644 --- a/ArmPkg/Library/CpuArchLib/CpuDxe.h +++ b/ArmPkg/Library/CpuArchLib/CpuDxe.h @@ -96,6 +96,14 @@ CpuSetMemoryAttributes ( IN UINT64 Attributes ); +EFI_STATUS +EFIAPI +CpuGetMemoryAttributes ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Address, + OUT UINT64 *Attributes + ); + EFI_STATUS InitializeExceptions ( IN EFI_CPU_ARCH_PROTOCOL *Cpu diff --git a/ArmPkg/Library/CpuArchLib/CpuMmuCommon.c b/ArmPkg/Library/CpuArchLib/CpuMmuCommon.c index 2d60c7d24d..c33c6bb6be 100644 --- a/ArmPkg/Library/CpuArchLib/CpuMmuCommon.c +++ b/ArmPkg/Library/CpuArchLib/CpuMmuCommon.c @@ -222,3 +222,28 @@ CpuSetMemoryAttributes ( return EFI_SUCCESS; } } + +EFI_STATUS +EFIAPI +CpuGetMemoryAttributes ( + IN EFI_CPU_ARCH_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Address, + OUT UINT64 *Attributes + ) +{ + EFI_STATUS Status; + UINTN RegionBaseAddress; + UINTN RegionLength; + UINTN RegionArmAttributes; + + RegionBaseAddress = Address; + Status = GetMemoryRegion (&RegionBaseAddress, &RegionLength, &RegionArmAttributes); + + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + *Attributes = RegionAttributeToGcdAttribute (RegionArmAttributes); + + return Status; +} diff --git a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S index 1d26d79473..35e0c3f6c9 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S +++ b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S @@ -7,26 +7,6 @@ #include -//------------------------------------------------------------------------------ -// VOID -// EFIAPI -// DisableSMAP ( -// VOID -// ); -//------------------------------------------------------------------------------ -ASM_FUNC(DisableSMAP) - ret - -//------------------------------------------------------------------------------ -// VOID -// EFIAPI -// EnableSMAP ( -// VOID -// ); -//------------------------------------------------------------------------------ -ASM_FUNC(EnableSMAP) - ret - //------------------------------------------------------------------------------ // EFI_STATUS // EFIAPI diff --git a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c index a6466e0cf2..470773a19a 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c +++ b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c @@ -41,3 +41,21 @@ InitializeMsr ( ASSERT (FALSE); } } + +VOID +EFIAPI +DisableSMAP ( + VOID + ) +{ + ArmClearPan (); +} + +VOID +EFIAPI +EnableSMAP ( + VOID + ) +{ + ArmSetPan (); +}