Skip to content

RFC MSHV: add PV-IOMMU driver

Wei Liu linux-arch linux-doc linux-hyperv linux-iommu lkml virtualization 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest8 patches 26 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8x86/hyperv: export hv_build_pci_dev_idarch/x86/hyperv/irqdomain.c arch/x86/include/asm/mshyperv.h+3 -10 replies
2/8asm-generic/hyperv: add device domain definitionsinclude/asm-generic/hyperv-tlfs.h+144 -00 replies
3/8intel/vt-d: make DMAR table parsing code more flexibledrivers/iommu/intel/dmar.c drivers/iommu/intel/iommu.c drivers/iommu/intel/irq_remapping.c +1 more+30 -142 replies
4/8intel/vt-d: export intel_iommu_get_resv_regionsdrivers/iommu/intel/iommu.c include/linux/intel-iommu.h+7 -22 replies
5/8mshv: add paravirtualized IOMMU supportdrivers/iommu/Kconfig drivers/iommu/hyperv-iommu.c+642 -04 replies
6/8mshv: command line option to skip devices in PV-IOMMUdrivers/iommu/hyperv-iommu.c+45 -06 replies
7/8mshv: implement in-kernel device frameworkDocumentation/virt/mshv/api.rst drivers/hv/mshv_main.c include/linux/mshv.h +1 more+286 -010 replies
8/8mshv: add vfio bridge devicedrivers/hv/Kconfig drivers/hv/Makefile drivers/hv/mshv_main.c +2 more+272 -12 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [RFC v1 0/8] MSHV: add PV-IOMMU driver

Hi all

Device passthrough is a critial feature for a virtualization stack. When designing this feature for MSHV support on Linux, one important considration is to not deviate from Linux's default VFIO stack. VFIO relies on an IOMMU or IOMMUs in the system to manipulate DMA mappings.

In this series an IOMMU driver is implemented using a set of hypercall interfaces provided by the Microsoft Hypervisor. At this stage only DMA remapping is implemented. Interrupt remapping will come later.

With this series I'm able to passthrough an NVMe drive to a guest with VFIO on a modified version of Cloud Hypervisor. From users' point of view, nothing needs changing. Cloud Hypervisor and Rust-VMM changes, which depend on the new kernel UAPIs from this series, will be upstreamed too.

This series is built on top of Nuno and Vineeth's patches [0][1].

The meat is in the patch named "mshv: add paravirtualized IOMMU support".

The in-kernel device framework and the VFIO bridge device are heavily inspired by KVM's code. I pondered whether it would be worth refactoring the code in KVM but decided against that route for two reasons: 1. it allowed faster prototyping and 2. I was not sure if that's something KVM community would agree to.

For the VT-D changes, what we're after is to build the RMRR regions list so that reserved regions are respected. Instead of doing a bad job myself, I decided to piggy-back on Intel's own code. AMD support is to be added until we have an AMD system.

Comments are welcome.

Thanks,
Wei.

[0] https://lore.kernel.org/linux-hyperv/1622241819-21155-1-git-send-email-nunodasneves@linux.microsoft.com/
[1] https://lore.kernel.org/linux-hyperv/[email protected]/

Wei Liu (8):
x86/hyperv: export hv_build_pci_dev_id asm-generic/hyperv: add device domain definitions intel/vt-d: make DMAR table parsing code more flexible intel/vt-d: export intel_iommu_get_resv_regions
mshv: add paravirtualized IOMMU support
mshv: command line option to skip devices in PV-IOMMU
mshv: implement in-kernel device framework
mshv: add vfio bridge device

 Documentation/virt/mshv/api.rst     |  12 +
 arch/x86/hyperv/irqdomain.c         |   3 +-
 arch/x86/include/asm/mshyperv.h     |   1 +
 drivers/hv/Kconfig                  |   4 +
 drivers/hv/Makefile                 |   2 +-
 drivers/hv/mshv_main.c              | 186 ++++++++
 drivers/hv/vfio.c                   | 244 ++++++++++
 drivers/hv/vfio.h                   |  18 +
 drivers/iommu/Kconfig               |  14 +
 drivers/iommu/hyperv-iommu.c        | 673 ++++++++++++++++++++++++++++
 drivers/iommu/intel/dmar.c          |  38 +-
 drivers/iommu/intel/iommu.c         |   7 +-
 drivers/iommu/intel/irq_remapping.c |   2 +-
 include/asm-generic/hyperv-tlfs.h   | 144 ++++++
 include/linux/dmar.h                |   2 +-
 include/linux/intel-iommu.h         |   4 +
 include/linux/mshv.h                |  57 +++
 include/uapi/linux/mshv.h           |  36 ++
 18 files changed, 1429 insertions(+), 18 deletions(-)
 create mode 100644 drivers/hv/vfio.c
 create mode 100644 drivers/hv/vfio.h
Signature · 1 line
2.30.2