audk/ArmPkg/Drivers
Ard Biesheuvel 1034d223f8 ArmPkg/CpuDxe: Perform preliminary NX remap of free memory
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: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
2023-05-29 16:51:01 +00:00
..
ArmCrashDumpDxe ArmPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
ArmGic ArmPkg: Update code to be more C11 compliant by using __func__ 2023-04-10 14:19:57 +00:00
ArmPciCpuIo2Dxe ArmPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
ArmPsciMpServicesDxe ArmPkg: implement EFI_MP_SERVICES_PROTOCOL based on PSCI calls 2023-01-27 14:18:56 +00:00
ArmScmiDxe ArmPkg/ArmScmiDxe: Fix the calculation of RequiredArraySize 2023-02-06 13:56:24 +00:00
CpuDxe ArmPkg/CpuDxe: Perform preliminary NX remap of free memory 2023-05-29 16:51:01 +00:00
CpuPei ArmPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
GenericWatchdogDxe ArmPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
MmCommunicationDxe ArmPkg: MmCommunicationDxe: Update MM communicate `MessageLength` check 2022-01-27 02:16:17 +00:00
TimerDxe ArmPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00