linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v11 00/18] KVM: Mapping guest_memfd backed memory at the host for software protected VMs
@ 2025-06-05 15:37 Fuad Tabba
  2025-06-05 15:37 ` [PATCH v11 01/18] KVM: Rename CONFIG_KVM_PRIVATE_MEM to CONFIG_KVM_GMEM Fuad Tabba
                   ` (18 more replies)
  0 siblings, 19 replies; 56+ messages in thread
From: Fuad Tabba @ 2025-06-05 15:37 UTC (permalink / raw)
  To: kvm, linux-arm-msm, linux-mm, kvmarm
  Cc: pbonzini, chenhuacai, mpe, anup, paul.walmsley, palmer, aou,
	seanjc, viro, brauner, willy, akpm, xiaoyao.li, yilun.xu,
	chao.p.peng, jarkko, amoorthy, dmatlack, isaku.yamahata, mic,
	vbabka, vannapurve, ackerleytng, mail, david, michael.roth,
	wei.w.wang, liam.merwick, isaku.yamahata, kirill.shutemov,
	suzuki.poulose, steven.price, quic_eberman, quic_mnalajal,
	quic_tsoni, quic_svaddagi, quic_cvanscha, quic_pderrin,
	quic_pheragu, catalin.marinas, james.morse, yuzenghui,
	oliver.upton, maz, will, qperret, keirf, roypat, shuah, hch, jgg,
	rientjes, jhubbard, fvdl, hughd, jthoughton, peterx, pankaj.gupta,
	ira.weiny, tabba

Main changes since v10 [1]:
- Added bounds checking when faulting a shared page into the host, along
  with a selftest to verify the check.
- Refactored KVM/arm64's handling of guest faults (user_mem_abort()).
  I've dropped the Reviewed-by tags from "KVM: arm64: Refactor
  user_mem_abort()..." since it has changed significantly.
- Handled nested virtualization in KVM/arm64 when faulting guest_memfd
  backed pages into the guest.
- Addressed various points of feedback from the last revision.
- Still based on Linux 6.15

This patch series enables the 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 v8 [5].

Cheers,
/fuad

[1] https://lore.kernel.org/all/20250527180245.1413463-1-tabba@google.com/
[2] https://github.com/firecracker-microvm/firecracker/tree/feature/secret-hiding
[3] https://lore.kernel.org/all/20250221160728.1584559-1-roypat@amazon.co.uk/
[4] https://lore.kernel.org/all/20250328153133.3504118-1-tabba@google.com/
[5] https://lore.kernel.org/all/20250430165655.605595-1-tabba@google.com/

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 SW-protected 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             |   5 +
 arch/arm64/kvm/Kconfig                        |   1 +
 arch/arm64/kvm/mmu.c                          | 200 +++++++++++++----
 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                        |  94 +++++++-
 virt/kvm/kvm_main.c                           |  16 +-
 virt/kvm/kvm_mm.h                             |   4 +-
 19 files changed, 645 insertions(+), 169 deletions(-)


base-commit: 0ff41df1cb268fc69e703a08a57ee14ae967d0ca
-- 
2.49.0.1266.g31b7d2e469-goog



^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2025-06-11 18:20 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05 15:37 [PATCH v11 00/18] KVM: Mapping guest_memfd backed memory at the host for software protected VMs Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 01/18] KVM: Rename CONFIG_KVM_PRIVATE_MEM to CONFIG_KVM_GMEM Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 02/18] KVM: Rename CONFIG_KVM_GENERIC_PRIVATE_MEM to CONFIG_KVM_GENERIC_GMEM_POPULATE Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 03/18] KVM: Rename kvm_arch_has_private_mem() to kvm_arch_supports_gmem() Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 04/18] KVM: x86: Rename kvm->arch.has_private_mem to kvm->arch.supports_gmem Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 05/18] KVM: Rename kvm_slot_can_be_private() to kvm_slot_has_gmem() Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 06/18] KVM: Fix comments that refer to slots_lock Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 07/18] KVM: Fix comment that refers to kvm uapi header path Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 08/18] KVM: guest_memfd: Allow host to map guest_memfd pages Fuad Tabba
2025-06-06  9:12   ` David Hildenbrand
2025-06-06  9:30     ` Fuad Tabba
2025-06-06  9:55       ` David Hildenbrand
2025-06-06 10:33         ` Fuad Tabba
2025-06-11  6:29     ` Shivank Garg
2025-06-11 18:20       ` Ackerley Tng
2025-06-08 23:42   ` Gavin Shan
2025-06-05 15:37 ` [PATCH v11 09/18] KVM: guest_memfd: Track shared memory support in memslot Fuad Tabba
2025-06-06  9:13   ` David Hildenbrand
2025-06-08 23:42   ` Gavin Shan
2025-06-05 15:37 ` [PATCH v11 10/18] KVM: x86/mmu: Handle guest page faults for guest_memfd with shared memory Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 11/18] KVM: x86: Consult guest_memfd when computing max_mapping_level Fuad Tabba
2025-06-06  9:14   ` David Hildenbrand
2025-06-06  9:48     ` Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 12/18] KVM: x86: Enable guest_memfd shared memory for SW-protected VMs Fuad Tabba
2025-06-05 15:49   ` David Hildenbrand
2025-06-05 16:11     ` Fuad Tabba
2025-06-05 17:35       ` David Hildenbrand
2025-06-05 17:43         ` Fuad Tabba
2025-06-05 17:45           ` David Hildenbrand
2025-06-05 18:29             ` Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 13/18] KVM: arm64: Refactor user_mem_abort() Fuad Tabba
2025-06-09  0:27   ` Gavin Shan
2025-06-09  7:01     ` Fuad Tabba
2025-06-09  9:02       ` Gavin Shan
2025-06-05 15:37 ` [PATCH v11 14/18] KVM: arm64: Handle guest_memfd-backed guest page faults Fuad Tabba
2025-06-05 17:21   ` James Houghton
2025-06-06  7:31     ` Fuad Tabba
2025-06-06  7:39       ` David Hildenbrand
2025-06-09  4:08   ` Gavin Shan
2025-06-09  7:04     ` Fuad Tabba
2025-06-09  9:06       ` Gavin Shan
2025-06-05 15:37 ` [PATCH v11 15/18] KVM: arm64: Enable host mapping of shared guest_memfd memory Fuad Tabba
2025-06-05 17:26   ` James Houghton
2025-06-09  0:29   ` Gavin Shan
2025-06-05 15:37 ` [PATCH v11 16/18] KVM: Introduce the KVM capability KVM_CAP_GMEM_SHARED_MEM Fuad Tabba
2025-06-05 15:37 ` [PATCH v11 17/18] KVM: selftests: Don't use hardcoded page sizes in guest_memfd test Fuad Tabba
2025-06-06  8:15   ` David Hildenbrand
2025-06-08 23:43   ` Gavin Shan
2025-06-05 15:38 ` [PATCH v11 18/18] KVM: selftests: guest_memfd mmap() test when mapping is allowed Fuad Tabba
2025-06-05 22:07   ` James Houghton
2025-06-05 22:12     ` Sean Christopherson
2025-06-05 22:17       ` James Houghton
2025-06-06  8:14     ` Fuad Tabba
2025-06-08 23:43   ` Gavin Shan
2025-06-09  7:06     ` Fuad Tabba
2025-06-06  9:18 ` [PATCH v11 00/18] KVM: Mapping guest_memfd backed memory at the host for software protected VMs David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).