mirror of https://github.com/acidanthera/audk.git
ArmPkg: Drop individual memory permission helpers
Now that we have a sane API to set and clear memory permissions that works the same on ARM and AArch64, we no longer have a need for the individual set/clear no-access/read-only/no-exec helpers so let's drop them. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
This commit is contained in:
parent
7054f1a54e
commit
8a1f540596
|
@ -288,9 +288,11 @@ RemapUnusedMemoryNx (
|
|||
MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + MemoryMapSize);
|
||||
while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
|
||||
if (MemoryMapEntry->Type == EfiConventionalMemory) {
|
||||
ArmSetMemoryRegionNoExec (
|
||||
ArmSetMemoryAttributes (
|
||||
MemoryMapEntry->PhysicalStart,
|
||||
EFI_PAGES_TO_SIZE (MemoryMapEntry->NumberOfPages)
|
||||
EFI_PAGES_TO_SIZE (MemoryMapEntry->NumberOfPages),
|
||||
EFI_MEMORY_XP,
|
||||
EFI_MEMORY_XP
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,68 +21,6 @@ ArmConfigureMmu (
|
|||
OUT UINTN *TranslationTableSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Convert a region of memory to read-protected, by clearing the access flag.
|
||||
|
||||
@param BaseAddress The start of the region.
|
||||
@param Length The size of the region.
|
||||
|
||||
@retval EFI_SUCCESS The attributes were set successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The operation failed due to insufficient memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmSetMemoryRegionNoAccess (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
);
|
||||
|
||||
/**
|
||||
Convert a region of memory to read-enabled, by setting the access flag.
|
||||
|
||||
@param BaseAddress The start of the region.
|
||||
@param Length The size of the region.
|
||||
|
||||
@retval EFI_SUCCESS The attributes were set successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The operation failed due to insufficient memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmClearMemoryRegionNoAccess (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmSetMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmClearMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmSetMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmClearMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmReplaceLiveTranslationEntry (
|
||||
|
|
|
@ -552,142 +552,6 @@ ArmSetMemoryAttributes (
|
|||
);
|
||||
}
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
SetMemoryRegionAttribute (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length,
|
||||
IN UINT64 Attributes,
|
||||
IN UINT64 BlockEntryMask
|
||||
)
|
||||
{
|
||||
return UpdateRegionMapping (
|
||||
BaseAddress,
|
||||
Length,
|
||||
Attributes,
|
||||
BlockEntryMask,
|
||||
ArmGetTTBR0BaseAddress (),
|
||||
TRUE
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
UINT64 Val;
|
||||
|
||||
if (ArmReadCurrentEL () == AARCH64_EL1) {
|
||||
Val = TT_PXN_MASK | TT_UXN_MASK;
|
||||
} else {
|
||||
Val = TT_XN_MASK;
|
||||
}
|
||||
|
||||
return SetMemoryRegionAttribute (
|
||||
BaseAddress,
|
||||
Length,
|
||||
Val,
|
||||
~TT_ADDRESS_MASK_BLOCK_ENTRY
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
UINT64 Mask;
|
||||
|
||||
// XN maps to UXN in the EL1&0 translation regime
|
||||
Mask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_PXN_MASK | TT_XN_MASK);
|
||||
|
||||
return SetMemoryRegionAttribute (
|
||||
BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
Mask
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert a region of memory to read-protected, by clearing the access flag.
|
||||
|
||||
@param BaseAddress The start of the region.
|
||||
@param Length The size of the region.
|
||||
|
||||
@retval EFI_SUCCESS The attributes were set successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The operation failed due to insufficient memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionNoAccess (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryRegionAttribute (
|
||||
BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AF)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert a region of memory to read-enabled, by setting the access flag.
|
||||
|
||||
@param BaseAddress The start of the region.
|
||||
@param Length The size of the region.
|
||||
|
||||
@retval EFI_SUCCESS The attributes were set successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The operation failed due to insufficient memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionNoAccess (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryRegionAttribute (
|
||||
BaseAddress,
|
||||
Length,
|
||||
TT_AF,
|
||||
~TT_ADDRESS_MASK_BLOCK_ENTRY
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryRegionAttribute (
|
||||
BaseAddress,
|
||||
Length,
|
||||
TT_AP_NO_RO,
|
||||
~TT_ADDRESS_MASK_BLOCK_ENTRY
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryRegionAttribute (
|
||||
BaseAddress,
|
||||
Length,
|
||||
TT_AP_NO_RW,
|
||||
~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK)
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ArmConfigureMmu (
|
||||
|
|
|
@ -544,107 +544,3 @@ ArmSetMemoryAttributes (
|
|||
TtEntryMask
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryAttributes (
|
||||
BaseAddress,
|
||||
Length,
|
||||
EFI_MEMORY_XP,
|
||||
TT_DESCRIPTOR_SECTION_XN_MASK
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionNoExec (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryAttributes (
|
||||
BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
TT_DESCRIPTOR_SECTION_XN_MASK
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryAttributes (
|
||||
BaseAddress,
|
||||
Length,
|
||||
EFI_MEMORY_RO,
|
||||
TT_DESCRIPTOR_SECTION_AP_MASK
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionReadOnly (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryAttributes (
|
||||
BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
TT_DESCRIPTOR_SECTION_AP_MASK
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert a region of memory to read-protected, by clearing the access flag.
|
||||
|
||||
@param BaseAddress The start of the region.
|
||||
@param Length The size of the region.
|
||||
|
||||
@retval EFI_SUCCESS The attributes were set successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The operation failed due to insufficient memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
ArmSetMemoryRegionNoAccess (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryAttributes (
|
||||
BaseAddress,
|
||||
Length,
|
||||
EFI_MEMORY_RP,
|
||||
TT_DESCRIPTOR_SECTION_AF
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert a region of memory to read-enabled, by setting the access flag.
|
||||
|
||||
@param BaseAddress The start of the region.
|
||||
@param Length The size of the region.
|
||||
|
||||
@retval EFI_SUCCESS The attributes were set successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The operation failed due to insufficient memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
ArmClearMemoryRegionNoAccess (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINT64 Length
|
||||
)
|
||||
{
|
||||
return SetMemoryAttributes (
|
||||
BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
TT_DESCRIPTOR_SECTION_AF
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue