Skip to content

RFC iommu/riscv: Add irqbypass support

Andrew Jones kvm kvm-riscv linux-iommu linux-riscv lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest18 patches 34 repliesIn review
  2. v1 RFC15 patches 20 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18genirq/msi: Provide DOMAIN_BUS_MSI_REMAPdrivers/irqchip/irq-msi-lib.c include/linux/irqdomain_defs.h+5 -41 reply
2/18iommu/riscv: Move struct riscv_iommu_domain and info to iommu.hdrivers/iommu/riscv/iommu.c drivers/iommu/riscv/iommu.h+20 -201 reply
3/18iommu/riscv: Use data structure instead of individual valuesdrivers/iommu/riscv/iommu.c+19 -122 replies
4/18iommu/riscv: Add IRQ domain for interrupt remappingdrivers/iommu/riscv/Makefile drivers/iommu/riscv/iommu-ir.c drivers/iommu/riscv/iommu.c +1 more+163 -12 replies
5/18iommu/riscv: Prepare to use MSI tabledrivers/iommu/riscv/iommu-ir.c drivers/iommu/riscv/iommu.c drivers/iommu/riscv/iommu.h+196 -01 reply
6/18iommu/riscv: Implement MSI table management functionsdrivers/iommu/riscv/iommu-bits.h drivers/iommu/riscv/iommu-ir.c drivers/iommu/riscv/iommu.c +1 more+86 -321 reply
7/18iommu/riscv: Export phys_to_ppn and ppn_to_physdrivers/iommu/riscv/iommu-bits.h drivers/iommu/riscv/iommu.c+9 -91 reply
8/18iommu/riscv: Use MSI table to enable IMSIC accessdrivers/iommu/riscv/iommu-ir.c drivers/iommu/riscv/iommu.h+143 -216 replies
9/18iommu/dma: enable IOMMU_DMA for RISC-Vdrivers/iommu/Kconfig+1 -11 reply
10/18RISC-V: Define irqbypass vcpu_infoarch/riscv/include/asm/irq.h+9 -01 reply
11/18iommu/riscv: Maintain each irq msitbl index with chip datadrivers/iommu/riscv/iommu-ir.c drivers/iommu/riscv/iommu.h+65 -110 replies
12/18iommu/riscv: Add guest file irqbypass supportdrivers/iommu/riscv/iommu-ir.c drivers/iommu/riscv/iommu.c drivers/iommu/riscv/iommu.h+171 -30 replies
13/18iommu/riscv: report iommu capabilitiesdrivers/iommu/riscv/iommu.c+12 -01 reply
14/18RISC-V: KVM: Enable KVM_VFIO interfaces on RISC-V archarch/riscv/kvm/Kconfig+2 -01 reply
15/18RISC-V: KVM: Add guest file irqbypass supportarch/riscv/kvm/Kconfig arch/riscv/kvm/aia_imsic.c arch/riscv/kvm/vm.c+173 -20 replies
16/18vfio: enable IOMMU_TYPE1 for RISC-Vdrivers/vfio/Kconfig+1 -11 reply
17/18RISC-V: defconfig: Add VFIO modulesarch/riscv/configs/defconfig+2 -01 reply
18/18DO NOT UPSTREAM: RISC-V: KVM: Workaround kvm_riscv_gstage_ioremap() bugarch/riscv/kvm/mmu.c+1 -13 replies

Reviews trailers per patch

13 of 18 patches have a Reviewed-by or Acked-by.

PatchNutty Liu
1/18R-b
2/18R-b
3/18R-b
4/18R-b
5/18R-b
6/18R-b
7/18R-b
8/18
9/18R-b
10/18R-b
11/18
12/18
13/18R-b
14/18R-b
15/18
16/18R-b
17/18R-b
18/18

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [RFC PATCH v2 00/18] iommu/riscv: Add irqbypass support

Changelog
---------
This is v2 of the RFC for adding interrupt remapping support to the RISC-V IOMMU driver along with support for KVM in order to apply it to irqbypass. v1 of the series was discussed here[1] where a couple large design flaws were pointed out. Those, along with a v1 TODO of referencing counting MSI PTEs in order to track when they may be unmapped, have been addressed in v2. Additionally, v2 is based on msi-lib, which didn't exist at the time of the v1 posting, and on the recent KVM irqbypass rework.

