Describe the PCI resources of the AMD Seattle so that devices can be
reassigned.

Also add one ivshmem device for networking purposes and extend the
non-root Linux cell accordingly. We can safely expose the physical
GICv2m for this purpose, but read-only. To avoid that root and non-root
cell use the same MSI frame (which are reported by the GICv2m),
overwrite the frame parameter in the non-root cell device tree.

Signed-off-by: Jan Kiszka <[email protected]>
---
 configs/amd-seattle-linux-demo.c   | 48 +++++++++++++++++++++++++++++-----
 configs/amd-seattle.c              | 53 ++++++++++++++++++++++++++++----------
 configs/dts/inmate-amd-seattle.dts | 39 +++++++++++++++++++++++++++-
 3 files changed, 119 insertions(+), 21 deletions(-)

diff --git a/configs/amd-seattle-linux-demo.c b/configs/amd-seattle-linux-demo.c
index 8f467a6..6f2f67a 100644
--- a/configs/amd-seattle-linux-demo.c
+++ b/configs/amd-seattle-linux-demo.c
@@ -18,8 +18,9 @@
 struct {
        struct jailhouse_cell_desc cell;
        __u64 cpus[1];
-       struct jailhouse_memory mem_regions[6];
-       struct jailhouse_irqchip irqchips[1];
+       struct jailhouse_memory mem_regions[8];
+       struct jailhouse_irqchip irqchips[2];
+       struct jailhouse_pci_device pci_devices[1];
 } __attribute__((packed)) config = {
        .cell = {
                .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
@@ -28,9 +29,8 @@ struct {
 
                .cpu_set_size = sizeof(config.cpus),
                .num_memory_regions = ARRAY_SIZE(config.mem_regions),
-               .num_irqchips = 1,
-               .pio_bitmap_size = 0,
-               .num_pci_devices = 0,
+               .num_irqchips = ARRAY_SIZE(config.irqchips),
+               .num_pci_devices = ARRAY_SIZE(config.pci_devices),
        },
 
        .cpus = {
@@ -82,11 +82,33 @@ struct {
                                JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
                                JAILHOUSE_MEM_LOADABLE,
                },
+               /* IVSHMEM shared memory region */ {
+                       .phys_start = 0x82fbe00000,
+                       .virt_start = 0x82fbe00000,
+                       .size =           0x100000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_ROOTSHARED,
+               },
+               /* v2m */ {
+                       .phys_start = 0xe1180000,
+                       .virt_start = 0xe1180000,
+                       .size =           0x1000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_IO |
+                               JAILHOUSE_MEM_ROOTSHARED,
+               },
        },
 
        .irqchips = {
                /* GIC */ {
                        .address = 0xe1110000,
+                       .pin_base = 32,
+                       .pin_bitmap = {
+                               0, 0,
+                               (1 << (100 - 96)) /* MSI */
+                       },
+               },
+               /* GIC */ {
+                       .address = 0xe1110000,
                        .pin_base = 352,
                        .pin_bitmap = {
                                (1 << (354 - 352)) | /* xgmac1 */
@@ -98,5 +120,19 @@ struct {
                                (1 << (376 - 352))   /* xgmac1 */
                        },
                },
-       }
+       },
+
+       .pci_devices = {
+               /* 00:0f.0 */ {
+                       .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
+                       .bdf = 0x0078,
+                       .bar_mask = {
+                               0xffffff00, 0xffffffff, 0x00000000,
+                               0x00000000, 0xffffffe0, 0xffffffff,
+                       },
+                       .num_msix_vectors = 1,
+                       .shmem_region = 6,
+                       .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
+               },
+       },
 };
diff --git a/configs/amd-seattle.c b/configs/amd-seattle.c
index 7298bec..cd589e5 100644
--- a/configs/amd-seattle.c
+++ b/configs/amd-seattle.c
@@ -20,6 +20,7 @@ struct {
        __u64 cpus[1];
        struct jailhouse_memory mem_regions[16];
        struct jailhouse_irqchip irqchips[3];
+       struct jailhouse_pci_device pci_devices[3];
 } __attribute__((packed)) config = {
        .header = {
                .signature = JAILHOUSE_SYSTEM_SIGNATURE,
@@ -32,12 +33,16 @@ struct {
                        .size = 0x1000,
                        .flags = JAILHOUSE_MEM_IO,
                },
-               .platform_info.arm = {
-                       .gicd_base = 0xe1110000,
-                       .gicc_base = 0xe112f000,
-                       .gich_base = 0xe1140000,
-                       .gicv_base = 0xe116f000,
-                       .maintenance_irq = 25,
+               .platform_info = {
+                       .pci_mmconfig_base = 0xf0000000,
+                       .pci_mmconfig_end_bus = 255,
+                       .arm = {
+                               .gicd_base = 0xe1110000,
+                               .gicc_base = 0xe112f000,
+                               .gich_base = 0xe1140000,
+                               .gicv_base = 0xe116f000,
+                               .maintenance_irq = 25,
+                       },
                },
                .root_cell = {
                        .name = "amd-seattle",
@@ -45,6 +50,7 @@ struct {
                        .cpu_set_size = sizeof(config.cpus),
                        .num_memory_regions = ARRAY_SIZE(config.mem_regions),
                        .num_irqchips = ARRAY_SIZE(config.irqchips),
+                       .num_pci_devices = ARRAY_SIZE(config.pci_devices),
                },
        },
 
@@ -151,13 +157,6 @@ struct {
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
                                JAILHOUSE_MEM_IO,
                },
-               /* pcie */ {
-                       .phys_start = 0xf0000000,
-                       .virt_start = 0xf0000000,
-                       .size =       0x10000000,
-                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
-                               JAILHOUSE_MEM_IO,
-               },
                /* RAM */ {
                        .phys_start = 0x8000000000,
                        .virt_start = 0x8000000000,
@@ -165,6 +164,12 @@ struct {
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
                                JAILHOUSE_MEM_EXECUTE,
                },
+               /* IVSHMEM shared memory region */ {
+                       .phys_start = 0x82fbe00000,
+                       .virt_start = 0x82fbe00000,
+                       .size =           0x100000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
+               },
        },
        .irqchips = {
                /* GIC */ {
@@ -189,5 +194,25 @@ struct {
                        },
                },
        },
-
+       .pci_devices = {
+               /* 00:00.0 */ {
+                       .type = JAILHOUSE_PCI_TYPE_BRIDGE,
+                       .bdf = 0x0000,
+               },
+               /* 00:02.0 */ {
+                       .type = JAILHOUSE_PCI_TYPE_BRIDGE,
+                       .bdf = 0x0010,
+               },
+               /* 00:0f.0 */ {
+                       .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
+                       .bdf = 0x0078,
+                       .bar_mask = {
+                               0xffffff00, 0xffffffff, 0x00000000,
+                               0x00000000, 0xffffffe0, 0xffffffff,
+                       },
+                       .num_msix_vectors = 1,
+                       .shmem_region = 15,
+                       .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
+               },
+       },
 };
diff --git a/configs/dts/inmate-amd-seattle.dts 
b/configs/dts/inmate-amd-seattle.dts
index 2ba2f04..62d29e1 100644
--- a/configs/dts/inmate-amd-seattle.dts
+++ b/configs/dts/inmate-amd-seattle.dts
@@ -57,10 +57,19 @@
        gic: interrupt-controller@e1110000 {
                compatible = "arm,gic-400", "arm,cortex-a15-gic";
                #interrupt-cells = <3>;
-               #address-cells = <0>;
+               #address-cells = <2>;
+               #size-cells = <2>;
                interrupt-controller;
                reg = <0x0 0xe1110000 0 0x1000>,
                      <0x0 0xe112f000 0 0x2000>;
+               ranges = <0 0 0 0xe1100000 0 0x100000>;
+               v2m0: v2m@e0080000 {
+                       compatible = "arm,gic-v2m-frame";
+                       msi-controller;
+                       reg = <0x0 0x00080000 0 0x1000>;
+                       arm,msi-base-spi = <100>;
+                       arm,msi-num-spis = <1>;
+               };
        };
 
        timer {
@@ -140,5 +149,33 @@
                        #stream-id-cells = <24>;
                        dma-coherent;
                };
+
+               pcie0: pcie@f0000000 {
+                       compatible = "pci-host-ecam-generic";
+                       #address-cells = <3>;
+                       #size-cells = <2>;
+                       #interrupt-cells = <1>;
+                       device_type = "pci";
+                       bus-range = <0 0x7f>;
+                       msi-parent = <&v2m0>;
+                       reg = <0 0xf0000000 0 0x10000000>;
+
+                       interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
+                       interrupt-map =
+                               <0x1000 0x0 0x0 0x1 &gic 0x0 0x0 0x0 0x120 0x1>,
+                               <0x1000 0x0 0x0 0x2 &gic 0x0 0x0 0x0 0x121 0x1>,
+                               <0x1000 0x0 0x0 0x3 &gic 0x0 0x0 0x0 0x122 0x1>,
+                               <0x1000 0x0 0x0 0x4 &gic 0x0 0x0 0x0 0x123 0x1>;
+
+                       dma-coherent;
+                       dma-ranges = <0x43000000 0x0 0x0 0x0 0x0 0x100 0x0>;
+                       ranges =
+                               /* I/O Memory (size=64K) */
+                               <0x01000000 0x00 0x00000000 0x00 0xefff0000 
0x00 0x00010000>,
+                               /* 32-bit MMIO (size=2G) */
+                               <0x02000000 0x00 0x40000000 0x00 0x40000000 
0x00 0x80000000>,
+                               /* 64-bit MMIO (size= 124G) */
+                               <0x03000000 0x01 0x00000000 0x01 0x00000000 
0x7f 0x00000000>;
+               };
        };
 };
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to