summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2022-10-24 18:16:18 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-10-27 16:52:01 +0000
commit789a723285533f35652ebd6029976e2ddc955655 (patch)
tree9c4ed78d05dc606d87d0e5d4f4b2c36e9af6c39f /OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
parent25589c4a76e7e3668fd6f794dd1827e958b6719c (diff)
downloadedk2-789a723285533f35652ebd6029976e2ddc955655.tar.gz
edk2-789a723285533f35652ebd6029976e2ddc955655.tar.bz2
edk2-789a723285533f35652ebd6029976e2ddc955655.zip
OvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and drop AlignedCopyMem()
NOR flash emulation under KVM involves switching between two modes, where array mode is backed by a read-only memslot, and programming mode is fully emulated, i.e., the memory region is not backed by anything, and the faulting accesses are forwarded to the VMM by the hypervisor, which translates them into NOR flash programming commands. Normally, we are limited to the use of device attributes when mapping such regions, given that the programming mode has MMIO semantics. However, when running under KVM, the chosen memory attributes only take effect when in array mode, since no memory mapping exists otherwise. This means we can tune the memory mapping so it behaves a bit more like a ROM, by switching to EFI_MEMORY_WC attributes. This means we no longer need a special CopyMem() implementation that avoids unaligned accesses at all cost. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
Diffstat (limited to 'OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c')
-rw-r--r--OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
index f9a41f6aab..ff3121af2a 100644
--- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c
@@ -394,14 +394,14 @@ NorFlashFvbInitialize (
EfiGcdMemoryTypeMemoryMappedIo,
Instance->DeviceBaseAddress,
RuntimeMmioRegionSize,
- EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
+ EFI_MEMORY_WC | EFI_MEMORY_RUNTIME
);
ASSERT_EFI_ERROR (Status);
Status = gDS->SetMemorySpaceAttributes (
Instance->DeviceBaseAddress,
RuntimeMmioRegionSize,
- EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
+ EFI_MEMORY_WC | EFI_MEMORY_RUNTIME
);
ASSERT_EFI_ERROR (Status);