From: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
To: linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>,
Ackerley Tng <ackerleytng@google.com>,
Alex Williamson <alex@shazbot.org>,
David Woodhouse <dwmw2@infradead.org>,
David Hildenbrand <david@kernel.org>,
Jason Gunthorpe <jgg@ziepe.ca>,
"Joerg Roedel (AMD)" <joro@8bytes.org>,
Kevin Tian <kevin.tian@intel.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Robin Murphy <robin.murphy@arm.com>,
Sean Christopherson <seanjc@google.com>,
Will Deacon <will@kernel.org>, Alexey Kardashevskiy <aik@amd.com>,
Xu Yilun <yilun.xu@linux.intel.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Steven Price <steven.price@arm.com>,
Fred Griffoul <griffoul@gmail.com>,
iommu@lists.linux.dev, kvm@vger.kernel.org
Subject: [RFC PATCH v1 0/6] KVM/VFIO: guest_memfd support for device MMIO resources
Date: Sat, 10 Oct 2026 12:54:58 +0530 [thread overview]
Message-ID: <20261010072504.536230-1-aneesh.kumar@kernel.org> (raw)
This series adds a guest_memfd device-resource framework for exposing PCI
BAR memory to guests. The intended use is confidential device assignment,
where KVM needs to coordinate private device mappings with shared access
through VFIO. The Arm CCA backend is provided separately; these patches
contain the guest_memfd, VFIO and IOMMUFD interfaces it uses.
The guest_memfd framework and Arm CCA backend are available together at:
https://git.gitlab.arm.com/linux-arm/linux-cca.git cca/topics/cca-da-gmem-backend
Userspace creates a device-backed guest_memfd using the ordinary VFIO
device fd as resource_fd, with GUEST_MEMFD_FLAG_USE_RESOURCE,
GUEST_MEMFD_FLAG_DEVICE and GUEST_MEMFD_FLAG_INIT_SHARED. Eligible BAR
intervals are registered as guest_memfd memslots. File offsets use the
existing VFIO region-offset namespace, allowing one guest_memfd to cover
multiple BAR intervals. Device-backed guest_memfd rejects mmap and
fallocate; shared guest faults obtain bare BAR PFNs from the provider
instead of resolving the memslot HVA or allocating folios.
IOMMUFD resolves and pins the device's existing vDEVICE for the VM and
serializes MMIO conversion through its MMIO mutex. VFIO supplies BAR PFNs,
checks eligible ranges and excludes independent dma-buf exports while a
guest_memfd provider is attached. VFIO host mmap faults, read/write and
ioeventfd accesses check the requested range's guest_memfd attributes.
Conversion revokes cached host mappings and shared guest mappings before
installing private mappings. Other shared intervals remain accessible.
This series depends on:
* Ackerley Tng's "Allow guest_memfd to be created using a resource (pool)
fd" RFC, which provides the tmpfs resource-provider API:
https://lore.kernel.org/all/20260925-gmem-tmpfs-backend-v1-0-d36159822d18@google.com/
* The IOMMUFD/TSM series, which provides the vIOMMU and vDEVICE interfaces:
https://lore.kernel.org/all/20261008055955.4014342-1-aneesh.kumar@kernel.org/
Notes:
* While developing this framework, I looked at David Woodhouse's
guest_memfd provider work, including the gmem-provider-v3 branch. It
was used for comparison and was not merged. The posted RFC v2 is here:
https://lore.kernel.org/all/20260720111259.122911-1-dwmw2@infradead.org/
* Codex assisted with implementation, review and series organization.
Cc: Ackerley Tng <ackerleytng@google.com>
Cc: Alex Williamson <alex@shazbot.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Joerg Roedel (AMD)" <joro@8bytes.org>
Cc: Kevin Tian <kevin.tian@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Will Deacon <will@kernel.org>
Cc: Alexey Kardashevskiy <aik@amd.com>
Cc: Xu Yilun <yilun.xu@linux.intel.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Steven Price <steven.price@arm.com>
Cc: Fred Griffoul <griffoul@gmail.com>
Cc: iommu@lists.linux.dev
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Aneesh Kumar K.V (Arm) (6):
KVM: guest_memfd: attach and bind device resources
KVM: guest_memfd: Support private/shared conversion of device memory
iommufd: Support MMIO provider attachment to vDEVICEs
vfio/pci: Provide guest_memfd backing for PCI BARs
KVM/VFIO: Remove device mappings during guest_memfd teardown
KVM: Invalidate guest_memfd mappings before removing memslot bindings
Documentation/virt/kvm/api.rst | 4 +
drivers/iommu/iommufd/viommu.c | 90 ++++
drivers/vfio/device_cdev.c | 3 +-
drivers/vfio/group.c | 4 +-
drivers/vfio/pci/Kconfig | 11 +
drivers/vfio/pci/Makefile | 2 +
drivers/vfio/pci/vfio_pci.c | 3 +
drivers/vfio/pci/vfio_pci_core.c | 13 +
drivers/vfio/pci/vfio_pci_dmabuf.c | 10 +
drivers/vfio/pci/vfio_pci_gmem.c | 349 +++++++++++++++
drivers/vfio/pci/vfio_pci_gmem.h | 36 ++
drivers/vfio/pci/vfio_pci_gmem_access.c | 138 ++++++
drivers/vfio/pci/vfio_pci_rdwr.c | 13 +-
drivers/vfio/vfio.h | 8 +
drivers/vfio/vfio_main.c | 34 +-
include/linux/guest_memfd.h | 50 +++
include/linux/iommufd.h | 33 ++
include/linux/kvm_host.h | 14 +-
include/linux/vfio.h | 3 +
include/linux/vfio_pci_core.h | 23 +
include/uapi/linux/kvm.h | 1 +
virt/kvm/guest_memfd.c | 545 +++++++++++++++++++++++-
virt/kvm/guest_memfd.h | 6 +
virt/kvm/kvm_main.c | 4 +
24 files changed, 1362 insertions(+), 35 deletions(-)
create mode 100644 drivers/vfio/pci/vfio_pci_gmem.c
create mode 100644 drivers/vfio/pci/vfio_pci_gmem.h
create mode 100644 drivers/vfio/pci/vfio_pci_gmem_access.c
--
2.43.0
next reply other threads:[~2026-10-10 7:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 7:24 Aneesh Kumar K.V (Arm) [this message]
2026-10-10 7:24 ` [RFC PATCH v1 1/6] KVM: guest_memfd: attach and bind device resources Aneesh Kumar K.V (Arm)
2026-10-10 7:25 ` [RFC PATCH v1 2/6] KVM: guest_memfd: Support private/shared conversion of device memory Aneesh Kumar K.V (Arm)
2026-10-10 7:25 ` [RFC PATCH v1 3/6] iommufd: Support MMIO provider attachment to vDEVICEs Aneesh Kumar K.V (Arm)
2026-10-10 7:25 ` [RFC PATCH v1 4/6] vfio/pci: Provide guest_memfd backing for PCI BARs Aneesh Kumar K.V (Arm)
2026-10-10 7:25 ` [RFC PATCH v1 5/6] KVM/VFIO: Remove device mappings during guest_memfd teardown Aneesh Kumar K.V (Arm)
2026-10-10 7:25 ` [RFC PATCH v1 6/6] KVM: Invalidate guest_memfd mappings before removing memslot bindings Aneesh Kumar K.V (Arm)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261010072504.536230-1-aneesh.kumar@kernel.org \
--to=aneesh.kumar@kernel.org \
--cc=ackerleytng@google.com \
--cc=aik@amd.com \
--cc=alex@shazbot.org \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=dwmw2@infradead.org \
--cc=griffoul@gmail.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=robin.murphy@arm.com \
--cc=seanjc@google.com \
--cc=steven.price@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yilun.xu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®