Re: how test the Translation Support for SMMUv3?

Nicolin Chen
2023-12-27T21:31:59Z

On Wed, Dec 27, 2023 at 03:46:41PM +0800, Ben wrote:
> Hi Nicolin,
> I saw your pachset on Add Nested Translation Support for SMMUv3
> [LWN.net]<https://lwn.net/Articles/931502/>, i have built the
> kernel and qemu you provided in cover letter.
> I run a QEMU system as Host, and launch a VM by kvmtool. But i
> cannot find a IOMMU on VM, how do you test your patchset?

Make sure you build the kernel with CONFIG_IOMMUFD, and QEMU
likely.

> would you like provide your steps?

# A set of sample commands
echo 0002:01:00.0 | tee /sys/bus/pci/devices/0002\:01\:00.0/driver/unbind; dmesg | tail
echo 8086 0111 | tee /sys/bus/pci/drivers/vfio-pci/new_id

qemu-1214 -object iommufd,id=iommufd0 \
-machine virt,accel=kvm,gic-version=3,iommu=nested-smmuv3,iommufd=iommufd0 \
-cpu host -m 256m -nographic -kernel /root/Image -bios /root/AAVMF_CODE.fd \
-initrd /root/buildroot-20200422-aarch64-qemu-test-rootfs.cpio \
-object memory-backend-ram,size=256m,id=m0 -numa node,cpus=0,nodeid=0,memdev=m0 \
-device vfio-pci,host=0002:01:00.0,rombar=0,iommufd=iommufd0,id="test0"

> BTW, i add a printk on arm_smmu_device_hw_probe() to print out the smmu->features , it looks your QEMU still only support ARM_SMMU_FEAT_TRANS_S1.

QEMU is used by the guest that should only support S1. The host
kernel on the hand should support both S1 and S2 for nesting.

> Does it provide a vIOMMU of SMMUv3 for your kernel and qemu patchset?

Once you boot with "iommu=nested-smmuv3", there should be one.