render / rpms / edk2

Forked from rpms/edk2 3 months ago
Clone

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

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