render / rpms / edk2

Forked from rpms/edk2 3 months ago
Clone

Blame SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-map-flash-memory-as-uncachea.patch

795857
From a7e155d9d0be18b9db31dd7135e9da2bc955e6b4 Mon Sep 17 00:00:00 2001
795857
From: Gerd Hoffmann <kraxel@redhat.com>
795857
Date: Wed, 11 Jan 2023 19:00:23 +0100
795857
Subject: [PATCH 1/2] OvmfPkg/VirtNorFlashDxe: map flash memory as uncacheable
795857
795857
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
795857
RH-MergeRequest: 21: OvmfPkg/VirtNorFlashDxe: map flash memory as uncacheable
795857
RH-Bugzilla: 2158173
795857
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
795857
RH-Acked-by: Oliver Steffen <osteffen@redhat.com>
795857
RH-Commit: [1/1] 819cd72096fa9f253eef7b532122183b608c0064 (kraxel/centos-edk2)
795857
795857
Switching from the ArmPlatformPkg/NorFlashDxe driver to the
795857
OvmfPkg/VirtNorFlashDxe driver had the side effect that flash address
795857
space got registered as EFI_MEMORY_WC instead of EFI_MEMORY_UC.
795857
795857
That confuses the linux kernel's numa code, seems this makes kernel
795857
consider the flash being node memory.  "lsmem" changes from ...
795857
795857
    RANGE                                 SIZE  STATE REMOVABLE BLOCK
795857
    0x0000000040000000-0x000000013fffffff   4G online       yes  8-39
795857
795857
... to ...
795857
795857
    RANGE                                  SIZE  STATE REMOVABLE BLOCK
795857
    0x0000000000000000-0x0000000007ffffff  128M online       yes     0
795857
    0x0000000040000000-0x000000013fffffff    4G online       yes  8-39
795857
795857
... and in the kernel log got new error lines:
795857
795857
    NUMA: Warning: invalid memblk node 512 [mem 0x0000000004000000-0x0000000007ffffff]
795857
    NUMA: Faking a node at [mem 0x0000000004000000-0x000000013fffffff]
795857
795857
Changing the attributes back to EFI_MEMORY_UC fixes this.
795857
795857
Fixes: b92298af8218 ("ArmVirtPkg/ArmVirtQemu: migrate to OVMF's VirtNorFlashDxe")
795857
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
795857
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
795857
(cherry picked from commit e5ec3ba409b5baa9cf429cc25fdf3c8d1b8dcef0)
795857
---
795857
 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 4 ++--
795857
 1 file changed, 2 insertions(+), 2 deletions(-)
795857
795857
diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
795857
index ff3121af2a..f9a41f6aab 100644
795857
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
795857
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
795857
@@ -394,14 +394,14 @@ NorFlashFvbInitialize (
795857
                   EfiGcdMemoryTypeMemoryMappedIo,
795857
                   Instance->DeviceBaseAddress,
795857
                   RuntimeMmioRegionSize,
795857
-                  EFI_MEMORY_WC | EFI_MEMORY_RUNTIME
795857
+                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
795857
                   );
795857
   ASSERT_EFI_ERROR (Status);
795857
 
795857
   Status = gDS->SetMemorySpaceAttributes (
795857
                   Instance->DeviceBaseAddress,
795857
                   RuntimeMmioRegionSize,
795857
-                  EFI_MEMORY_WC | EFI_MEMORY_RUNTIME
795857
+                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
795857
                   );
795857
   ASSERT_EFI_ERROR (Status);
795857
 
795857
-- 
795857
2.31.1
795857