This series adds restricted mmap() support to guest_memfd, as well as support for guest_memfd on arm64. It is based on Linux 6.13-rc7. Please refer to v3 for the context [1]. Main changes since v4 [2]: - Fixed handling of guest_memfd()-backed page faults in arm64 - Rebased on Linux 6.13-rc7 Not a change per se, but I am able to trigger/test the callback on the final __folio_put() using vmsplice to grab a reference without increasing the mapcount. The state diagram that uses the new states in this patch series, and how they would interact with sharing/unsharing in pKVM [3]. Cheers, /fuad [1] https://lore.kernel.org/all/20241010085930.1546800-1-tabba@xxxxxxxxxx/ [2] https://lore.kernel.org/all/20241213164811.2006197-1-tabba@xxxxxxxxxx/ [3] https://lpc.events/event/18/contributions/1758/attachments/1457/3699/Guestmemfd%20folio%20state%20page_type.pdf Ackerley Tng (2): KVM: guest_memfd: Make guest mem use guest mem inodes instead of anonymous inodes KVM: guest_memfd: Track mappability within a struct kvm_gmem_private Fuad Tabba (13): mm: Consolidate freeing of typed folios on final folio_put() KVM: guest_memfd: Introduce kvm_gmem_get_pfn_locked(), which retains the folio lock KVM: guest_memfd: Folio mappability states and functions that manage their transition KVM: guest_memfd: Handle final folio_put() of guestmem pages KVM: guest_memfd: Allow host to mmap guest_memfd() pages when shared KVM: guest_memfd: Add guest_memfd support to kvm_(read|/write)_guest_page() KVM: guest_memfd: Add KVM capability to check if guest_memfd is host mappable KVM: guest_memfd: Add a guest_memfd() flag to initialize it as mappable KVM: guest_memfd: selftests: guest_memfd mmap() test when mapping is allowed KVM: arm64: Skip VMA checks for slots without userspace address KVM: arm64: Refactor user_mem_abort() calculation of force_pte KVM: arm64: Handle guest_memfd()-backed guest page faults KVM: arm64: Enable guest_memfd private memory when pKVM is enabled Documentation/virt/kvm/api.rst | 4 + arch/arm64/include/asm/kvm_host.h | 3 + arch/arm64/kvm/Kconfig | 1 + arch/arm64/kvm/mmu.c | 98 ++- include/linux/kvm_host.h | 80 +++ include/linux/page-flags.h | 22 + include/uapi/linux/kvm.h | 2 + include/uapi/linux/magic.h | 1 + mm/debug.c | 1 + mm/swap.c | 28 +- tools/testing/selftests/kvm/Makefile | 1 + .../testing/selftests/kvm/guest_memfd_test.c | 64 +- virt/kvm/Kconfig | 4 + virt/kvm/guest_memfd.c | 579 +++++++++++++++++- virt/kvm/kvm_main.c | 234 ++++++- 15 files changed, 1034 insertions(+), 88 deletions(-) base-commit: 5bc55a333a2f7316b58edc7573e8e893f7acb532 -- 2.48.0.rc2.279.g1de40edade-goog