From: Jan Kiszka <[email protected]>

This allows to test PCI device assignment to non-root cells via a Linux
inmate. Specifically MSI-X can be stressed, in contrast to the default
e1000 model which only comes with INTx.

Signed-off-by: Jan Kiszka <[email protected]>
---
 README.md         |   2 +
 configs/qemu-vm.c | 109 +++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 89 insertions(+), 22 deletions(-)

diff --git a/README.md b/README.md
index ebb98fd..d4c734d 100644
--- a/README.md
+++ b/README.md
@@ -244,6 +244,7 @@ enable nested VMX support. Start the virtual machine as 
follows:
         -cpu kvm64,-kvm_pv_eoi,-kvm_steal_time,-kvm_asyncpf,-kvmclock,+vmx \
         -drive file=LinuxInstallation.img,format=raw|qcow2|...,id=disk,if=none 
\
         -device ide-hd,drive=disk -serial stdio -serial vc \
+        -netdev user,id=net -device e1000e,addr=2.0,netdev=net \
         -device intel-hda,addr=1b.0 -device hda-duplex
 
 For AMD CPUs: Make sure the kvm-amd module was loaded with nested=1 to enable
@@ -253,6 +254,7 @@ nested SVM support. Start the virtual machine as follows:
         -cpu host,-kvm_pv_eoi,-kvm_steal_time,-kvm_asyncpf,-kvmclock \
         -drive file=LinuxInstallation.img,format=raw|qcow2|...,id=disk,if=none 
\
         -device ide-hd,drive=disk -serial stdio -serial vc \
+        -netdev user,id=net -device e1000e,addr=2.0,netdev=net \
         -device intel-hda,addr=1b.0 -device hda-duplex
 
 Inside the VM, make sure that `jailhouse-*.bin`, generated by the build 
