Skip to content

KVM: guest_memfd: support for uffd minor

Nikita Kalyazin kvm linux-fsdevel linux-kselftest linux-mm lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest6 patches 21 repliesIn review
  2. v25 patches 6 repliesSuperseded
  3. v1 RFC5 patches 16 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6mm: userfaultfd: generic continue for non hugetlbfsinclude/linux/mm_types.h mm/hugetlb.c mm/shmem.c +1 more+38 -146 replies
2/6mm: provide can_userfault vma operationinclude/linux/mm.h mm/hugetlb.c mm/shmem.c+20 -00 replies
3/6mm: userfaultfd: use can_userfault vma operationinclude/linux/userfaultfd_k.h mm/userfaultfd.c+13 -100 replies
4/6KVM: guest_memfd: add support for userfaultfd minorvirt/kvm/guest_memfd.c+10 -02 replies
5/6mm: userfaultfd: add UFFD_FEATURE_MINOR_GUEST_MEMFDfs/userfaultfd.c include/uapi/linux/userfaultfd.h+9 -20 replies
6/6KVM: selftests: test userfaultfd minor for guest_memfdtools/testing/selftests/kvm/guest_memfd_test.c+99 -00 replies

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH v3 0/6] KVM: guest_memfd: support for uffd minor

This series is built on top of the Fuad's v7 "mapping guest_memfd backed memory at the host" [1].

With James's KVM userfault [2], it is possible to handle stage-2 faults in guest_memfd in userspace. However, KVM itself also triggers faults in guest_memfd in some cases, for example: PV interfaces like kvmclock, PV EOI and page table walking code when fetching the MMIO instruction on x86. It was agreed in the guest_memfd upstream call on 23 Jan 2025 [3] that KVM would be accessing those pages via userspace page tables. In order for such faults to be handled in userspace, guest_memfd needs to support userfaultfd.

Changes since v2 [4]:
- James: Fix sgp type when calling shmem_get_folio_gfp
- James: Improved vm_ops->fault() error handling
- James: Add and make use of the can_userfault() VMA operation
- James: Add UFFD_FEATURE_MINOR_GUEST_MEMFD feature flag
- James: Fix typos and add more checks in the test

Nikita

[1] https://lore.kernel.org/kvm/[email protected]/T/
[2] https://lore.kernel.org/kvm/[email protected]/T/
[3] https://docs.google.com/document/d/1M6766BzdY1Lhk7LiR5IqVR8B8mG3cr-cxTxOrAosPOk/edit?tab=t.0#heading=h.w1126rgli5e3
[4] https://lore.kernel.org/kvm/[email protected]/T/

Nikita Kalyazin (6):
mm: userfaultfd: generic continue for non hugetlbfs
mm: provide can_userfault vma operation
mm: userfaultfd: use can_userfault vma operation
KVM: guest_memfd: add support for userfaultfd minor
mm: userfaultfd: add UFFD_FEATURE_MINOR_GUEST_MEMFD
KVM: selftests: test userfaultfd minor for guest_memfd

 fs/userfaultfd.c                              |  3 +-
 include/linux/mm.h                            |  5 +
 include/linux/mm_types.h                      |  4 +
 include/linux/userfaultfd_k.h                 | 10 +-
 include/uapi/linux/userfaultfd.h              |  8 +-
 mm/hugetlb.c                                  |  9 +-
 mm/shmem.c                                    | 17 +++-
 mm/userfaultfd.c                              | 47 ++++++---
 .../testing/selftests/kvm/guest_memfd_test.c  | 99 +++++++++++++++++++
 virt/kvm/guest_memfd.c                        | 10 ++
 10 files changed, 188 insertions(+), 24 deletions(-)

base-commit: 3cc51efc17a2c41a480eed36b31c1773936717e0

Signature · 1 line
2.47.1