render / rpms / edk2

Forked from rpms/edk2 2 months ago
Clone

Blame SOURCES/edk2-ArmVirt-don-t-use-unaligned-CopyMem-on-NOR-flash.patch

8ff9b3
From f6d83cd74def6af6ab27ddda15112cdf59c853d5 Mon Sep 17 00:00:00 2001
8ff9b3
From: Gerd Hoffmann <kraxel@redhat.com>
8ff9b3
Date: Mon, 16 Jan 2023 10:46:39 +0100
8ff9b3
Subject: [PATCH] ArmVirt: don't use unaligned CopyMem () on NOR flash
8ff9b3
8ff9b3
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
8ff9b3
RH-MergeRequest: 23: ArmVirt: don't use unaligned CopyMem () on NOR flash
8ff9b3
RH-Bugzilla: 2158173
8ff9b3
RH-Acked-by: Oliver Steffen <osteffen@redhat.com>
8ff9b3
RH-Commit: [1/1] 7c8b7e5cd9c239dd8d040450bd4d479ef789114b (kraxel/centos-edk2)
8ff9b3
8ff9b3
Commit 789a72328553 reclassified the NOR flash region as EFI_MEMORY_WC
8ff9b3
in the OS visible EFI memory map, and dropped the explicit aligned
8ff9b3
CopyMem() implementation, in the assumption that EFI_MEMORY_WC will be
8ff9b3
honored by the OS, and that the region will be mapped in a way that
8ff9b3
tolerates misaligned accesseses. However, Linux today uses device
8ff9b3
attributes for all EFI MMIO regions, in spite of the memory type
8ff9b3
attributes, and so using misaligned accesses is never safe.
8ff9b3
8ff9b3
So instead, switch to the generic CopyMem() implementation entirely,
8ff9b3
just like we already did for VariableRuntimeDxe.
8ff9b3
8ff9b3
Fixes: 789a72328553 ("OvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and drop AlignedCopyMem()")
8ff9b3
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
8ff9b3
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
8ff9b3
(cherry picked from commit 987cc09c7cf38d628063062483e2341fba679b0e)
8ff9b3
---
8ff9b3
 ArmVirtPkg/ArmVirtKvmTool.dsc    | 6 +++++-
8ff9b3
 ArmVirtPkg/ArmVirtQemu.dsc       | 6 +++++-
8ff9b3
 ArmVirtPkg/ArmVirtQemuKernel.dsc | 6 +++++-
8ff9b3
 3 files changed, 15 insertions(+), 3 deletions(-)
8ff9b3
8ff9b3
diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc
8ff9b3
index 2ba00bd08f..d0afe1b49e 100644
8ff9b3
--- a/ArmVirtPkg/ArmVirtKvmTool.dsc
8ff9b3
+++ b/ArmVirtPkg/ArmVirtKvmTool.dsc
8ff9b3
@@ -296,7 +296,11 @@
8ff9b3
       NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
8ff9b3
   }
8ff9b3
 
8ff9b3
-  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
8ff9b3
+  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf {
8ff9b3
+    <LibraryClasses>
8ff9b3
+      # don't use unaligned CopyMem () on the UEFI varstore NOR flash region
8ff9b3
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
8ff9b3
+  }
8ff9b3
 
8ff9b3
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
8ff9b3
 
8ff9b3
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
8ff9b3
index a4bd72e481..76389e6bd4 100644
8ff9b3
--- a/ArmVirtPkg/ArmVirtQemu.dsc
8ff9b3
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
8ff9b3
@@ -428,7 +428,11 @@
8ff9b3
     <LibraryClasses>
8ff9b3
       NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
8ff9b3
   }
8ff9b3
-  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
8ff9b3
+  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf {
8ff9b3
+    <LibraryClasses>
8ff9b3
+      # don't use unaligned CopyMem () on the UEFI varstore NOR flash region
8ff9b3
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
8ff9b3
+  }
8ff9b3
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
8ff9b3
 
8ff9b3
   #
8ff9b3
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
8ff9b3
index 7f85b0dc92..0445a89b1c 100644
8ff9b3
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
8ff9b3
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
8ff9b3
@@ -331,7 +331,11 @@
8ff9b3
     <LibraryClasses>
8ff9b3
       NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
8ff9b3
   }
8ff9b3
-  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf
8ff9b3
+  OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf {
8ff9b3
+    <LibraryClasses>
8ff9b3
+      # don't use unaligned CopyMem () on the UEFI varstore NOR flash region
8ff9b3
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
8ff9b3
+  }
8ff9b3
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
8ff9b3
 
8ff9b3
   #
8ff9b3
-- 
8ff9b3
2.31.1
8ff9b3