Description
-----------
Platforms with MSI support (IMSICs) and implementations of the RISC-V IOMMU with an MSI table can control device MSI delivery, including directly delivering MSIs of devices assigned to guests to VCPUs. This series enables that control and enables IOMMU_DMA in order to use paging IOMMU domains by default. When the IOMMU doesn't support an MSI table (it's an optional IOMMU capability) then paging domains are still used, but the system does not have isolated MSIs. For direct delivery to VCPUs an MSI table is required and thanks to KVM+VFIO it's possible to determine when and how to map guest IMSIC addresses to host guest interrupt files. The RISC-V IOMMU and AIA also support MRIFs (memory- resident interrupt files), but support for those will be posted as a follow-on to this series. Also, additional work will be done in order to take advantage of the RISC-V IOMMU's second stage of paging. At this time, the series just uses the first stage which allows testing with unmodified KVM userspace and VFIO.

The patches are organized as follows:
1-4: Create an irq domain and some function stubs for an initial
interrupt remapping support skeleton
5-9: Add MSI table management to enable host interrupt remapping
and enable IOMMU_DMA
10-13: Add IOMMU driver support for directly delivering MSIs to VCPUs 14-17: Add KVM support for directly delivering MSIs to VCPUs

The last patch is a workaround for a KVM bug not introduced by this series which is needed to enable testing of the series -- I still need to debug and fix that properly.

There series is also available here[2].

Based on commit 39879e3a4106.

[1] https://lore.kernel.org/all/[email protected]/
[2] https://github.com/jones-drew/linux/commits/riscv/iommu-irqbypass-rfc-v2/

Andrew Jones (13):
genirq/msi: Provide DOMAIN_BUS_MSI_REMAP
iommu/riscv: Move struct riscv_iommu_domain and info to iommu.h iommu/riscv: Add IRQ domain for interrupt remapping iommu/riscv: Prepare to use MSI table
iommu/riscv: Implement MSI table management functions iommu/riscv: Export phys_to_ppn and ppn_to_phys iommu/riscv: Use MSI table to enable IMSIC access
RISC-V: Define irqbypass vcpu_info
iommu/riscv: Maintain each irq msitbl index with chip data iommu/riscv: Add guest file irqbypass support
RISC-V: KVM: Add guest file irqbypass support
RISC-V: defconfig: Add VFIO modules
DO NOT UPSTREAM: RISC-V: KVM: Workaround kvm_riscv_gstage_ioremap()
bug

Tomasz Jeznach (4):
iommu/dma: enable IOMMU_DMA for RISC-V iommu/riscv: report iommu capabilities
RISC-V: KVM: Enable KVM_VFIO interfaces on RISC-V arch
vfio: enable IOMMU_TYPE1 for RISC-V

Zong Li (1):
iommu/riscv: Use data structure instead of individual values

 arch/riscv/configs/defconfig     |   2 +
 arch/riscv/include/asm/irq.h     |   9 +
 arch/riscv/kvm/Kconfig           |   3 +
 arch/riscv/kvm/aia_imsic.c       | 143 ++++++-
 arch/riscv/kvm/mmu.c             |   2 +-
 arch/riscv/kvm/vm.c              |  31 ++
 drivers/iommu/Kconfig            |   2 +-
 drivers/iommu/riscv/Makefile     |   2 +-
 drivers/iommu/riscv/iommu-bits.h |  11 +
 drivers/iommu/riscv/iommu-ir.c   | 698 +++++++++++++++++++++++++++++++
 drivers/iommu/riscv/iommu.c      | 158 +++----
 drivers/iommu/riscv/iommu.h      |  75 ++++
 drivers/irqchip/irq-msi-lib.c    |   8 +-
 drivers/vfio/Kconfig             |   2 +-
 include/linux/irqdomain_defs.h   |   1 +
 15 files changed, 1063 insertions(+), 84 deletions(-)
 create mode 100644 drivers/iommu/riscv/iommu-ir.c
Signature · 1 line
2.49.0