The OvmfPkg SEV-ES flash support uses a VMGEXIT call to perform an MMIO write to update the flash device. This support assumes an identity mapped address for the flash address (VA == PA). However, when done as part of the EFI runtime services after the SetVitualAddressMap() API has been called, the VA == PA assumption is no longer correct and the MMIO write fails.
The Qemu flash services needs to track the original base address, as this represents the physical address of the flash device. QemuFlashPtrWrite() can then use this address to always calculate the physical address even after SetVitualAddressMap() has been called.
v1: https://edk2.groups.io/g/devel/message/70692 https://www.redhat.com/archives/edk2-devel-archive/2021-January/msg01178.html msgid: <8bba19920e58813f32889dec522bbcd8de113219.1611338106.git.thomas.lendacky@amd.com>
v2: https://edk2.groups.io/g/devel/message/70703 https://www.redhat.com/archives/edk2-devel-archive/2021-January/msg01190.html msgid: <84a5f9161541db5aa3b57c96b737afbcb4b6189d.1611410263.git.thomas.lendacky@amd.com>
(In reply to thomas.lendacky from comment #3) >| v2: >| https://edk2.groups.io/g/devel/message/70703 >| https://www.redhat.com/archives/edk2-devel-archive/2021-January/msg01190.html >| msgid: <84a5f9161541db5aa3b57c96b737afbcb4b6189d.1611410263.git.thomas.lendacky@amd.com> Merged as commit 3a3501862f73, via <https://github.com/tianocore/edk2/pull/1389>.