Hi folks: Hello everyone, I have a few questions regarding the QEMU device passthrough feature that I’d like to ask for help with.
Both my HOST OS and GUEST OS are running Ubuntu 20.4.6. I passed through a dedicated NVIDIA MX250 GPU from the HOST to the GUEST OS. On the HOST, I installed the VFIO-PCI driver for passthrough, while the GUEST OS uses the default Nouveau driver from Ubuntu 20.4.6. I also enabled IOMMU in the GUEST OS and checked the IOMMU group layout from sysfs"/sys/kernel/iommu_group/xxxx/type". The passthrough MX250 operates in “DMA” translation mode,which means the translation really work. Thanks to your excellent work, the setup process went smoothly and everything runs well. However, I have a couple of questions: Is the IOMMU (DMAR) in the GUEST OS emulated by QEMU, or does it share the same IOMMU as the HOST OS? Given that both the GUEST OS and HOST OS have IOMMU enabled, when the MX250 performs DMA, it should go through two-stage page table translation—first in the GUEST OS and then in the HOST OS—with VFIO-PCI assisting in this process, correct? If so, are both stages handled by hardware? I understand that the second stage is definitely hardware-assisted, but I’m uncertain about the first stage: whether the translation from IOVA to GPA (IPA) within the GUEST OS is also hardware-assisted. Those are my two questions. Thank you very much for your help! some information about my env: Qemu Launch VM command: qemu-system-x86_64 -cpu qemu64,+mtrr,+ssse3,sse4.1,+sse4.2 -m 4096 -smp 4 --enable-kvm -drive file=./test-vm-1.qcow2,if=virtio -machine q35,kernel-irqchip=split -device intel-iommu,intremap=on,caching-mode=on -device vfio-pci,host=02:00.0 vms@vms-Standard-PC-i440FX-PIIX-1996:/sys/class/iommu/dmar0/devices$ ls 0000:00:00.0 0000:00:01.0 0000:00:02.0 0000:00:03.0 0000:00:04.0 0000:00:1f.0 0000:00:1f.2 0000:00:1f.3 vms@vms-Standard-PC-i440FX-PIIX-1996:/sys/class/iommu/dmar0/devices$ lspci 00:00.0 Host bridge: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller 00:01.0 VGA compatible controller: Device 1234:1111 (rev 02) 00:02.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection 00:03.0 3D controller: NVIDIA Corporation GP108M [GeForce MX250] (rev a1) 00:04.0 SCSI storage controller: Red Hat, Inc. Virtio block device 00:1f.0 ISA bridge: Intel Corporation 82801IB (ICH9) LPC Interface Controller (rev 02) 00:1f.2 SATA controller: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] (rev 02) 00:1f.3 SMBus: Intel Corporation 82801I (ICH9 Family) SMBus Controller (rev 02) vms@vms-Standard-PC-i440FX-PIIX-1996:/sys/class/iommu/dmar0/devices$ cat /sys/kernel/iommu_groups/ 0/ 1/ 2/ 3/ 4/ 5/ vms@vms-Standard-PC-i440FX-PIIX-1996:/sys/class/iommu/dmar0/devices$ cat /sys/kernel/iommu_groups/*/type DMA DMA DMA DMA DMA DMA vms@vms-Standard-PC-i440FX-PIIX-1996:/sys/class/iommu/dmar0/devices BRs zlc