process,
diff --git a/configs/qemu-vm.c b/configs/qemu-vm.c
index d776b15..04d0c94 100644
--- a/configs/qemu-vm.c
+++ b/configs/qemu-vm.c
@@ -24,11 +24,11 @@
 struct {
        struct jailhouse_system header;
        __u64 cpus[1];
-       struct jailhouse_memory mem_regions[14];
+       struct jailhouse_memory mem_regions[16];
        struct jailhouse_irqchip irqchips[1];
        __u8 pio_bitmap[0x2000];
        struct jailhouse_pci_device pci_devices[9];
-       struct jailhouse_pci_capability pci_caps[5];
+       struct jailhouse_pci_capability pci_caps[11];
 } __attribute__((packed)) config = {
        .header = {
                .signature = JAILHOUSE_SYSTEM_SIGNATURE,
@@ -108,45 +108,59 @@ struct {
                        .size = 0x1000000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
                },
-               /* MemRegion: fe000000-fe7fffff : 0000:00:1f.7 (virtio-9p) */
+               /* MemRegion: fe000000-fe003fff : 0000:00:1f.7 (virtio-9p) */
                {
                        .phys_start = 0xfe000000,
                        .virt_start = 0xfe000000,
-                       .size = 0x800000,
+                       .size = 0x4000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
+               },
+               /* MemRegion: feb40000-feb7ffff : 0000:00:02.0 */
+               {
+                       .phys_start = 0xfeb40000,
+                       .virt_start = 0xfeb40000,
+                       .size = 0x40000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
                },
-               /* MemRegion: feb80000-febbffff : 0000:00:02.0 (e1000) */
+               /* MemRegion: feb80000-feb9ffff : e1000e */
                {
                        .phys_start = 0xfeb80000,
                        .virt_start = 0xfeb80000,
-                       .size = 0x40000,
+                       .size = 0x20000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
                },
-               /* MemRegion: febc0000-febdffff : 0000:00:02.0 (e1000) */
+               /* MemRegion: feba0000-febbffff : e1000e */
                {
-                       .phys_start = 0xfebc0000,
-                       .virt_start = 0xfebc0000,
+                       .phys_start = 0xfeba0000,
+                       .virt_start = 0xfeba0000,
                        .size = 0x20000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
                },
-               /* MemRegion: febf0000-febf3fff : 0000:00:1b.0 (ICH HD audio) */
+               /* MemRegion: febd1000-febd3fff : e1000e */
+               {
+                       .phys_start = 0xfebd1000,
+                       .virt_start = 0xfebd1000,
+                       .size = 0x3000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
+               },
+               /* MemRegion: febd4000-febd7fff : 0000:00:1b.0 (ICH HD audio) */
                {
-                       .phys_start = 0xfebf0000,
-                       .virt_start = 0xfebf0000,
+                       .phys_start = 0xfebd4000,
+                       .virt_start = 0xfebd4000,
                        .size = 0x4000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
                },
-               /* MemRegion: febf4000-febf4fff : 0000:00:01.0 (vesafd) */
+               /* MemRegion: febd8000-febd8fff : 0000:00:01.0 (vesafd) */
                {
-                       .phys_start = 0xfebf4000,
-                       .virt_start = 0xfebf4000,
+                       .phys_start = 0xfebd8000,
+                       .virt_start = 0xfebd8000,
                        .size = 0x1000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
                },
-               /* MemRegion: febf5000-febf5fff : 0000:00:1f.2 (ahci) */
+               /* MemRegion: febd9000-febd9fff : 0000:00:1f.2 (ahci) */
                {
-                       .phys_start = 0xfebf5000,
-                       .virt_start = 0xfebf5000,
+                       .phys_start = 0xfebd9000,
+                       .virt_start = 0xfebd9000,
                        .size = 0x1000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
                },
@@ -217,10 +231,21 @@ struct {
                        .domain = 0x0000,
                        .bdf = 0x0008,
                },
-               { /* e1000 */
+               { /* e1000e */
                        .type = JAILHOUSE_PCI_TYPE_DEVICE,
                        .domain = 0x0000,
                        .bdf = 0x0010,
+                       .bar_mask = {
+                               0xfffe0000, 0xfffe0000, 0xffffffe0,
+                               0xffffc000, 0x00000000, 0x00000000,
+                       },
+                       .caps_start = 5,
+                       .num_caps = 6,
+                       .num_msi_vectors = 1,
+                       .msi_64bits = 1,
+                       .num_msix_vectors = 5,
+                       .msix_region_size = 0x1000,
+                       .msix_address = 0xfebd0000,
                },
                { /* ICH HD audio */
                        .type = JAILHOUSE_PCI_TYPE_DEVICE,
@@ -254,11 +279,15 @@ struct {
                        .type = JAILHOUSE_PCI_TYPE_DEVICE,
                        .domain = 0x0000,
                        .bdf = 0x00ff,
+                       .bar_mask = {
+                               0xffffffe0, 0xfffff000, 0x00000000,
+                               0x00000000, 0xffffc000, 0xffffffff,
+                       },
                        .caps_start = 4,
                        .num_caps = 1,
                        .num_msix_vectors = 2,
                        .msix_region_size = 0x1000,
-                       .msix_address = 0xfebf6000,
+                       .msix_address = 0xfebda000,
                },
                { /* IVSHMEM (networking) */
                        .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
@@ -269,7 +298,7 @@ struct {
                                0x00000000, 0xffffffe0, 0xffffffff,
                        },
                        .num_msix_vectors = 1,
-                       .shmem_region = 12,
+                       .shmem_region = 14,
                        .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
                },
                { /* IVSHMEM (demo) */
@@ -281,7 +310,7 @@ struct {
                                0x00000000, 0xffffffe0, 0xffffffff,
                        },
                        .num_msix_vectors = 1,
-                       .shmem_region = 13,
+                       .shmem_region = 15,
                        .shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
                },
        },
@@ -316,5 +345,41 @@ struct {
                        .len = 12,
                        .flags = JAILHOUSE_PCICAPS_WRITE,
                },
+               { /* e1000e */
+                       .id = 0x1,
+                       .start = 0xc8,
+                       .len = 8,
+                       .flags = JAILHOUSE_PCICAPS_WRITE,
+               },
+               {
+                       .id = 0x5,
+                       .start = 0xd0,
+                       .len = 14,
+                       .flags = JAILHOUSE_PCICAPS_WRITE,
+               },
+               {
+                       .id = 0x10,
+                       .start = 0xe0,
+                       .len = 20,
+                       .flags = JAILHOUSE_PCICAPS_WRITE,
+               },
+               {
+                       .id = 0x11,
+                       .start = 0xa0,
+                       .len = 12,
+                       .flags = JAILHOUSE_PCICAPS_WRITE,
+               },
+               {
+                       .id = 0x1 | JAILHOUSE_PCI_EXT_CAP,
+                       .start = 0x100,
+                       .len = 4,
+                       .flags = 0,
+               },
+               {
+                       .id = 0x3 | JAILHOUSE_PCI_EXT_CAP,
+                       .start = 0x140,
+                       .len = 4,
+                       .flags = 0,
+               },
        },
 };
-- 
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