From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com,
bmeng@tinylab.org, liwei1518@gmail.com,
zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com,
jason.chien@sifive.com, frank.chang@sifive.com,
ajones@ventanamicro.com,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Subject: [PATCH for-9.2 v6 12/12] docs/specs: add riscv-iommu
Date: Thu, 1 Aug 2024 12:43:33 -0300 [thread overview]
Message-ID: <20240801154334.1009852-13-dbarboza@ventanamicro.com> (raw)
In-Reply-To: <20240801154334.1009852-1-dbarboza@ventanamicro.com>
Add a simple guideline to use the existing RISC-V IOMMU support we just
added.
This doc will be updated once we add the riscv-iommu-sys device.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
docs/specs/index.rst | 1 +
docs/specs/riscv-iommu.rst | 80 ++++++++++++++++++++++++++++++++++++++
docs/system/riscv/virt.rst | 13 +++++++
3 files changed, 94 insertions(+)
create mode 100644 docs/specs/riscv-iommu.rst
diff --git a/docs/specs/index.rst b/docs/specs/index.rst
index 1484e3e760..c68cd9ae6c 100644
--- a/docs/specs/index.rst
+++ b/docs/specs/index.rst
@@ -33,3 +33,4 @@ guest hardware that is specific to QEMU.
virt-ctlr
vmcoreinfo
vmgenid
+ riscv-iommu
diff --git a/docs/specs/riscv-iommu.rst b/docs/specs/riscv-iommu.rst
new file mode 100644
index 0000000000..e3b8f7208e
--- /dev/null
+++ b/docs/specs/riscv-iommu.rst
@@ -0,0 +1,80 @@
+.. _riscv-iommu:
+
+RISC-V IOMMU support for RISC-V machines
+========================================
+
+QEMU implements a RISC-V IOMMU emulation based on the RISC-V IOMMU spec
+version 1.0 `iommu1.0`_.
+
+The emulation includes a PCI reference device, riscv-iommu-pci, that QEMU
+RISC-V boards can use. The 'virt' RISC-V machine is compatible with this
+device.
+
+riscv-iommu-pci reference device
+--------------------------------
+
+This device implements the RISC-V IOMMU emulation as recommended by the section
+"Integrating an IOMMU as a PCIe device" of `iommu1.0`_: a PCI device with base
+class 08h, sub-class 06h and programming interface 00h.
+
+As a reference device it doesn't implement anything outside of the specification,
+so it uses a generic default PCI ID given by QEMU: 1b36:0014.
+
+To include the device in the 'virt' machine:
+
+.. code-block:: bash
+
+ $ qemu-system-riscv64 -M virt -device riscv-iommu-pci,[optional_pci_opts] (...)
+
+This will add a RISC-V IOMMU PCI device in the board following any additional
+PCI parameters (like PCI bus address). The behavior of the RISC-V IOMMU is
+defined by the spec but its operation is OS dependent. As of this writing the
+existing Linux kernel support `linux-v8`_, not yet merged, will configure the IOMMU
+to create IOMMU groups with any eligible cards available in the system,
+regardless of factors such as the order in which the devices are added in the
+command line.
+
+This means that these command lines are equivalent as far as the current
+IOMMU kernel driver behaves:
+
+.. code-block:: bash
+
+ $ qemu-system-riscv64 \
+ -M virt,aia=aplic-imsic,aia-guests=5 \
+ -device riscv-iommu-pci,addr=1.0,vendor-id=0x1efd,device-id=0xedf1 \
+ -device e1000e,netdev=net1 -netdev user,id=net1,net=192.168.0.0/24 \
+ -device e1000e,netdev=net2 -netdev user,id=net2,net=192.168.200.0/24 \
+ (...)
+
+ $ qemu-system-riscv64 \
+ -M virt,aia=aplic-imsic,aia-guests=5 \
+ -device e1000e,netdev=net1 -netdev user,id=net1,net=192.168.0.0/24 \
+ -device e1000e,netdev=net2 -netdev user,id=net2,net=192.168.200.0/24 \
+ -device riscv-iommu-pci,addr=1.0,vendor-id=0x1efd,device-id=0xedf1 \
+ (...)
+
+Both will create iommu groups for the two e1000e cards.
+
+Another thing to notice on `linux-v8`_ is that the kernel driver considers an IOMMU
+identified as a Rivos device, i.e. it uses Rivos vendor ID. To use the riscv-iommu-pci
+device with the existing kernel support we need to emulate a Rivos PCI IOMMU by
+setting 'vendor-id' and 'device-id':
+
+.. code-block:: bash
+
+ $ qemu-system-riscv64 -M virt \
+ -device riscv-iommu-pci,vendor-id=0x1efd,device-id=0xedf1 (...)
+
+Several options are available to control the capabilities of the device, namely:
+
+- "bus": the bus that the IOMMU device uses
+- "ioatc-limit": size of the Address Translation Cache (default to 2Mb)
+- "intremap": enable/disable MSI support
+- "ats": enable ATS support
+- "off" (Out-of-reset translation mode: 'on' for DMA disabled, 'off' for 'BARE' (passthrough))
+- "s-stage": enable s-stage support
+- "g-stage": enable g-stage support
+
+.. _iommu1.0: https://github.com/riscv-non-isa/riscv-iommu/releases/download/v1.0/riscv-iommu.pdf
+
+.. _linux-v8: https://lore.kernel.org/linux-riscv/cover.1718388908.git.tjeznach@rivosinc.com/
diff --git a/docs/system/riscv/virt.rst b/docs/system/riscv/virt.rst
index c3f94f63da..dd884ea919 100644
--- a/docs/system/riscv/virt.rst
+++ b/docs/system/riscv/virt.rst
@@ -84,6 +84,19 @@ none``, as in
Firmware images used for pflash must be exactly 32 MiB in size.
+riscv-iommu support
+-------------------
+
+The board has support for the riscv-iommu-pci device by using the following
+command line:
+
+.. code-block:: bash
+
+ $ qemu-system-riscv64 -M virt -device riscv-iommu-pci (...)
+
+Refer to :ref:`riscv-iommu` for more information on how the RISC-V IOMMU support
+works.
+
Machine-specific options
------------------------
--
2.45.2
next prev parent reply other threads:[~2024-08-01 15:45 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-01 15:43 [PATCH for-9.2 v6 00/12] riscv: QEMU RISC-V IOMMU Support Daniel Henrique Barboza
2024-08-01 15:43 ` [PATCH for-9.2 v6 01/12] exec/memtxattr: add process identifier to the transaction attributes Daniel Henrique Barboza
2024-08-01 15:43 ` [PATCH for-9.2 v6 02/12] hw/riscv: add riscv-iommu-bits.h Daniel Henrique Barboza
2024-08-04 23:04 ` Alistair Francis
2024-08-05 18:25 ` Daniel Henrique Barboza
2024-08-05 23:46 ` Alistair Francis
2024-08-07 8:37 ` Jason Chien
2024-08-01 15:43 ` [PATCH for-9.2 v6 03/12] hw/riscv: add RISC-V IOMMU base emulation Daniel Henrique Barboza
2024-08-04 23:23 ` Alistair Francis
2024-08-17 11:34 ` Andrew Jones
2024-08-18 18:20 ` Daniel Henrique Barboza
2024-08-20 15:16 ` Jason Chien
2024-08-23 12:42 ` Daniel Henrique Barboza
2024-08-27 2:18 ` Tomasz Jeznach
2024-09-03 11:46 ` Daniel Henrique Barboza
2024-10-01 23:28 ` Tomasz Jeznach
2024-10-02 0:05 ` Daniel Henrique Barboza
2024-10-03 8:42 ` Andrew Jones
2024-08-01 15:43 ` [PATCH for-9.2 v6 04/12] pci-ids.rst: add Red Hat pci-id for RISC-V IOMMU device Daniel Henrique Barboza
2024-08-21 11:34 ` Gerd Hoffmann
2024-08-01 15:43 ` [PATCH for-9.2 v6 05/12] hw/riscv: add riscv-iommu-pci reference device Daniel Henrique Barboza
2024-08-01 15:43 ` [PATCH for-9.2 v6 06/12] hw/riscv/virt.c: support for RISC-V IOMMU PCIDevice hotplug Daniel Henrique Barboza
2024-08-01 15:43 ` [PATCH for-9.2 v6 07/12] test/qtest: add riscv-iommu-pci tests Daniel Henrique Barboza
2024-08-01 15:43 ` [PATCH for-9.2 v6 08/12] hw/riscv/riscv-iommu: add Address Translation Cache (IOATC) Daniel Henrique Barboza
2024-08-20 15:27 ` Jason Chien
2024-08-23 17:18 ` Daniel Henrique Barboza
2024-08-27 2:44 ` Tomasz Jeznach
2024-08-27 11:56 ` Daniel Henrique Barboza
2024-08-01 15:43 ` [PATCH for-9.2 v6 09/12] hw/riscv/riscv-iommu: add ATS support Daniel Henrique Barboza
2024-08-01 15:43 ` [PATCH for-9.2 v6 10/12] hw/riscv/riscv-iommu: add DBG support Daniel Henrique Barboza
2024-08-04 23:35 ` Alistair Francis
2024-08-01 15:43 ` [PATCH for-9.2 v6 11/12] qtest/riscv-iommu-test: add init queues test Daniel Henrique Barboza
2024-08-01 15:43 ` Daniel Henrique Barboza [this message]
2024-08-04 23:39 ` [PATCH for-9.2 v6 12/12] docs/specs: add riscv-iommu Alistair Francis
2024-09-03 12:56 ` Daniel Henrique Barboza
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240801154334.1009852-13-dbarboza@ventanamicro.com \
--to=dbarboza@ventanamicro.com \
--cc=ajones@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=bmeng@tinylab.org \
--cc=frank.chang@sifive.com \
--cc=jason.chien@sifive.com \
--cc=liwei1518@gmail.com \
--cc=palmer@rivosinc.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.