Skip to content

vfio: Add support for platform devices

Mostafa Saleh kvm 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9vfio: Fix fd leak in vfio_group_get_for_dev()vfio/core.c+1 -10 replies
2/9vfio: Factor out wired IRQ setup and teardowninclude/kvm/vfio.h vfio/core.c vfio/pci.c+137 -1070 replies
3/9vfio: Support edge-triggered wired IRQsinclude/kvm/vfio.h vfio/core.c vfio/pci.c+32 -240 replies
4/9fdt: Allow fdt_irq_fn to generate multiple interruptsarm64/fdt.c hw/cfi_flash.c hw/rtc.c +6 more+60 -340 replies
5/9fdt: Add helper to copy an FDT nodeinclude/kvm/fdt.h+28 -00 replies
6/9vfio: Reserve guest address space for VFIO platformarm64/include/kvm/kvm-arch.h mips/include/kvm/kvm-arch.h powerpc/include/kvm/kvm-arch.h +2 more+15 -40 replies
7/9vfio: Add basic support for vfio-platformMakefile builtin-run.c include/kvm/vfio.h +2 more+187 -00 replies
8/9vfio: platform: Add interrupts supportinclude/kvm/vfio.h vfio/platform.c+119 -30 replies
9/9vfio: platform: Take the guest node from a device tree templatebuiltin-run.c include/kvm/vfio.h vfio/core.c +1 more+68 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH kvmtool 0/9] vfio: Add support for platform devices

This patch series extend VFIO support to platform devices by using VFIO-platform.

One of the main difference is how the guest discover the device, which is done through the device tree.
kvmtool can only describe:
- regs
- interrupts

However, the guest still needs a compatible string and other per device bindings.
To avoid having any hardcoded DT nodes in the source code, kvmtool will accept a dtb argument with each assigned device that will be copied to the guest node.

Patches
=======
1-4: Fixes, code refactoring and improving interrupt support. 5: DT common function.
6-8: VFIO-platform support.
9: Custom device tree support.

Patch 2 is better viewed with --color-moved

Testing
=======
Tested on Lenovo Mini-x Gen 10 (Snapdragon-X) by assigning 2 devices, QCE and BAM as follows:

echo 1dfa000.crypto > /sys/bus/platform/drivers/qcrypto/unbind echo 1dc4000.dma-controller > /sys/bus/platform/drivers/bam-dma-engine/unbind

echo "vfio-platform" > /sys/bus/platform/devices/1dfa000.crypto/driver_override echo "vfio-platform" > /sys/bus/platform/devices/1dc4000.dma-controller/driver_override

echo 1dc4000.dma-controller > /sys/bus/platform/drivers/vfio-platform/bind echo 1dfa000.crypto > /sys/bus/platform/drivers/vfio-platform/bind

./lkvm-static run --irqchip gicv3 -k Image -p "nokaslr" -d rootfs.ext2 --force-pci -c 1 --debug --vfio- platform 1dc4000.dma-controller,purwa-cryptobam.dtb --vfio-platform 1dfa000.crypto,purwa-qce.dtb

There are some fixes on the list that are needed to be able to unbind the bam device [1]

Mostafa Saleh (9):
vfio: Fix fd leak in vfio_group_get_for_dev()
vfio: Factor out wired IRQ setup and teardown
vfio: Support edge-triggered wired IRQs
fdt: Allow fdt_irq_fn to generate multiple interrupts
fdt: Add helper to copy an FDT node
vfio: Reserve guest address space for VFIO platform
vfio: Add basic support for vfio-platform
vfio: platform: Add interrupts support
vfio: platform: Take the guest node from a device tree template

 Makefile                       |   1 +
 arm64/fdt.c                    |  36 ++--
 arm64/include/kvm/kvm-arch.h   |  10 +-
 builtin-run.c                  |   3 +
 hw/cfi_flash.c                 |   4 +-
 hw/rtc.c                       |   4 +-
 hw/serial.c                    |   3 +-
 include/kvm/fdt.h              |  32 +++-
 include/kvm/vfio.h             |  41 ++++-
 mips/include/kvm/kvm-arch.h    |   2 +
 powerpc/include/kvm/kvm-arch.h |   2 +
 riscv/fdt.c                    |   2 +-
 riscv/include/kvm/kvm-arch.h   |   7 +-
 riscv/irq.c                    |  27 ++-
 vfio/core.c                    | 152 +++++++++++++++-
 vfio/pci.c                     | 111 +-----------
 vfio/platform.c                | 317 +++++++++++++++++++++++++++++++++
 virtio/mmio.c                  |  10 +-
 x86/include/kvm/kvm-arch.h     |   2 +
 19 files changed, 619 insertions(+), 147 deletions(-)
 create mode 100644 vfio/platform.c
Signature · 1 line
2.56.0.307.g5fe7bd680c-goog