Page MenuHomeFreeBSD

RISC-V IOMMU support
ClosedPublic

Authored by br on Mar 18 2026, 5:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 14, 11:02 AM
Unknown Object (File)
Wed, May 13, 4:10 PM
Unknown Object (File)
Tue, May 12, 10:00 AM
Unknown Object (File)
Mon, May 11, 5:43 AM
Unknown Object (File)
Wed, Apr 29, 12:00 PM
Unknown Object (File)
Wed, Apr 29, 12:00 PM
Unknown Object (File)
Apr 15 2026, 12:23 AM
Unknown Object (File)
Apr 12 2026, 8:58 PM

Details

Summary

Support for RISC-V IOMMU spec v1.0.1 (ratified)

https://github.com/riscv-non-isa/riscv-iommu

Supports translation for PCI devices only.

Supports 1 or 2-level device-directory-table (DDT).

Supports SV39 and SV48 virtual memory system (on per-device basis).

Supports both "standard" and "extended" device-context (DC) structure.

Supports "bypass" mode to disable translation for a particular device.

Supports WSI (Wire-Signalled Interrupts) only.

This includes both PCI-bus and FDT attachment drivers.

Note in case of PCI-bus attachment, interrupts are not available. In this case no error report is provided in case of translation fault. Otherwise interrupts are not needed.

Test Plan

Tested in QEMU only, with virtio-block and virtio-network devices.

Ensure that "hw.busdma.default" kernel boot variable is enabled.

For virtio-network device (to sit behind MMU) apply this https://reviews.freebsd.org/D55492

Virtio-block should work without additional patch.

FDT:

./qemu-system-riscv64 -nographic \
	-machine virt,iommu-sys=on \
	-cpu 'rv64,h=true,sscofpmf=true' \
	-smp 8 \
	-netdev tap,ifname=tap0,script=no,id=net0 \
	-device virtio-blk-pci,iommu_platform=on,disable-legacy=on,drive=disk \
	-drive file=${DRIVE_FILE},id=disk,format=raw,if=none,cache=writeback \
	-device virtio-blk-pci,iommu_platform=on,disable-legacy=on,drive=disk2 \
	-drive file=${DRIVE2},id=disk2,format=raw,if=none,cache=writeback \
	-device virtio-net-pci,iommu_platform=on,disable-legacy=on,netdev=net0 \
	-m 16G \
	-bios /usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf \
	-kernel ${KERNEL}

PCI:

./qemu-system-riscv64 -nographic \
	-machine virt,iommu-sys=off \
	-device riscv-iommu-pci,addr=1.0 \
	-cpu 'rv64,h=true,sscofpmf=true' \
	-smp 8 \
	-netdev tap,ifname=tap0,script=no,id=net0 \
	-device virtio-blk-pci,iommu_platform=on,disable-legacy=on,drive=disk \
	-drive file=${DRIVE_FILE},id=disk,format=raw,if=none,cache=writeback \
	-device virtio-blk-pci,iommu_platform=on,disable-legacy=on,drive=disk2 \
	-drive file=${DRIVE2},id=disk2,format=raw,if=none,cache=writeback \
	-device virtio-net-pci,iommu_platform=on,disable-legacy=on,netdev=net0 \
	-m 16G \
	-bios /usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf \
	-kernel ${KERNEL}

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

br requested review of this revision.Mar 18 2026, 5:23 PM
br created this revision.
sys/riscv/include/iommu.h
9

Just taking an initial cursory glance, all these #include <riscv/...> should be #include <machine/...>

minsoochoo0122_proton.me added inline comments.
sys/riscv/iommu/iommu.h
2–27

The preferred policy recommends not writing out the full license text, but ofc you can if you want.

same for other newly added files.

https://docs.freebsd.org/en/articles/license-guide/

/*
 * Copyright (c) [year] [your name]
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */
adrian added inline comments.
sys/riscv/iommu/iommu_if.m
2

Would it make sense to push this layering abstraction up to sys/dev/iommu/ first? So arm64 can also implement >1 iommu provider?

sys/riscv/iommu/iommu_if.m
2

arm64 has one already:

sys/arm64/iommu/iommu_if.m

but we can unite them later in a single one

This revision was not accepted when it landed; it landed in state Needs Review.Tue, May 12, 10:21 AM
Closed by commit rGbcecad2c24aa: riscv: IOMMU support (authored by br). · Explain Why
This revision was automatically updated to reflect the committed changes.