Page MenuHomeFreeBSD

RISC-V IOMMU support
Needs ReviewPublic

Authored by br on Wed, Mar 18, 5:23 PM.

Details

Reviewers
jrtc27
mhorne
markj
Group Reviewers
riscv
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

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

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

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