rhboot / shim

UEFI shim loader
Other
819 stars 289 forks source link

Remove sanity check for length when updating mem attrs #542

Closed dennis-tseng99 closed 1 year ago

dennis-tseng99 commented 1 year ago

According to the DXE spec, the BaseAddress must be page-aligned, while the Length is not necessarily page-aligned. Hence, the sanity checks for size in update_mem_attrs() and get_mem_attrs in pe.c are removed.

_DXE Architectural Protocols Platform Initialization Specification, Vol. 2 EFI_CPU_ARCH_PROTOCOL.SetMemoryAttributes() Summary Change a memory region to support specified memory attributes. Prototype typedef EFI_STATUS (EFIAPI EFI_CPU_SET_MEMORY_ATTRIBUTES) ( IN CONST EFI_CPU_ARCH_PROTOCOL This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes ); Parameters This The EFI_CPU_ARCH_PROTOCOL instance. BaseAddress The physical address that is the start address of a memory region. EFI_PHYSICALADDRESS is defined in the AllocatePages() function description in the UEFI 2.0 specification. Length The size in bytes of the memory region. Attributes A bit mask that specifies the memory region attributes. GetMemoryMap() for the set of legal attribute bits.

Signed-off-by: Dennis Tseng dennis.tseng@suse.com

nicholasbishop commented 1 year ago

At least under mu, the mem attrs seem to be set at the page level. Passing in a non-page-aligned size when updating attrs will fail. So I think we should keep the size check.

dennis-tseng99 commented 1 year ago

Understood. I will close this PR soon if no other comments. Thank Nicholasbishop.

dennis-tseng99 commented 1 year ago

Close this PR because: