Skip to content

Commit

Permalink
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/mst/vhost

Pull virtio, vhost updates from Michael Tsirkin:
 "Fixes, features, performance:

   - new iommu device

   - vhost guest memory access using vmap (just meta-data for now)

   - minor fixes"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  virtio-mmio: add error check for platform_get_irq
  scsi: virtio_scsi: Use struct_size() helper
  iommu/virtio: Add event queue
  iommu/virtio: Add probe request
  iommu: Add virtio-iommu driver
  PCI: OF: Initialize dev->fwnode appropriately
  of: Allow the iommu-map property to omit untranslated devices
  dt-bindings: virtio: Add virtio-pci-iommu node
  dt-bindings: virtio-mmio: Add IOMMU description
  vhost: fix clang build warning
  vhost: access vq metadata through kernel virtual address
  vhost: factor out setting vring addr and num
  vhost: introduce helpers to get the size of metadata area
  vhost: rename vq_iotlb_prefetch() to vq_meta_prefetch()
  vhost: fine grain userspace memory accessors
  vhost: generalize adding used elem
  • Loading branch information
torvalds committed Jul 17, 2019
2 parents 37d4607 + 5e663f0 commit 3a1d538
Show file tree
Hide file tree
Showing 15 changed files with 2,228 additions and 131 deletions.
66 changes: 66 additions & 0 deletions Documentation/devicetree/bindings/virtio/iommu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
* virtio IOMMU PCI device

When virtio-iommu uses the PCI transport, its programming interface is
discovered dynamically by the PCI probing infrastructure. However the
device tree statically describes the relation between IOMMU and DMA
masters. Therefore, the PCI root complex that hosts the virtio-iommu
contains a child node representing the IOMMU device explicitly.

Required properties:

- compatible: Should be "virtio,pci-iommu"
- reg: PCI address of the IOMMU. As defined in the PCI Bus
Binding reference [1], the reg property is a five-cell
address encoded as (phys.hi phys.mid phys.lo size.hi
size.lo). phys.hi should contain the device's BDF as
0b00000000 bbbbbbbb dddddfff 00000000. The other cells
should be zero.
- #iommu-cells: Each platform DMA master managed by the IOMMU is assigned
an endpoint ID, described by the "iommus" property [2].
For virtio-iommu, #iommu-cells must be 1.

Notes:

- DMA from the IOMMU device isn't managed by another IOMMU. Therefore the
virtio-iommu node doesn't have an "iommus" property, and is omitted from
the iommu-map property of the root complex.

Example:

pcie@10000000 {
compatible = "pci-host-ecam-generic";
...

/* The IOMMU programming interface uses slot 00:01.0 */
iommu0: iommu@0008 {
compatible = "virtio,pci-iommu";
reg = <0x00000800 0 0 0 0>;
#iommu-cells = <1>;
};

/*
* The IOMMU manages all functions in this PCI domain except
* itself. Omit BDF 00:01.0.
*/
iommu-map = <0x0 &iommu0 0x0 0x8>
<0x9 &iommu0 0x9 0xfff7>;
};

pcie@20000000 {
compatible = "pci-host-ecam-generic";
...
/*
* The IOMMU also manages all functions from this domain,
* with endpoint IDs 0x10000 - 0x1ffff
*/
iommu-map = <0x0 &iommu0 0x10000 0x10000>;
};

ethernet@fe001000 {
...
/* The IOMMU manages this platform device with endpoint ID 0x20000 */
iommus = <&iommu0 0x20000>;
};

[1] Documentation/devicetree/bindings/pci/pci.txt
[2] Documentation/devicetree/bindings/iommu/iommu.txt
30 changes: 30 additions & 0 deletions Documentation/devicetree/bindings/virtio/mmio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,40 @@ Required properties:
- reg: control registers base address and size including configuration space
- interrupts: interrupt generated by the device

Required properties for virtio-iommu:

- #iommu-cells: When the node corresponds to a virtio-iommu device, it is
linked to DMA masters using the "iommus" or "iommu-map"
properties [1][2]. #iommu-cells specifies the size of the
"iommus" property. For virtio-iommu #iommu-cells must be
1, each cell describing a single endpoint ID.

Optional properties:

- iommus: If the device accesses memory through an IOMMU, it should
have an "iommus" property [1]. Since virtio-iommu itself
does not access memory through an IOMMU, the "virtio,mmio"
node cannot have both an "#iommu-cells" and an "iommus"
property.

Example:

virtio_block@3000 {
compatible = "virtio,mmio";
reg = <0x3000 0x100>;
interrupts = <41>;

/* Device has endpoint ID 23 */
iommus = <&viommu 23>
}

viommu: iommu@3100 {
compatible = "virtio,mmio";
reg = <0x3100 0x100>;
interrupts = <42>;

#iommu-cells = <1>
}

[1] Documentation/devicetree/bindings/iommu/iommu.txt
[2] Documentation/devicetree/bindings/pci/pci-iommu.txt
7 changes: 7 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -17107,6 +17107,13 @@ S: Maintained
F: drivers/virtio/virtio_input.c
F: include/uapi/linux/virtio_input.h

VIRTIO IOMMU DRIVER
M: Jean-Philippe Brucker <[email protected]>
L: [email protected]
S: Maintained
F: drivers/iommu/virtio-iommu.c
F: include/uapi/linux/virtio_iommu.h

VIRTUAL BOX GUEST DEVICE DRIVER
M: Hans de Goede <[email protected]>
M: Arnd Bergmann <[email protected]>
Expand Down
11 changes: 11 additions & 0 deletions drivers/iommu/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,15 @@ config HYPERV_IOMMU
Stub IOMMU driver to handle IRQs as to allow Hyper-V Linux
guests to run with x2APIC mode enabled.

config VIRTIO_IOMMU
bool "Virtio IOMMU driver"
depends on VIRTIO=y
depends on ARM64
select IOMMU_API
select INTERVAL_TREE
help
Para-virtualised IOMMU driver with virtio.

Say Y here if you intend to run this kernel as a guest.

endif # IOMMU_SUPPORT
1 change: 1 addition & 0 deletions drivers/iommu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o
obj-$(CONFIG_S390_IOMMU) += s390-iommu.o
obj-$(CONFIG_QCOM_IOMMU) += qcom_iommu.o
obj-$(CONFIG_HYPERV_IOMMU) += hyperv-iommu.o
obj-$(CONFIG_VIRTIO_IOMMU) += virtio-iommu.o
Loading

0 comments on commit 3a1d538

Please sign in to comment.