]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/ArmVirtMemoryInitPeiLib: avoid redundant cache invalidation
authorArd Biesheuvel <ardb@kernel.org>
Sat, 29 Jan 2022 14:58:26 +0000 (15:58 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 25 Feb 2022 15:57:11 +0000 (15:57 +0000)
Alex reports that the cache invalidation performed by
ArmVirtMemoryInitPeiLib takes a non-negligible amount of time at boot.
This cache invalidation used to be necessary to avoid inconsistencies
between the CPU's cached and uncached views of the permanent PEI memory
region, given that the PEI phase is where the MMU gets enabled.

The only allocations done from permanent PEI memory with the MMU off are
pages used for page tables, and since commit 748fea6279ef
("ArmPkg/ArmMmuLib AARCH64: invalidate page tables before populating
them"), each of those is invalidated in the caches explicitly, for
reasons described in the patch's commit log. All other allocations done
in PEI are either from temporary PEI memory, which includes the stack,
or from permanent PEI memory but after the MMU has been enabled.

This means that the cache invalidation in ArmVirtMemoryInitPeiLib is no
longer necessary, and can simply be dropped.

Reported-by: Alexander Graf <graf@amazon.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c

index 022e13e762b653ecc317e6cf564c7b7931918775..98d90ad4200db9405c311ac3959923b9fd9b083c 100644 (file)
@@ -91,15 +91,6 @@ MemoryPeim (
       );\r
   }\r
 \r
-  //\r
-  // When running under virtualization, the PI/UEFI memory region may be\r
-  // clean but not invalidated in system caches or in lower level caches\r
-  // on other CPUs. So invalidate the region by virtual address, to ensure\r
-  // that the contents we put there with the caches and MMU off will still\r
-  // be visible after turning them on.\r
-  //\r
-  InvalidateDataCacheRange ((VOID *)(UINTN)UefiMemoryBase, UefiMemorySize);\r
-\r
   // Build Memory Allocation Hob\r
   InitMmu ();\r
 \r