audk/OvmfPkg/QemuFlashFvbServicesRuntimeDxe
Tom Lendacky 3a3501862f OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Use physical address with SEV-ES
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3183

Under SEV-ES, a write to the flash device is done using a direct VMGEXIT
to perform an MMIO write. The address provided to the MMIO write must be
the physical address of the MMIO write destitnation. During boot, OVMF
runs with an identity mapped pagetable structure so that VA == PA and the
VMGEXIT MMIO write destination is just the virtual address of the flash
area address being written.

However, when the UEFI SetVirtualAddressMap() API is invoked, an identity
mapped pagetable structure may not be in place and using the virtual
address for the flash area address is no longer valid. This results in
writes to the flash not being performed successfully. This can be seen
by attempting to change the boot order under Linux. The update will
appear to be performed, based on the output of the command. But rebooting
the guest will show that the new boot order has not been set.

To remedy this, save the value of the flash base physical address before
converting the address as part of SetVirtualAddressMap(). The physical
address can then be calculated by obtaining the offset of the MMIO target
virtual address relative to the flash base virtual address and adding that
to the original flash base physical address. The resulting value produces
a successful MMIO write during runtime services.

Fixes: 437eb3f7a8
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Message-Id: <84a5f9161541db5aa3b57c96b737afbcb4b6189d.1611410263.git.thomas.lendacky@amd.com>
[lersek@redhat.com: SetVitualAddressMap() -> SetVirtualAddressMap() typo
 fix, in both the commit message and the code comment]
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2021-01-26 00:25:16 +00:00
..
FvbInfo.c OvmfPkg/Qemu: Fix various typos 2020-02-10 22:30:07 +00:00
FvbServicesRuntimeDxe.inf OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Bypass flash detection with SEV-ES 2020-08-17 02:46:39 +00:00
FvbServicesSmm.inf OvmfPkg: set fixed FlashNvStorage base addresses with -D SMM_REQUIRE 2020-03-12 21:14:46 +00:00
FwBlockService.c OvmfPkg: replace old EFI_D_ debug levels with new DEBUG_ ones 2020-04-30 13:01:16 +00:00
FwBlockService.h OvmfPkg/QemuFlashFvbServices: factor out SetPcdFlashNvStorageBaseAddresses 2020-03-12 21:14:46 +00:00
FwBlockServiceDxe.c OvmfPkg: replace old EFI_D_ debug levels with new DEBUG_ ones 2020-04-30 13:01:16 +00:00
FwBlockServiceSmm.c OvmfPkg: replace old EFI_D_ debug levels with new DEBUG_ ones 2020-04-30 13:01:16 +00:00
QemuFlash.c OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Fix erase blocks for SEV-ES 2020-11-10 19:07:55 +00:00
QemuFlash.h OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Bypass flash detection with SEV-ES 2020-08-17 02:46:39 +00:00
QemuFlashDxe.c OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Use physical address with SEV-ES 2021-01-26 00:25:16 +00:00
QemuFlashSmm.c OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Bypass flash detection with SEV-ES 2020-08-17 02:46:39 +00:00