ArmPkg/ArmMmuLib: Implement EFI_MEMORY_RP using access flag
Implement support for read-protected memory by wiring it up to the access flag in the page table descriptor. The resulting mapping is implicitly non-writable and non-executable as well, but this is good enough for implementing this attribute, as we never rely on write or execute permissions without read permissions. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
This commit is contained in:
committed by
mergify[bot]
parent
041c7a31c2
commit
6b821be140
@@ -523,3 +523,51 @@ ArmClearMemoryRegionReadOnly (
|
||||
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
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user