diff options
Diffstat (limited to 'meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0010-hw-arm-introduce-xenpv-machine.patch')
-rw-r--r-- | meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0010-hw-arm-introduce-xenpv-machine.patch | 230 |
1 files changed, 0 insertions, 230 deletions
diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0010-hw-arm-introduce-xenpv-machine.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0010-hw-arm-introduce-xenpv-machine.patch deleted file mode 100644 index fc979b52..00000000 --- a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0010-hw-arm-introduce-xenpv-machine.patch +++ /dev/null | |||
@@ -1,230 +0,0 @@ | |||
1 | From 5618a18b1f12d567a8ef85240d55b841e18ef472 Mon Sep 17 00:00:00 2001 | ||
2 | From: Vikram Garhwal <vikram.garhwal@amd.com> | ||
3 | Date: Fri, 1 Jul 2022 17:28:16 -0700 | ||
4 | Subject: [PATCH 10/16] hw/arm: introduce xenpv machine | ||
5 | |||
6 | Create a new machine xenpv which creates a IOREQ server to connect | ||
7 | with Xen. It also creates a tpm-tis-device which connects to swtpm to | ||
8 | support TPM functionalities. | ||
9 | |||
10 | Xen IOREQ connection expect the TARGET_PAGE_SIZE to 4096, and the xenpv | ||
11 | machine on ARM will have no CPU definitions. We need to define | ||
12 | TARGET_PAGE_SIZE appropriately ourselves. | ||
13 | |||
14 | Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com> | ||
15 | Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> | ||
16 | Reviewed-by: Stefano Stabellini <stefano.stabellini@xilinx.com> | ||
17 | --- | ||
18 | hw/arm/meson.build | 1 + | ||
19 | hw/arm/xen_arm.c | 156 ++++++++++++++++++++++++++++++++++ | ||
20 | include/hw/arm/xen_arch_hvm.h | 12 +++ | ||
21 | include/hw/xen/arch_hvm.h | 2 + | ||
22 | 4 files changed, 171 insertions(+) | ||
23 | create mode 100644 hw/arm/xen_arm.c | ||
24 | create mode 100644 include/hw/arm/xen_arch_hvm.h | ||
25 | |||
26 | diff --git a/hw/arm/meson.build b/hw/arm/meson.build | ||
27 | index 3aac913bfd..0cae024374 100644 | ||
28 | --- a/hw/arm/meson.build | ||
29 | +++ b/hw/arm/meson.build | ||
30 | @@ -62,6 +62,7 @@ arm_ss.add(when: 'CONFIG_FSL_IMX7', if_true: files('fsl-imx7.c', 'mcimx7d-sabre. | ||
31 | arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c', 'smmuv3.c')) | ||
32 | arm_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c')) | ||
33 | arm_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c')) | ||
34 | +arm_ss.add(when: 'CONFIG_XEN', if_true: files('xen_arm.c')) | ||
35 | arm_ss.add_all(xen_ss) | ||
36 | |||
37 | hw_arch += {'arm': arm_ss} | ||
38 | diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c | ||
39 | new file mode 100644 | ||
40 | index 0000000000..0922e3db84 | ||
41 | --- /dev/null | ||
42 | +++ b/hw/arm/xen_arm.c | ||
43 | @@ -0,0 +1,156 @@ | ||
44 | +/* | ||
45 | + * QEMU ARM Xen PV Machine | ||
46 | + * | ||
47 | + * | ||
48 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
49 | + * of this software and associated documentation files (the "Software"), to deal | ||
50 | + * in the Software without restriction, including without limitation the rights | ||
51 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
52 | + * copies of the Software, and to permit persons to whom the Software is | ||
53 | + * furnished to do so, subject to the following conditions: | ||
54 | + * | ||
55 | + * The above copyright notice and this permission notice shall be included in | ||
56 | + * all copies or substantial portions of the Software. | ||
57 | + * | ||
58 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
59 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
60 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
61 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
62 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
63 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
64 | + * THE SOFTWARE. | ||
65 | + */ | ||
66 | + | ||
67 | +#include "qemu/osdep.h" | ||
68 | +#include "qemu/error-report.h" | ||
69 | +#include "qapi/qapi-commands-migration.h" | ||
70 | +#include "hw/boards.h" | ||
71 | +#include "hw/sysbus.h" | ||
72 | +#include "sysemu/block-backend.h" | ||
73 | +#include "sysemu/tpm_backend.h" | ||
74 | +#include "sysemu/sysemu.h" | ||
75 | +#include "hw/xen/xen-legacy-backend.h" | ||
76 | +#include "hw/xen/xen-hvm-common.h" | ||
77 | +#include "sysemu/tpm.h" | ||
78 | +#include "hw/xen/arch_hvm.h" | ||
79 | + | ||
80 | +#define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpv") | ||
81 | +OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM) | ||
82 | + | ||
83 | +static MemoryListener xen_memory_listener = { | ||
84 | + .region_add = xen_region_add, | ||
85 | + .region_del = xen_region_del, | ||
86 | + .log_start = NULL, | ||
87 | + .log_stop = NULL, | ||
88 | + .log_sync = NULL, | ||
89 | + .log_global_start = NULL, | ||
90 | + .log_global_stop = NULL, | ||
91 | + .priority = 10, | ||
92 | +}; | ||
93 | + | ||
94 | +struct XenArmState { | ||
95 | + /*< private >*/ | ||
96 | + MachineState parent; | ||
97 | + | ||
98 | + XenIOState *state; | ||
99 | +}; | ||
100 | + | ||
101 | +void arch_handle_ioreq(XenIOState *state, ioreq_t *req) | ||
102 | +{ | ||
103 | + hw_error("Invalid ioreq type 0x%x\n", req->type); | ||
104 | + | ||
105 | + return; | ||
106 | +} | ||
107 | + | ||
108 | +void arch_xen_set_memory(XenIOState *state,MemoryRegionSection *section, | ||
109 | + bool add) | ||
110 | +{ | ||
111 | +} | ||
112 | + | ||
113 | +void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length) | ||
114 | +{ | ||
115 | +} | ||
116 | + | ||
117 | +void qmp_xen_set_global_dirty_log(bool enable, Error **errp) | ||
118 | +{ | ||
119 | +} | ||
120 | + | ||
121 | +static int xen_init_ioreq(XenIOState *state, unsigned int max_cpus) | ||
122 | +{ | ||
123 | + xen_dmod = xendevicemodel_open(0, 0); | ||
124 | + xen_xc = xc_interface_open(0, 0, 0); | ||
125 | + | ||
126 | + if (xen_xc == NULL) { | ||
127 | + perror("xen: can't open xen interface\n"); | ||
128 | + return -1; | ||
129 | + } | ||
130 | + | ||
131 | + xen_fmem = xenforeignmemory_open(0, 0); | ||
132 | + if (xen_fmem == NULL) { | ||
133 | + perror("xen: can't open xen fmem interface\n"); | ||
134 | + xc_interface_close(xen_xc); | ||
135 | + return -1; | ||
136 | + } | ||
137 | + | ||
138 | + xen_register_ioreq(state, max_cpus, xen_memory_listener); | ||
139 | + | ||
140 | + xenstore_record_dm_state(xenstore, "running"); | ||
141 | + | ||
142 | + return 0; | ||
143 | +} | ||
144 | + | ||
145 | + | ||
146 | +static void xen_arm_init(MachineState *machine) | ||
147 | +{ | ||
148 | + DeviceState *dev; | ||
149 | + SysBusDevice *busdev; | ||
150 | + Error *errp = NULL; | ||
151 | + XenArmState *xam = XEN_ARM(machine); | ||
152 | + | ||
153 | + xam->state = g_new0(XenIOState, 1); | ||
154 | + | ||
155 | + if (xen_init_ioreq(xam->state, machine->smp.cpus)) { | ||
156 | + return; | ||
157 | + } | ||
158 | + | ||
159 | + TPMBackend *be = qemu_find_tpm_be("tpm0"); | ||
160 | + if (be == NULL) { | ||
161 | + DPRINTF("Couldn't fine the backend for tpm0\n"); | ||
162 | + return; | ||
163 | + } | ||
164 | + | ||
165 | + dev = qdev_new(TYPE_TPM_TIS_SYSBUS); | ||
166 | + object_property_set_link(OBJECT(dev), "tpmdev", OBJECT(be), &errp); | ||
167 | + object_property_set_str(OBJECT(dev), "tpmdev", be->id, &errp); | ||
168 | + busdev = SYS_BUS_DEVICE(dev); | ||
169 | + sysbus_realize_and_unref(busdev, &error_fatal); | ||
170 | + sysbus_mmio_map(busdev, 0, GUEST_TPM_BASE); | ||
171 | + | ||
172 | + DPRINTF("Connected tpmdev at address 0x%lx\n", GUEST_TPM_BASE); | ||
173 | + | ||
174 | + return; | ||
175 | +} | ||
176 | + | ||
177 | +static void xen_arm_machine_class_init(ObjectClass *oc, void *data) | ||
178 | +{ | ||
179 | + | ||
180 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
181 | + mc->desc = "Xen Para-virtualized PC"; | ||
182 | + mc->init = xen_arm_init; | ||
183 | + mc->max_cpus = 1; | ||
184 | + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); | ||
185 | +} | ||
186 | + | ||
187 | +static const TypeInfo xen_arm_machine_type = { | ||
188 | + .name = TYPE_XEN_ARM, | ||
189 | + .parent = TYPE_MACHINE, | ||
190 | + .class_init = xen_arm_machine_class_init, | ||
191 | + .instance_size = sizeof(XenArmState), | ||
192 | +}; | ||
193 | + | ||
194 | +static void xen_arm_machine_register_types(void) | ||
195 | +{ | ||
196 | + type_register_static(&xen_arm_machine_type); | ||
197 | +} | ||
198 | + | ||
199 | +type_init(xen_arm_machine_register_types) | ||
200 | diff --git a/include/hw/arm/xen_arch_hvm.h b/include/hw/arm/xen_arch_hvm.h | ||
201 | new file mode 100644 | ||
202 | index 0000000000..f645dfec28 | ||
203 | --- /dev/null | ||
204 | +++ b/include/hw/arm/xen_arch_hvm.h | ||
205 | @@ -0,0 +1,12 @@ | ||
206 | +#ifndef HW_XEN_ARCH_ARM_HVM_H | ||
207 | +#define HW_XEN_ARCH_ARM_HVM_H | ||
208 | + | ||
209 | +#include <xen/hvm/ioreq.h> | ||
210 | +void arch_handle_ioreq(XenIOState *state, ioreq_t *req); | ||
211 | +void arch_xen_set_memory(XenIOState *state, | ||
212 | + MemoryRegionSection *section, | ||
213 | + bool add); | ||
214 | + | ||
215 | +#undef TARGET_PAGE_SIZE | ||
216 | +#define TARGET_PAGE_SIZE 4096 | ||
217 | +#endif | ||
218 | diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h | ||
219 | index 26674648d8..c7c515220d 100644 | ||
220 | --- a/include/hw/xen/arch_hvm.h | ||
221 | +++ b/include/hw/xen/arch_hvm.h | ||
222 | @@ -1,3 +1,5 @@ | ||
223 | #if defined(TARGET_I386) || defined(TARGET_X86_64) | ||
224 | #include "hw/i386/xen_arch_hvm.h" | ||
225 | +#elif defined(TARGET_ARM) || defined(TARGET_ARM_64) | ||
226 | +#include "hw/arm/xen_arch_hvm.h" | ||
227 | #endif | ||
228 | -- | ||
229 | 2.17.1 | ||
230 | |||