xen-troops / meta-xt-prod-devel-rpi5

Apache License 2.0
3 stars 5 forks source link

How to use rpi5 iommu for passthrough? #43

Closed LJKingd closed 1 month ago

LJKingd commented 1 month ago

I noticed that there are IOMMU device nodes in the device tree of the Raspberry Pi 5. In Xen, how can I enable these IOMMU devices?

When starting a DomU with Dom0, if I want to perform device passthrough, I need to enable IOMMU in Xen to achieve it, right? And it is necessary to have "I/O virtualisation enabled" printed when Xen initializes.

lorc commented 1 month ago

Hi @LJKingd

Problem with RPi5 is that it does not have IO-MMU that support Stage 2 translations. So, on this platform it is not possible to get classic device-passthrough.

LJKingd commented 1 month ago

@lorc Thank you very much for your reply. I noticed that there is such an IOMMU node in bcm2712-5-b.dts. Does this mean that the Raspberry Pi 5 has an IOMMU module? If so, why can't it be used? iommu@5100 { compatible = "brcm,bcm2712-iommu"; reg = <0x10 0x5100 0x00 0x80>; cache = <0x2b>;

iommu-cells = <0x00>;

                    phandle = <0x53>;
            }
lorc commented 1 month ago

Yes, it in fact has IOMMU module, but it is for Stage 1 translation only. I.e. it only can be used by Linux kernel.

This IOMMU covers only small part of address space. Its purpose is to create physically contiguous memory regions from discontiguous buffers for devices that does not support scatter-gather DMA operations. It is more like TILER module from TI chips than real IO-MMU like ARM's SMMU or Renesas's IPMMU.

LJKingd commented 1 month ago

@lorc Thanks for your answer. I understand now.