Re: [RFC PATCH 10/30] vfio/pci: Export vfio dma-buf specific info for importers
From: Xu Yilun
Date: Mon Jul 27 2026 - 05:03:33 EST
> > If VFIO can create one
It is an interesting idea to let VFIO create a guest_memfd instance, if
DMABUF doesn't work. But to achieve this goal, I think we still need to
refactor guest_memfd to allow for different memory/MMIO resource
exporters/creators, and different resource importers/users like KVM MMU
& IOMMUFD.
>
> At guest_memfd creation time, guest_memfd is always created for a
> KVM. This is the first place where it is bound to a kvm instance. This
> is one place where it helps Yilun with Confidential VMs, so KVM can be
> sure that the memory was meant for a specific CoCo kvm and not any VM.
>
> I think it might be weird to have VFIO take a kvm fd to create a
> guest_memfd?
I think having VFIO create a guest_memfd is better than having KVM
create a guest_memfd on behalf of VFIO.
The lifecycle of the MMIO resources should be managed by VFIO, cause
the availability of these MMIO resouces are impacted by device
operations, e.g., device reset, PCI Memory Space Enable (MSE) ...
You can't export MMIO resources to KVM MMU without VFIO's awareness.
And VFIO doesn't have to take a kvm fd paramter to create a guest_memfd,
VFIO has got the kvm instance via KVM_DEV_VFIO_FILE_ADD.
>
> I was thinking that the userspace VMM could do something like:
>
> int vfio_fd = open("/dev/vfio/devices/vfio0");
> int gmem_fd = ioctl(KVM_CREATE_GUEST_MEMFD, { .fd = vfio_fd });