linux-um archives
 help / color / mirror / Atom feed
* [PATCH 0/3] um: Add VFIO-based PCI passthrough support
@ 2025-03-15 16:19 Tiwei Bie
  2025-03-15 16:19 ` [PATCH 1/3] um: Rewrite the sigio workaround based on epoll and tgkill Tiwei Bie
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Tiwei Bie @ 2025-03-15 16:19 UTC (permalink / raw)
  To: richard, anton.ivanov, johannes; +Cc: linux-um, Tiwei Bie

This patchset adds a new virt-pci driver to UML that allows users to
pass through host PCI devices to UML via VFIO. Currently, only MSI-X
capable devices are supported, and drivers are assumed to use MSI-X.

This driver has been tested with virtio-net-pci, virtio-blk-pci and
nvme in a QEMU virtual machine with virtual IOMMU enabled. Regression
testing for virtio_pcidev has only covered compile tests and partial
virtio probe/remove tests with a dummy vhost-user backend.

Here are some steps to try out this driver:

1. Enable IOMMU and bind PCI devices to the vfio-pci driver.

2. Launch a UML instance directly (assuming that the PCI devices to
   be passed through to UML are 0000:02:00.0 and 0000:03:00.0).

 $ ./linux mem=2G init=/bin/sh ubd0=$your_rootfs_image \
           vfio_uml.device=0000:02:00.0 \
           vfio_uml.device=0000:03:00.0

Note that, currently, it's not possible to allocate a large amount of
"physical" memory to the UML instance; otherwise, it may overlap with
IOMMU-reserved IOVA ranges (e.g. [0xfee00000, 0xfef00000)), causing
DMA mapping failures.

This patchset is based on the following patchset:
https://lore.kernel.org/all/20250306150747.2926434-1-tiwei.btw@antgroup.com/

v1:
- Add more details in the commit log;

RFC: https://lore.kernel.org/all/20250310074057.3977758-1-tiwei.btw@antgroup.com/

Tiwei Bie (3):
  um: Rewrite the sigio workaround based on epoll and tgkill
  um: virt-pci: Refactor virtio_pcidev into its own module
  um: Add VFIO-based virtual PCI driver

 arch/um/drivers/Kconfig         |  20 +-
 arch/um/drivers/Makefile        |   5 +-
 arch/um/drivers/random.c        |   2 +-
 arch/um/drivers/rtc_user.c      |   2 +-
 arch/um/drivers/vfio_kern.c     | 648 +++++++++++++++++++++++++++++
 arch/um/drivers/vfio_user.c     | 323 +++++++++++++++
 arch/um/drivers/vfio_user.h     |  44 ++
 arch/um/drivers/virt-pci.c      | 699 ++++++--------------------------
 arch/um/drivers/virt-pci.h      |  41 ++
 arch/um/drivers/virtio_pcidev.c | 628 ++++++++++++++++++++++++++++
 arch/um/include/shared/os.h     |   2 +-
 arch/um/include/shared/sigio.h  |   1 -
 arch/um/kernel/sigio.c          |  26 --
 arch/um/os-Linux/sigio.c        | 330 ++-------------
 14 files changed, 1866 insertions(+), 905 deletions(-)
 create mode 100644 arch/um/drivers/vfio_kern.c
 create mode 100644 arch/um/drivers/vfio_user.c
 create mode 100644 arch/um/drivers/vfio_user.h
 create mode 100644 arch/um/drivers/virt-pci.h
 create mode 100644 arch/um/drivers/virtio_pcidev.c

-- 
2.34.1



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

end of thread, other threads:[~2025-03-20 15:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15 16:19 [PATCH 0/3] um: Add VFIO-based PCI passthrough support Tiwei Bie
2025-03-15 16:19 ` [PATCH 1/3] um: Rewrite the sigio workaround based on epoll and tgkill Tiwei Bie
2025-03-15 16:19 ` [PATCH 2/3] um: virt-pci: Refactor virtio_pcidev into its own module Tiwei Bie
2025-03-15 16:19 ` [PATCH 3/3] um: Add VFIO-based virtual PCI driver Tiwei Bie
2025-03-20  8:50   ` Johannes Berg
2025-03-20 15:16     ` Tiwei Bie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox