Skip to content
Snippets Groups Projects
Select Git revision
0 results

ArmPkg.dec

  • Ard Biesheuvel's avatar
    1034d223
    ArmPkg/CpuDxe: Perform preliminary NX remap of free memory · 1034d223
    Ard Biesheuvel authored
    
    The DXE core implementation of PcdDxeNxMemoryProtectionPolicy already
    contains an assertion that EfiConventionalMemory and EfiBootServicesData
    are subjected to the same policy when it comes to the use of NX
    permissions. The reason for this is that we may otherwise end up with
    unbounded recursion in the page table code, given that allocating a page
    table would then involve a permission attribute change, and this could
    result in the need for a block entry to be split, which would trigger
    the allocation of a page table recursively.
    
    For the same reason, a shortcut exists in ApplyMemoryProtectionPolicy()
    where, instead of setting the memory attributes unconditionally, we
    compare the NX policies and avoid touching the page tables if they are
    the same for the old and the new memory types. Without this shortcut, we
    may end up in a situation where, as the CPU arch protocol DXE driver is
    ramping up, the same unbounded recursion is triggered, due to the fact
    that the NX policy for EfiConventionalMemory has not been applied yet.
    
    To break this cycle, let's remap all EfiConventionalMemory regions
    according to the NX policy for EfiBootServicesData before exposing the
    CPU arch protocol to the DXE core and other drivers. This ensures that
    creating EfiBootServicesData allocations does not result in memory
    attribute changes, and therefore no recursion.
    
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Reviewed-by: default avatarLeif Lindholm <quic_llindhol@quicinc.com>
    1034d223
    History
    ArmPkg/CpuDxe: Perform preliminary NX remap of free memory
    Ard Biesheuvel authored
    
    The DXE core implementation of PcdDxeNxMemoryProtectionPolicy already
    contains an assertion that EfiConventionalMemory and EfiBootServicesData
    are subjected to the same policy when it comes to the use of NX
    permissions. The reason for this is that we may otherwise end up with
    unbounded recursion in the page table code, given that allocating a page
    table would then involve a permission attribute change, and this could
    result in the need for a block entry to be split, which would trigger
    the allocation of a page table recursively.
    
    For the same reason, a shortcut exists in ApplyMemoryProtectionPolicy()
    where, instead of setting the memory attributes unconditionally, we
    compare the NX policies and avoid touching the page tables if they are
    the same for the old and the new memory types. Without this shortcut, we
    may end up in a situation where, as the CPU arch protocol DXE driver is
    ramping up, the same unbounded recursion is triggered, due to the fact
    that the NX policy for EfiConventionalMemory has not been applied yet.
    
    To break this cycle, let's remap all EfiConventionalMemory regions
    according to the NX policy for EfiBootServicesData before exposing the
    CPU arch protocol to the DXE core and other drivers. This ensures that
    creating EfiBootServicesData allocations does not result in memory
    attribute changes, and therefore no recursion.
    
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Reviewed-by: default avatarLeif Lindholm <quic_llindhol@quicinc.com>
Code owners