summaryrefslogtreecommitdiff
path: root/scripts/cleanpatch
diff options
context:
space:
mode:
authorSasha Levin <sashal@kernel.org>2026-10-27 15:19:14 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2026-11-20 15:31:15 +0100
commitc0710989d7ebedf4b0130b08ad7dd3f65d026fe8 (patch)
treee6ae23ed819b5e0858df110c3f278401e21f15d0 /scripts/cleanpatch
parent031ef175269d11b6368a9bff71a6a14aaa52b3f4 (diff)
KVM: x86: Don't save the GPA of a fault on the guest's page tables
When a #NPF or EPT violation on a direct MMU leads to emulation, x86_emulate_instruction() saves the faulting GPA to avoid a table walk. However, if the fault occurred while the CPU was walking the guest's page tables (PFERR_GUEST_PAGE_MASK), the GPA is that of a guest paging structure, not of the access being emulated, and the access goes to the wrong address. KVM selftest set_memory_region_test runs into this on AMD. test_delete_memory_region() deletes the memslot holding the guest's page tables while the guest spins on a read of 0xc0000000 that userspace handles as MMIO. If the vCPU is at the read when the memslot goes away, the CPU takes a #NPF on the guest's root page table at 0x180000. DecodeAssist provides the instruction bytes, the read of 0xc0000000 has the same page offset as 0x180000, and the emulator turns it into an MMIO read of 0x180000: ==== Test Assertion Failure ==== set_memory_region_test.c:83: run->mmio.phys_addr == MEM_REGION_GPA ... Unexpected exit mmio address = 0x180000 If the vCPU is at the next instruction instead, the #NPF happens on the code fetch, DecodeAssist provides no bytes, KVM fails to fetch the instruction itself and injects a #PF, and the guest shuts down as the test expects. KernelCI sees the failure in about half of the runs on a DL345 Gen11 (EPYC). Tell the emulator when the fault occurred on the guest's page tables and don't use the GPA for the access then, so that the emulator does perform the guest page table walk and the correct gpa is reported for KVM_EXIT_MMIO. Fixes: 0f89b207b04a ("kvm: svm: Use the hardware provided GPA instead of page walk") Signed-off-by: Sasha Levin <sashal@kernel.org> Link: https://patch.msgid.link/20261027191914.2341911-1-sashal@kernel.org [Paolo: extract SEV change to a separate commit] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'scripts/cleanpatch')
0 files changed, 0 insertions, 0 deletions