]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/VirtNorFlashDxe: map flash memory as uncacheable
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 11 Jan 2023 18:00:23 +0000 (19:00 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 12 Jan 2023 10:37:16 +0000 (10:37 +0000)
Switching from the ArmPlatformPkg/NorFlashDxe driver to the
OvmfPkg/VirtNorFlashDxe driver had the side effect that flash address
space got registered as EFI_MEMORY_WC instead of EFI_MEMORY_UC.

That confuses the linux kernel's numa code, seems this makes kernel
consider the flash being node memory.  "lsmem" changes from ...

    RANGE                                 SIZE  STATE REMOVABLE BLOCK
    0x0000000040000000-0x000000013fffffff   4G online       yes  8-39

... to ...

    RANGE                                  SIZE  STATE REMOVABLE BLOCK
    0x0000000000000000-0x0000000007ffffff  128M online       yes     0
    0x0000000040000000-0x000000013fffffff    4G online       yes  8-39

... and in the kernel log got new error lines:

    NUMA: Warning: invalid memblk node 512 [mem 0x0000000004000000-0x0000000007ffffff]
    NUMA: Faking a node at [mem 0x0000000004000000-0x000000013fffffff]

Changing the attributes back to EFI_MEMORY_UC fixes this.

Fixes: b92298af8218 ("ArmVirtPkg/ArmVirtQemu: migrate to OVMF's VirtNorFlashDxe")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c

index ff3121af2a4003b6f84ea4cfd202c9bb0157b3f7..f9a41f6aab0f9189a625fc02501e068e732945cb 100644 (file)
@@ -394,14 +394,14 @@ NorFlashFvbInitialize (
                   EfiGcdMemoryTypeMemoryMappedIo,\r
                   Instance->DeviceBaseAddress,\r
                   RuntimeMmioRegionSize,\r
-                  EFI_MEMORY_WC | EFI_MEMORY_RUNTIME\r
+                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   Status = gDS->SetMemorySpaceAttributes (\r
                   Instance->DeviceBaseAddress,\r
                   RuntimeMmioRegionSize,\r
-                  EFI_MEMORY_WC | EFI_MEMORY_RUNTIME\r
+                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r