qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/7] vfio: Implement VFIO_DEVICE_FEATURE_DMA_BUF and use it in virtio-gpu
@ 2025-10-03 23:35 Vivek Kasireddy
  2025-10-03 23:35 ` [PATCH v1 1/7] virtio-gpu: Recreate the resource's dmabuf if new backing is attached Vivek Kasireddy
                   ` (7 more replies)
  0 siblings, 8 replies; 26+ messages in thread
From: Vivek Kasireddy @ 2025-10-03 23:35 UTC (permalink / raw)
  To: qemu-devel
  Cc: Vivek Kasireddy, Marc-André Lureau, Alex Bennée,
	Akihiko Odaki, Dmitry Osipenko, Alex Williamson,
	Cédric Le Goater, Leon Romanovsky, Leon Romanovsky,
	Jason Gunthorpe, Dongwon Kim

The virtio-gpu driver running in the Guest VM can create Guest blob
resources (by importing dmabufs) that are backed by System RAM. This
is made possible by making use of memfd memory backend and udmabuf
driver on the Host side. However, in order to create Guest blobs
that are backed by vfio-pci device regions (which happens when
virtio-gpu imports dmabufs from devices that have local memory such
as dGPU VFs), we have to implement VFIO_DEVICE_FEATURE_DMA_BUF and
leverage it in virtio-gpu.

So, while creating the blobs we use memory_region_is_ram_device() to
figure out if the blob is backed by memfd or a vfio-pci device. If
it is determined that the blob is backed by vfio-pci device region,
instead of calling into udmabuf driver to create dmabuf we would
now call into vfio-pci driver to have a dmabuf created on the Host.

RFC -> v1:
- Create the CPU mapping using vfio device fd if the dmabuf exporter
  (vfio-pci) does not provide mmap() support (Akihiko)
- Log a warning with LOG_GUEST_ERROR instead of warn_report() when
  dmabuf cannot be created using Guest provided addresses (Akihiko)
- Use address_space_translate() instead of gpa2hva() to obtain the
  Host addresses (Akihiko)
- Rearrange the patches and improve the commit messages (Akihiko)
- Fix compilation error when VFIO is not enabled (Alex)
- Add a new helper to obtain VFIO region index from memory region
- Move vfio_device_create_dmabuf() to hw/vfio/device.c

Tested with an SRIOV enabled Intel dGPU by running Gnome Wayland
(in the VM) and Qemu with the following (relevant) parameters:
-device vfio-pci,host=0000:03:00.1
-device virtio-vga,max_outputs=1,xres=1920,yres=1080,blob=true
-display gtk,gl=on

Associated vfio-pci kernel driver series:
https://lore.kernel.org/dri-devel/cover.1754311439.git.leon@kernel.org/
Associated virtio-gpu kernel driver series (merged):
https://lore.kernel.org/dri-devel/20241126031643.3490496-1-vivek.kasireddy@intel.com/

---
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Alex Bennée <alex.bennee@linaro.org>
Cc: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Cédric Le Goater <clg@redhat.com>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>

Vivek Kasireddy (7):
  virtio-gpu: Recreate the resource's dmabuf if new backing is attached
  virtio-gpu: Don't rely on res->blob to identify blob resources
  virtio-gpu: Find hva for Guest's DMA addr associated with a ram device
  vfio/region: Add a helper to get region index from memory region
  linux-headers: Update vfio.h to include VFIO_DEVICE_FEATURE_DMA_BUF
  vfio/device: Add support for VFIO_DEVICE_FEATURE_DMA_BUF
  virtio-gpu-udmabuf: Create dmabuf for blobs associated with VFIO
    devices

 hw/display/Kconfig              |   5 ++
 hw/display/virtio-gpu-udmabuf.c | 143 ++++++++++++++++++++++++++++++--
 hw/display/virtio-gpu.c         |  53 +++++++++---
 hw/vfio/device.c                |  43 ++++++++++
 hw/vfio/region.c                |  14 ++++
 include/hw/vfio/vfio-device.h   |   5 ++
 linux-headers/linux/vfio.h      |  25 ++++++
 7 files changed, 270 insertions(+), 18 deletions(-)

-- 
2.50.1



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

end of thread, other threads:[~2025-10-14  4:50 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-03 23:35 [PATCH v1 0/7] vfio: Implement VFIO_DEVICE_FEATURE_DMA_BUF and use it in virtio-gpu Vivek Kasireddy
2025-10-03 23:35 ` [PATCH v1 1/7] virtio-gpu: Recreate the resource's dmabuf if new backing is attached Vivek Kasireddy
2025-10-14  4:36   ` Akihiko Odaki
2025-10-03 23:35 ` [PATCH v1 2/7] virtio-gpu: Don't rely on res->blob to identify blob resources Vivek Kasireddy
2025-10-10  4:19   ` Akihiko Odaki
2025-10-13  6:54     ` Kasireddy, Vivek
2025-10-14  4:15       ` Akihiko Odaki
2025-10-03 23:35 ` [PATCH v1 3/7] virtio-gpu: Find hva for Guest's DMA addr associated with a ram device Vivek Kasireddy
2025-10-14  4:38   ` Akihiko Odaki
2025-10-03 23:35 ` [PATCH v1 4/7] vfio/region: Add a helper to get region index from memory region Vivek Kasireddy
2025-10-06  8:26   ` Cédric Le Goater
2025-10-07  4:50     ` Kasireddy, Vivek
2025-10-07  9:05       ` Cédric Le Goater
2025-10-03 23:35 ` [PATCH v1 5/7] linux-headers: Update vfio.h to include VFIO_DEVICE_FEATURE_DMA_BUF Vivek Kasireddy
2025-10-03 23:35 ` [PATCH v1 6/7] vfio/device: Add support for VFIO_DEVICE_FEATURE_DMA_BUF Vivek Kasireddy
2025-10-06  8:24   ` Cédric Le Goater
2025-10-07  4:48     ` Kasireddy, Vivek
2025-10-03 23:36 ` [PATCH v1 7/7] virtio-gpu-udmabuf: Create dmabuf for blobs associated with VFIO devices Vivek Kasireddy
2025-10-06 15:59   ` Cédric Le Goater
2025-10-07  4:53     ` Kasireddy, Vivek
2025-10-07  6:51     ` Cédric Le Goater
2025-10-10  4:53   ` Akihiko Odaki
2025-10-13  7:00     ` Kasireddy, Vivek
2025-10-14  4:49       ` Akihiko Odaki
2025-10-06 15:28 ` [PATCH v1 0/7] vfio: Implement VFIO_DEVICE_FEATURE_DMA_BUF and use it in virtio-gpu Cédric Le Goater
2025-10-07  4:51   ` Kasireddy, Vivek

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).