]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirt: don't use unaligned CopyMem () on NOR flash
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 16 Jan 2023 09:46:39 +0000 (10:46 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 16 Jan 2023 11:43:02 +0000 (11:43 +0000)
Commit 789a72328553 reclassified the NOR flash region as EFI_MEMORY_WC
in the OS visible EFI memory map, and dropped the explicit aligned
CopyMem() implementation, in the assumption that EFI_MEMORY_WC will be
honored by the OS, and that the region will be mapped in a way that
tolerates misaligned accesseses. However, Linux today uses device
attributes for all EFI MMIO regions, in spite of the memory type
attributes, and so using misaligned accesses is never safe.

So instead, switch to the generic CopyMem() implementation entirely,
just like we already did for VariableRuntimeDxe.

Fixes: 789a72328553 ("OvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and drop AlignedCopyMem()")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
ArmVirtPkg/ArmVirtKvmTool.dsc
ArmVirtPkg/ArmVirtQemu.dsc
ArmVirtPkg/ArmVirtQemuKernel.dsc

index 2ba00bd08ff1813d91456a7ad4b6924712b2a79f..d0afe1b49e250c554313c2077b89650d6f6d67cb 100644 (file)
       NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf\r
   }\r
 \r
-  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf\r
+  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf {\r
+    <LibraryClasses>\r
+      # don't use unaligned CopyMem () on the UEFI varstore NOR flash region\r
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
+  }\r
 \r
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
 \r
index 5dd8b6104ccaaeaeb509e23aed006f56090b99f7..0f1c6395488aa00d6a90e3a337c43f93c4d23916 100644 (file)
     <LibraryClasses>\r
       NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf\r
   }\r
-  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf\r
+  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf {\r
+    <LibraryClasses>\r
+      # don't use unaligned CopyMem () on the UEFI varstore NOR flash region\r
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
+  }\r
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
 \r
   #\r
index f5db3ac432f33c66ba441ede111636f6eece84f0..807c85d4828598de8add816946b6380d2036f23f 100644 (file)
     <LibraryClasses>\r
       NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf\r
   }\r
-  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf\r
+  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf {\r
+    <LibraryClasses>\r
+      # don't use unaligned CopyMem () on the UEFI varstore NOR flash region\r
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
+  }\r
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
 \r
   #\r