[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a5531d06-dd11-402b-a701-a7c6a62186a7@amazon.com>
Date: Mon, 17 Nov 2025 17:55:46 +0000
From: Nikita Kalyazin <kalyazin@...zon.com>
To: Mike Rapoport <rppt@...nel.org>, <linux-mm@...ck.org>
CC: Andrea Arcangeli <aarcange@...hat.com>, Andrew Morton
<akpm@...ux-foundation.org>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
David Hildenbrand <david@...hat.com>, Hugh Dickins <hughd@...gle.com>, "Liam
R. Howlett" <Liam.Howlett@...cle.com>, Lorenzo Stoakes
<lorenzo.stoakes@...cle.com>, Michal Hocko <mhocko@...e.com>, Paolo Bonzini
<pbonzini@...hat.com>, Peter Xu <peterx@...hat.com>, Sean Christopherson
<seanjc@...gle.com>, Shuah Khan <shuah@...nel.org>, Suren Baghdasaryan
<surenb@...gle.com>, Vlastimil Babka <vbabka@...e.cz>,
<linux-kernel@...r.kernel.org>, <kvm@...r.kernel.org>,
<linux-kselftest@...r.kernel.org>
Subject: Re: [RFC PATCH 0/4] mm, kvm: add guest_memfd support for uffd minor
faults
On 17/11/2025 11:46, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@...nel.org>
>
> 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.
Hi Mike,
Thanks for posting it!
In our use case, Firecracker snapshot-restore using UFFD [1], we will
use UFFD minor/continue to respond to guest_memfd faults in user
mappings primarily due to VMM accesses that are required for PV (virtio)
device emulation and also KVM accesses when decoding MMIO operations on x86.
Nikita
[1]
https://github.com/firecracker-microvm/firecracker/blob/main/docs/snapshotting/handling-page-faults-on-snapshot-resume.md
>
> 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
> --
> 2.50.1
>
Powered by blists - more mailing lists