Skip to content

RFC kvm,x86,async_pf: Add capability to return page fault error

Vivek Goyal kvm lkml oe-kbuild-all virtio-fs 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4kvm: Add capability to be able to report async pf error to guestDocumentation/virt/kvm/cpuid.rst Documentation/virt/kvm/msr.rst arch/x86/include/asm/kvm_host.h +8 more+63 -160 replies
2/4kvm: async_pf: Send faulting gva address in case of errorarch/x86/include/asm/kvm_host.h arch/x86/include/asm/kvm_para.h arch/x86/include/asm/vmx.h +6 more+90 -360 replies
3/4kvm: Always get async page notificationsarch/x86/kernel/kvm.c+0 -20 replies
4/4kvm,x86,async_pf: Search exception tables in case of errorarch/x86/include/asm/kvm_para.h arch/x86/kernel/kvm.c arch/x86/kvm/mmu/mmu.c+22 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/4] kvm,x86,async_pf: Add capability to return page fault error

Current page fault logic in kvm seems to assume that host will always be able to successfully resolve page fault soon or later. There does not seem to be any mechanism for hypervisor to return an error say -EFAULT to guest.

We are writing DAX support for virtiofs filesystem. This will allow directly mapping host page cache page into guest user space process.

This mechanism now needs additional support from kvm where a page fault error needs to be propagated back into guest. For example, say guest process mmaped a file (and this did an mmap of portion of file on host into qemu address space). Now file gets truncated and guest process tries to access mapped region. It will generate page fault in host and it will try to map the file page. But page is not there any more so it will get back -EFAULT. But there is no mechanism to send this information back to guest and currently host sends PAGE_READY to guest, guest retries and fault happens again and host tries to resolve page fault again and this becomes an infinite loop.

This is an RFC patch series which tries to extend async page fault mechanism to also be able to communicate back that an error occurred while resolving the page fault. Then guest can send SIGBUS to guest process accessing the truncated portion of file. Or if access happened in guest kernel, then it can try to fixup the exception and jump to error handling portion if there is one.

This patch series tries to solve it only for x86 architecture on intel vmx only. Also it does not solve the problem for nested virtualization.

Is extending async page fault mechanism to report error back to guest is right thing to do? Or there needs to be another way.

Any feedback or comments are welcome.

Thanks
Vivek

Vivek Goyal (4):
kvm: Add capability to be able to report async pf error to guest
kvm: async_pf: Send faulting gva address in case of error
kvm: Always get async page notifications kvm,x86,async_pf: Search exception tables in case of error

 Documentation/virt/kvm/cpuid.rst     |  4 ++
 Documentation/virt/kvm/msr.rst       | 11 +++--
 arch/x86/include/asm/kvm_host.h      | 17 ++++++-
 arch/x86/include/asm/kvm_para.h      | 13 +++---
 arch/x86/include/asm/vmx.h           |  2 +
 arch/x86/include/uapi/asm/kvm_para.h | 12 ++++-
 arch/x86/kernel/kvm.c                | 69 ++++++++++++++++++++++------
 arch/x86/kvm/cpuid.c                 |  3 +-
 arch/x86/kvm/mmu/mmu.c               | 12 +++--
 arch/x86/kvm/vmx/nested.c            |  2 +-
 arch/x86/kvm/vmx/vmx.c               | 11 ++++-
 arch/x86/kvm/x86.c                   | 37 +++++++++++----
 include/linux/kvm_host.h             |  1 +
 virt/kvm/async_pf.c                  |  6 ++-
 14 files changed, 156 insertions(+), 44 deletions(-)
Signature · 1 line
2.25.1