Main changes since v11 [1]: - Addressed various points of feedback from the last revision. - Rebased on Linux 6.16-rc1. This patch series enables mapping of guest_memfd backed memory in the host. This is useful for VMMs like Firecracker that aim to run guests entirely backed by guest_memfd [2]. When combined with Patrick's series for direct map removal [3], this provides additional hardening against Spectre-like transient execution attacks. This series also lays the groundwork for restricted mmap() support for guest_memfd backed memory in the host for Confidential Computing platforms that permit in-place sharing of guest memory with the host [4]. Patch breakdown: Patches 1-7: Primarily refactoring and renaming to decouple the concept of guest memory being "private" from it being backed by guest_memfd. Patches 8-9: Add support for in-place shared memory and the ability for the host to map it. This is gated by a new configuration option, toggled by a new flag, and advertised to userspace by a new capability (introduced in patch 16). Patches 10-15: Implement the x86 and arm64 support for this feature. Patch 16: Introduces the new capability to advertise this support and updates the documentation. Patches 17-18: Add and fix selftests for the new functionality. For details on how to test this patch series, and on how to boot a guest that uses the new features, please refer to the instructions in v8 [5], but use the updated kvmtool for 6.16 (KVM_CAP_GMEM_SHARED_MEM number has changed) [6]. Cheers, /fuad [1] https://lore.kernel.org/all/20250605153800.557144-1-tabba@xxxxxxxxxx/ [2] https://github.com/firecracker-microvm/firecracker/tree/feature/secret-hiding [3] https://lore.kernel.org/all/20250221160728.1584559-1-roypat@xxxxxxxxxxxx/ [4] https://lore.kernel.org/all/20250328153133.3504118-1-tabba@xxxxxxxxxx/ [5] https://lore.kernel.org/all/20250430165655.605595-1-tabba@xxxxxxxxxx/ [6] https://android-kvm.googlesource.com/kvmtool/+/refs/heads/tabba/guestmem-basic-6.16 Ackerley Tng (2): KVM: x86/mmu: Handle guest page faults for guest_memfd with shared memory KVM: x86: Consult guest_memfd when computing max_mapping_level Fuad Tabba (16): KVM: Rename CONFIG_KVM_PRIVATE_MEM to CONFIG_KVM_GMEM KVM: Rename CONFIG_KVM_GENERIC_PRIVATE_MEM to CONFIG_KVM_GENERIC_GMEM_POPULATE KVM: Rename kvm_arch_has_private_mem() to kvm_arch_supports_gmem() KVM: x86: Rename kvm->arch.has_private_mem to kvm->arch.supports_gmem KVM: Rename kvm_slot_can_be_private() to kvm_slot_has_gmem() KVM: Fix comments that refer to slots_lock KVM: Fix comment that refers to kvm uapi header path KVM: guest_memfd: Allow host to map guest_memfd pages KVM: guest_memfd: Track shared memory support in memslot KVM: x86: Enable guest_memfd shared memory for non-CoCo VMs KVM: arm64: Refactor user_mem_abort() KVM: arm64: Handle guest_memfd-backed guest page faults KVM: arm64: Enable host mapping of shared guest_memfd memory KVM: Introduce the KVM capability KVM_CAP_GMEM_SHARED_MEM KVM: selftests: Don't use hardcoded page sizes in guest_memfd test KVM: selftests: guest_memfd mmap() test when mapping is allowed Documentation/virt/kvm/api.rst | 9 + arch/arm64/include/asm/kvm_host.h | 4 + arch/arm64/kvm/Kconfig | 1 + arch/arm64/kvm/mmu.c | 189 ++++++++++++---- arch/x86/include/asm/kvm_host.h | 22 +- arch/x86/kvm/Kconfig | 5 +- arch/x86/kvm/mmu/mmu.c | 135 ++++++----- arch/x86/kvm/svm/sev.c | 4 +- arch/x86/kvm/svm/svm.c | 4 +- arch/x86/kvm/x86.c | 4 +- include/linux/kvm_host.h | 80 +++++-- include/uapi/linux/kvm.h | 2 + tools/testing/selftests/kvm/Makefile.kvm | 1 + .../testing/selftests/kvm/guest_memfd_test.c | 212 +++++++++++++++--- virt/kvm/Kconfig | 14 +- virt/kvm/Makefile.kvm | 2 +- virt/kvm/guest_memfd.c | 91 +++++++- virt/kvm/kvm_main.c | 16 +- virt/kvm/kvm_mm.h | 4 +- 19 files changed, 630 insertions(+), 169 deletions(-) base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494 -- 2.50.0.rc0.642.g800a2b2222-goog