diff options
author | Ard Biesheuvel <ardb@kernel.org> | 2023-02-08 16:34:33 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-05-29 16:51:01 +0000 |
commit | 1034d223f8cc6bf8b9b86c57e564753cdad46f88 (patch) | |
tree | 9540bc4c7aa5cb6f14d2df83c2a7718256592eac /ArmPkg/ArmPkg.dec | |
parent | 03663c4319003ccd911c93d11be37397a5881780 (diff) | |
download | edk2-1034d223f8cc6bf8b9b86c57e564753cdad46f88.tar.gz edk2-1034d223f8cc6bf8b9b86c57e564753cdad46f88.tar.bz2 edk2-1034d223f8cc6bf8b9b86c57e564753cdad46f88.zip |
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>
Diffstat (limited to 'ArmPkg/ArmPkg.dec')
-rw-r--r-- | ArmPkg/ArmPkg.dec | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 2444457ae5..1a16d044c9 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -144,6 +144,11 @@ # If PcdMonitorConduitHvc = TRUE, conduit = HVC
gArmTokenSpaceGuid.PcdMonitorConduitHvc|FALSE|BOOLEAN|0x00000047
+ # Whether to remap all unused memory NX before installing the CPU arch
+ # protocol driver. This is needed on platforms that map all DRAM with RWX
+ # attributes initially, and can be disabled otherwise.
+ gArmTokenSpaceGuid.PcdRemapUnusedMemoryNx|TRUE|BOOLEAN|0x00000048
+
[PcdsFeatureFlag.ARM]
# Whether to map normal memory as non-shareable. FALSE is the safe choice, but
# TRUE may be appropriate to fix performance problems if you don't care about
|