Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Passthrough allows you to give control of physical devices to guests domus. This page has a few examples for device passthroughs.

Table of Contents
minLevel1
maxLevel7

PSUART assignment

Turn xen.dtb into xen.dts:

Code Block
dtc -I dtb -O dts xen.dtb > xen.dts

The, edit xen.dts by adding xen,passthrough; under the node of the device to assign, in this case serial@ff000000:

Code Block
serial@ff010000 {
			compatible = "cdns,uart-r1p12", "xlnx,xuartps";
			status = "okay";
			interrupt-parent = <0xfde8>;
			interrupts = <0x0 0x16 0x4>;
			reg = <0x0 0xff010000 0x1000>;
			device_type = "serial";
			clock-names = "uart_clk", "pclk";
			power-domains = <0x26 0x22>;
			clocks = <0x1e 0x1f>;
			cts-override;
			port-number = <0x1>;
			xen,passthrough; /* add this line */
		};

Convert xen.dts back into xen.dtb:

Code Block
dtc -I dts -O dtb xen.dts > xen.dtb

To enable the PSUART assignment to a domU. Below is one example for the dom create config file. 

...

To calculate irqs corresponding to the guest domain, it needs to find the following line in UART settings described in xen.dts file:

Code Block
serial@ff010000 {
			compatible = "cdns,uart-r1p12", "xlnx,xuartps";
			status = "okay";
			interrupt-parent = <0xfde8>;
			interrupts = <0x0 0x16 0x4>;

take the interrupt which is device specific, in this case interrupt number is 0x16, add 32 which is the base address of interrupt handler.

...

Turn xen.dtb into xen.dts:

Code Block
dtc -I dtb -O dts xen.dtb > xen.dts

The, edit xen.dts by adding xen,passthrough; under the node of the device to assign, in this case pcie@fd0e0000:

Code Block
pcie@fd0e0000 {
    compatible = "xlnx,nwl-pcie-2.11";
    status = "disabled";
    #address-cells = <0x3>;
    #size-cells = <0x2>;
    #interrupt-cells = <0x1>;
    msi-controller;
    device_type = "pci";
    interrupt-parent = <0x4>;
    interrupts = <0x0 0x76 0x4 0x0 0x75 0x4 0x0 0x74 0x4 0x0 0x73 0x4 0x0 0x72 0x4>;
    interrupt-names = "misc", "dummy", "intx", "msi1", "msi0";
    msi-parent = <0x31>;
    reg = <0x0 0xfd0e0000 0x0 0x1000 0x0 0xfd480000 0x0 0x1000 0x80 0x0 0x0 0x1000000>;
    reg-names = "breg", "pcireg", "cfg";
    ranges = <0x2000000 0x0 0xe0000000 0x0 0xe0000000 0x0 0x10000000 0x43000000 0x6 0x0 0x6 0x0 0x2 0x0>;
    interrupt-map-mask = <0x0 0x0 0x0 0x7>;
    bus-range = <0x0 0xff>;
    interrupt-map = <0x0 0x0 0x0 0x1 0x32 0x1 0x0 0x0 0x0 0x2 0x32 0x2 0x0 0x0 0x0 0x3 0x32 0x3 0x0 0x0 0x0 0x4 0x32 0x4>;
    power-domains = <0x26 0x3b>;
    clocks = <0x3 0x17>;
    xlnx,bar0-enable = <0x0>;
    xlnx,bar1-enable = <0x0>;
    xlnx,bar2-enable = <0x0>;
    xlnx,bar3-enable = <0x0>;
    xlnx,bar4-enable = <0x0>;
    xlnx,bar5-enable = <0x0>;
    xlnx,pcie-mode = "Root Port";
    xlnx,tz-nonsecure = <0x0>;
    phandle = <0x31>;
    iommus = <0x28 0x4d0>;
    xen,passthrough = <1>;
    legacy-interrupt-controller {
            interrupt-controller;
            #address-cells = <0x0>;
            #interrupt-cells = <0x1>;
            phandle = <0x32>;
    };
}; 

Since the PCIe is a DMA-capable device, it should be included in the SMMU section of the xen.dts. Make sure that the PCIe base address in the IOMMU address map exists in the list of mmu-masters. Please refer the latest version of Zynq Ultrascale + MPSoC TRM (UG1085):
a) Find PCIe master device in the table given in the section AXI Master IDs and pick the corresponding master ID, which is 0011010000.
b) Expand these 10 bits to 12 bits, the top 2 bits are simply indicating which TBUn device is behind, this can be found in the Zynq UltraScale+ MPSoC TRM
Interconnect Functional Description section. For PCIe it is TBU1, i.e. the address will be 010011010000=0x4d0.

...

Creation of passthrough-pci.dts:
Please see attached passthrough-pci.dts (Please use

View file
namepci_passthrough_2023.dts
for release 2023 onwards)for example of partial device tree file and convert the above dtc into dtb using dtc compiler:

...

Finally, The next step is to configure guest domain to correspond to the pass-through mode.
The guest configuration file should look as follows for release v2022 or older:

Code Block
# Guest name
name = "guest0"
# Kernel image to boot
kernel = "/boot/Image"
ramdisk = "/boot/xen-rootfs.cpio.gz"
extra = "root=/dev/ram0 init=/bin/sh console=hvc0 rdinit=/sbin/init"
# Initial memory allocation (MB)
memory = 1024
# Number of VCPUS
vcpus = 2
# Passthrough
dtdev = [ "/amba/pcie@fd0e0000" ]
device_tree = "/etc/xen/domu.dtb"
irqs = [ 146, 147, 148, 150 ]
iomem = [ "0xfd0e0,1", "0xfd480,1", "0xe0000,1000"]

For newer release versions(2023 onwards), please use following guest configs:

Code Block
name = "guest0"
kernel = "/boot/Image"
ramdisk = "/boot/xen-rootfs.cpio.gz"
extra = "root=/dev/ram0 init=/bin/sh console=hvc0 rdinit=/sbin/init"
# Initial memory allocation (MB)
memory = 1600
vcpus = 2
dtdev = [ "/axi/pcie@fd0e0000" ]
device_tree = "/etc/xen/pci_passthrough.dtb"
irqs = [ 146, 147, 148, 149, 150 ]
iomem = [ "0xfd0e0,1", "0xfd480,1", "0xe0000,1000", "0x600000,1000", "0x8000000,1000"]

The options needed for pass-through mode are defined below:
dtdev - The absolute path of the device to be passed through in the device tree
device_tree - absolute path of partial device tree in the Domain 0
irqs - interrupt number inside interrupt queue for the guest domain (see calculation steps below)
iomem - the number of physical memory pages to be passed to the guest (see calculation steps below)

...