render / rpms / edk2

Forked from rpms/edk2 3 months ago
Clone

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

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