diff options
Diffstat (limited to 'meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0001-xen_arm-Create-virtio-mmio-devices-during-initializa.patch')
-rw-r--r-- | meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0001-xen_arm-Create-virtio-mmio-devices-during-initializa.patch | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0001-xen_arm-Create-virtio-mmio-devices-during-initializa.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0001-xen_arm-Create-virtio-mmio-devices-during-initializa.patch new file mode 100644 index 00000000..1757e9e2 --- /dev/null +++ b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0001-xen_arm-Create-virtio-mmio-devices-during-initializa.patch | |||
@@ -0,0 +1,116 @@ | |||
1 | From b9291457ca2eb4340c71d2eed08fde83916c9fa4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> | ||
3 | Date: Tue, 29 Aug 2023 21:35:17 -0700 | ||
4 | Subject: [PATCH 01/11] xen_arm: Create virtio-mmio devices during | ||
5 | initialization | ||
6 | |||
7 | In order to use virtio backends we need to allocate virtio-mmio | ||
8 | parameters (irq and base) and register corresponding buses. | ||
9 | |||
10 | Use the constants defined in public header arch-arm.h to be | ||
11 | aligned with the toolstack. So the number of current supported | ||
12 | virtio-mmio devices is 10. | ||
13 | |||
14 | For the interrupts triggering use already existing on Arm | ||
15 | device-model hypercall. | ||
16 | |||
17 | The toolstack should then insert the same amount of device nodes | ||
18 | into guest device-tree. | ||
19 | |||
20 | Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> | ||
21 | Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com> | ||
22 | Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> | ||
23 | Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com> | ||
24 | --- | ||
25 | hw/arm/xen_arm.c | 35 +++++++++++++++++++++++++++++++++++ | ||
26 | include/hw/xen/xen_native.h | 16 ++++++++++++++++ | ||
27 | 2 files changed, 51 insertions(+) | ||
28 | |||
29 | diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c | ||
30 | index 1d3e6d481a..7393b37355 100644 | ||
31 | --- a/hw/arm/xen_arm.c | ||
32 | +++ b/hw/arm/xen_arm.c | ||
33 | @@ -26,6 +26,7 @@ | ||
34 | #include "qapi/qapi-commands-migration.h" | ||
35 | #include "qapi/visitor.h" | ||
36 | #include "hw/boards.h" | ||
37 | +#include "hw/irq.h" | ||
38 | #include "hw/sysbus.h" | ||
39 | #include "sysemu/block-backend.h" | ||
40 | #include "sysemu/tpm_backend.h" | ||
41 | @@ -59,6 +60,38 @@ struct XenArmState { | ||
42 | } cfg; | ||
43 | }; | ||
44 | |||
45 | +/* | ||
46 | + * VIRTIO_MMIO_DEV_SIZE is imported from tools/libs/light/libxl_arm.c under Xen | ||
47 | + * repository. | ||
48 | + * | ||
49 | + * Origin: git://xenbits.xen.org/xen.git 2128143c114c | ||
50 | + */ | ||
51 | +#define VIRTIO_MMIO_DEV_SIZE 0x200 | ||
52 | + | ||
53 | +#define NR_VIRTIO_MMIO_DEVICES \ | ||
54 | + (GUEST_VIRTIO_MMIO_SPI_LAST - GUEST_VIRTIO_MMIO_SPI_FIRST) | ||
55 | + | ||
56 | +static void xen_set_irq(void *opaque, int irq, int level) | ||
57 | +{ | ||
58 | + xendevicemodel_set_irq_level(xen_dmod, xen_domid, irq, level); | ||
59 | +} | ||
60 | + | ||
61 | +static void xen_create_virtio_mmio_devices(XenArmState *xam) | ||
62 | +{ | ||
63 | + int i; | ||
64 | + | ||
65 | + for (i = 0; i < NR_VIRTIO_MMIO_DEVICES; i++) { | ||
66 | + hwaddr base = GUEST_VIRTIO_MMIO_BASE + i * VIRTIO_MMIO_DEV_SIZE; | ||
67 | + qemu_irq irq = qemu_allocate_irq(xen_set_irq, NULL, | ||
68 | + GUEST_VIRTIO_MMIO_SPI_FIRST + i); | ||
69 | + | ||
70 | + sysbus_create_simple("virtio-mmio", base, irq); | ||
71 | + | ||
72 | + DPRINTF("Created virtio-mmio device %d: irq %d base 0x%lx\n", | ||
73 | + i, GUEST_VIRTIO_MMIO_SPI_FIRST + i, base); | ||
74 | + } | ||
75 | +} | ||
76 | + | ||
77 | void arch_handle_ioreq(XenIOState *state, ioreq_t *req) | ||
78 | { | ||
79 | hw_error("Invalid ioreq type 0x%x\n", req->type); | ||
80 | @@ -110,6 +143,8 @@ static void xen_arm_init(MachineState *machine) | ||
81 | |||
82 | xen_register_ioreq(xam->state, machine->smp.cpus, &xen_memory_listener); | ||
83 | |||
84 | + xen_create_virtio_mmio_devices(xam); | ||
85 | + | ||
86 | #ifdef CONFIG_TPM | ||
87 | if (xam->cfg.tpm_base_addr) { | ||
88 | xen_enable_tpm(xam); | ||
89 | diff --git a/include/hw/xen/xen_native.h b/include/hw/xen/xen_native.h | ||
90 | index 4dce905fde..a4b1aa9e5d 100644 | ||
91 | --- a/include/hw/xen/xen_native.h | ||
92 | +++ b/include/hw/xen/xen_native.h | ||
93 | @@ -523,4 +523,20 @@ static inline int xen_set_ioreq_server_state(domid_t dom, | ||
94 | enable); | ||
95 | } | ||
96 | |||
97 | +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <= 41500 | ||
98 | +static inline int xendevicemodel_set_irq_level(xendevicemodel_handle *dmod, | ||
99 | + domid_t domid, uint32_t irq, | ||
100 | + unsigned int level) | ||
101 | +{ | ||
102 | + return 0; | ||
103 | +} | ||
104 | +#endif | ||
105 | + | ||
106 | +#if CONFIG_XEN_CTRL_INTERFACE_VERSION <= 41700 | ||
107 | +#define GUEST_VIRTIO_MMIO_BASE xen_mk_ullong(0x02000000) | ||
108 | +#define GUEST_VIRTIO_MMIO_SIZE xen_mk_ullong(0x00100000) | ||
109 | +#define GUEST_VIRTIO_MMIO_SPI_FIRST 33 | ||
110 | +#define GUEST_VIRTIO_MMIO_SPI_LAST 43 | ||
111 | +#endif | ||
112 | + | ||
113 | #endif /* QEMU_HW_XEN_NATIVE_H */ | ||
114 | -- | ||
115 | 2.39.2 | ||
116 | |||