summaryrefslogtreecommitdiff
path: root/scripts/basic/split-include.c
diff options
context:
space:
mode:
authorAnish Moorthy <amoorthy@google.com>2026-09-20 07:24:58 +0000
committerSean Christopherson <seanjc@google.com>2026-09-28 17:55:24 -0700
commit64f1cf2884403895feed3c442c65e1cb785945b9 (patch)
tree0683148600f4d23d2b59c8af6973a3d212f5360a /scripts/basic/split-include.c
parent98a843669196ace8789a859796e45caffb970e40 (diff)
downloadlinux-64f1cf2884403895feed3c442c65e1cb785945b9.tar.gz
linux-64f1cf2884403895feed3c442c65e1cb785945b9.zip
KVM: x86/mmu: Report a memory fault exit when the fault handler EFAULTs
KVM_CAP_MEMORY_FAULT_INFO documents that KVM_RUN will fill kvm_run.memory_fault when KVM cannot resolve a guest page fault VM-Exit, "e.g. if there is a valid memslot but no backing VMA for the corresponding host virtual address". kvm_handle_error_pfn() does not honor that guarantee. It returns a bare -EFAULT, leaving userspace with no indication of which guest physical address faulted, or even that the exit was a memory fault at all. Userspace cannot distinguish a transient, resolvable condition from a fatal one, so in practice the VMM terminates the guest. Fill kvm_run.memory_fault before returning -EFAULT. A concrete user is an Intel integrated GPU assigned to a guest via vfio-pci. The guest driver clears PCI_COMMAND.MEM on one vCPU while another vCPU is mid-MMIO to a BAR of the same device. Clearing PCI_COMMAND.MEM makes vfio-pci zap the BAR's mmap, so the second vCPU's fault finds a valid memslot whose VMA can no longer supply a PFN, and KVM_RUN fails with a bare -EFAULT. The VM dies, even though the guest did nothing architecturally invalid and the condition clears as soon as the driver re-enables memory decoding. Reproduce by pairing a vCPU that spins on accesses to the assigned device's BAR0 with a vCPU that toggles PCI_COMMAND.MEM; the race is hit within minutes. The same crash has been observed in the field on production edge hardware. Reporting the fault does not by itself define the access semantics. Userspace still has to decide what a read or write to a BAR with memory decoding disabled returns. But it is the information userspace needs in order to make that decision instead of killing the guest. Suggested-by: Sean Christopherson <seanjc@google.com> Fixes: 16f95f3b95ca ("KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace") Link: https://lore.kernel.org/all/20240809205158.1340255-1-amoorthy@google.com/ Link: https://lore.kernel.org/all/Zr-8M9rYplgN6IS3@google.com/ Signed-off-by: Anish Moorthy <amoorthy@google.com> Co-developed-by: Mikhail Malyshev <mike.malyshev@gmail.com> Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com> Link: https://patch.msgid.link/20260920072459.3485710-2-mike.malyshev@gmail.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'scripts/basic/split-include.c')
0 files changed, 0 insertions, 0 deletions