Skip to content

RFC mm, kvm: add guest_memfd support for uffd minor faults

Mike Rapoport kvm linux-kselftest linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4userfaultfd: move vma_can_userfault out of lineinclude/linux/userfaultfd_k.h mm/userfaultfd.c+36 -341 reply
2/4userfaultfd, shmem: use a VMA callback to handle UFFDIO_CONTINUEinclude/linux/mm.h mm/shmem.c mm/userfaultfd.c+69 -202 replies
3/4userfaultfd, guest_memfd: support userfault minor mode in guest_memfdfs/userfaultfd.c include/uapi/linux/userfaultfd.h virt/kvm/guest_memfd.c+40 -22 replies
4/4KVM: selftests: test userfaultfd minor for guest_memfdtools/testing/selftests/kvm/guest_memfd_test.c+103 -00 replies

Reviews trailers per patch

1 of 4 patches has a Reviewed-by or Acked-by.

PatchDavid Hildenbrand (Red Hat)
1/4R-b
2/4
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC PATCH 0/4] mm, kvm: add guest_memfd support for uffd minor faults

From: "Mike Rapoport (Microsoft)" <[email protected]>

Hi,

These patches allow guest_memfd to notify userspace about minor page faults using userfaultfd and let userspace to resolve these page faults using UFFDIO_CONTINUE.

To allow UFFDIO_CONTINUE outside of the core mm I added a get_pagecache_folio() callback to vm_ops that allows an address space backing a VMA to return a folio that exists in it's page cache (patch 2)

In order for guest_memfd to notify userspace about page faults, it has to call handle_userfault() and since guest_memfd may be a part of kvm module, handle_userfault() is exported for kvm module (patch 3).

Note that patch 3 changelog does not provide motivation for enabling uffd in guest_memfd, mainly because I can't say I understand why is that required :)
Would be great to hear from KVM folks about it.

This series is the minimal change I've been able to come up with to allow integration of guest_memfd with uffd and while refactoring uffd and making mfill_atomic() flow more linear would have been a nice improvement, it's way out of the scope of enabling uffd with guest_memfd.

Mike Rapoport (Microsoft) (3):
userfaultfd: move vma_can_userfault out of line userfaultfd, shmem: use a VMA callback to handle UFFDIO_CONTINUE userfaultfd, guest_memfd: support userfault minor mode in guest_memfd

Nikita Kalyazin (1):
KVM: selftests: test userfaultfd minor for guest_memfd

 fs/userfaultfd.c                              |   4 +-
 include/linux/mm.h                            |   9 ++
 include/linux/userfaultfd_k.h                 |  36 +-----
 include/uapi/linux/userfaultfd.h              |   8 +-
 mm/shmem.c                                    |  20 ++++
 mm/userfaultfd.c                              |  88 ++++++++++++---
 .../testing/selftests/kvm/guest_memfd_test.c  | 103 ++++++++++++++++++
 virt/kvm/guest_memfd.c                        |  30 +++++
 8 files changed, 245 insertions(+), 53 deletions(-)

base-commit: 6146a0f1dfae5d37442a9ddcba012add260bceb0

Signature · 1 line
2.50.1