Hello all, This series implements explicit cache maintenance for the QEMU/KVM and Xen build targets. This is necessary as, under virtualization, memory regions that are manipulated with the MMU and caches off may be shadowed by clean cachelines in system caches or lower level caches on other CPUs.
Changes since v2: - added patches #1 and #2, patches #3 to #5 are the otherwise unmodified patches #1 to #3 of the previous submission of this series Patch #1 fixes the dependency between MemoryInitPeim and MemoryInitPeiLib, by making the former depend on the latter via a library class instead of incorporating the .c file directly. This allows us to override the library instance in patch #2. Patch #2 moves ArmVirtualizationPkg/ArmVirtualizationQemu.dsc to the virt specific implementation of MemoryInitPeiLib, so that it may benefit from the cache maintenance that we will add to it later. The difference between the current version of ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf and [...]/ArmVirtualizationMemoryInitPeiLib/ArmVirtualizationMemoryInitPeiLib.inf is that the former addresses an issue where the FD region lives in system RAM, which is never the case for the QEMU target anyway. Patch #3 removes the threshold that 'promotes' a cache maintenance by virtual address operation to a cache maintenance by set/way operation. The idea was presumably that, above a certain threshold, it is cheaper to just clean or invalidate the whole cache than to loop over a large memory range. However, set/way operations operate on the local caches only, and are not broadcast to other CPUs, nor do they affect system caches that are managed in an implementation specific way. So the only correct way to operate on a VA range is to loop over the VA range, unfortunately. Patch #4 adds invalidation of the PI/UEFI memory range to ArmVirtualizationPkg's implementation of MemoryInitPeiLib, and updates ArmVirtualizationQemu.dsc (the QEMU/KVM target) to switch to it. Also, for both QEMU/KVM and Xen, it reduces the size of this region to 16 MB (from 64 MB), which hopefully alleviates the perfomance hit a bit. Patch #5 adds invalidation of the FD region as well. Unlike under QEMU/KVM, where the FD region resides in emulated NOR flash, and is hence read-only, under Xen the FD region contains global variables, and is relocated at runtime. So here, we need to invalidate the FD region for the same reason we need to invalidate the PI/UEFI memory region. In addition, it moves the initialization of the SerialPortLib to after the MMU is up: this prevents problems with invoking hypercalls and/or accessing memory regions that are shared with the hypervisor, whose accesses to those regions go via the caches. Ard Biesheuvel (5): ArmPlatformPkg: do not fulfil MemoryInitPeiLib dependency directly via .c file ArmVirtualizationPkg: move Qemu target to ArmVirtualizationMemoryInitPeiLib ArmPkg: remove cache maintenance by VA operation range size threshold ArmVirtualizationPkg: invalidate PEI memory region by VA ArmVirtualizationPkg: Xen: shuffle init order to deal with incoherency ArmPkg/ArmPkg.dec | 3 +-- ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c | 29 +++++++++++------------------ ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf | 3 --- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.inf | 3 --- ArmPkg/Library/ArmLib/AArch64/AArch64LibPrePi.inf | 3 --- ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf | 3 --- ArmPkg/Library/ArmLib/Arm11/Arm11Lib.inf | 1 - ArmPkg/Library/ArmLib/Arm11/Arm11LibPrePi.inf | 1 - ArmPkg/Library/ArmLib/Arm11/Arm11LibSec.inf | 1 - ArmPkg/Library/ArmLib/Arm9/Arm9ArmLib.inf | 3 --- ArmPkg/Library/ArmLib/Arm9/Arm9ArmLibPrePi.inf | 3 --- ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf | 3 --- ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf | 3 --- ArmPkg/Library/ArmLib/ArmV7/ArmV7LibSec.inf | 3 --- ArmPkg/Library/ArmLib/Null/NullArmLib.inf | 3 --- ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualization.dsc.inc | 1 + ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 6 ++++-- ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationXen.dsc | 4 ++-- ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationMemoryInitPeiLib/ArmVirtualizationMemoryInitPeiLib.c | 10 ++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationMemoryInitPeiLib/ArmVirtualizationMemoryInitPeiLib.inf | 1 + ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 + ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c | 20 ++++++++++++++------ ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf | 2 +- ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf | 2 +- 24 files changed, 47 insertions(+), 65 deletions(-) -- 1.8.3.2 ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel