diff options
Diffstat (limited to 'meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0002-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch')
-rw-r--r-- | meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0002-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0002-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0002-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch new file mode 100644 index 00000000..f88db620 --- /dev/null +++ b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-8.1/0002-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch | |||
@@ -0,0 +1,124 @@ | |||
1 | From 70a74795c5071bf591e6e557b7c8c492ead0e675 Mon Sep 17 00:00:00 2001 | ||
2 | From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> | ||
3 | Date: Tue, 29 Aug 2023 21:35:18 -0700 | ||
4 | Subject: [PATCH 02/11] xen_arm: Initialize RAM and add hi/low memory regions | ||
5 | |||
6 | In order to use virtio backends we need to initialize RAM for the | ||
7 | xen-mapcache (which is responsible for mapping guest memory using foreign | ||
8 | mapping) to work. Calculate and add hi/low memory regions based on | ||
9 | machine->ram_size. | ||
10 | |||
11 | Use the constants defined in public header arch-arm.h to be aligned with the xen | ||
12 | toolstack. | ||
13 | |||
14 | While using this machine, the toolstack should then pass real ram_size using | ||
15 | "-m" arg. If "-m" is not given, create a QEMU machine without IOREQ and other | ||
16 | emulated devices like TPM and VIRTIO. This is done to keep this QEMU machine | ||
17 | usable for /etc/init.d/xencommons. | ||
18 | |||
19 | Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> | ||
20 | Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com> | ||
21 | Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> | ||
22 | Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com> | ||
23 | --- | ||
24 | hw/arm/xen_arm.c | 45 +++++++++++++++++++++++++++++++++++++ | ||
25 | include/hw/xen/xen_native.h | 8 +++++++ | ||
26 | 2 files changed, 53 insertions(+) | ||
27 | |||
28 | diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c | ||
29 | index 7393b37355..f83b983ec5 100644 | ||
30 | --- a/hw/arm/xen_arm.c | ||
31 | +++ b/hw/arm/xen_arm.c | ||
32 | @@ -60,6 +60,8 @@ struct XenArmState { | ||
33 | } cfg; | ||
34 | }; | ||
35 | |||
36 | +static MemoryRegion ram_lo, ram_hi; | ||
37 | + | ||
38 | /* | ||
39 | * VIRTIO_MMIO_DEV_SIZE is imported from tools/libs/light/libxl_arm.c under Xen | ||
40 | * repository. | ||
41 | @@ -92,6 +94,39 @@ static void xen_create_virtio_mmio_devices(XenArmState *xam) | ||
42 | } | ||
43 | } | ||
44 | |||
45 | +static void xen_init_ram(MachineState *machine) | ||
46 | +{ | ||
47 | + MemoryRegion *sysmem = get_system_memory(); | ||
48 | + ram_addr_t block_len, ram_size[GUEST_RAM_BANKS]; | ||
49 | + | ||
50 | + if (machine->ram_size <= GUEST_RAM0_SIZE) { | ||
51 | + ram_size[0] = machine->ram_size; | ||
52 | + ram_size[1] = 0; | ||
53 | + block_len = GUEST_RAM0_BASE + ram_size[0]; | ||
54 | + } else { | ||
55 | + ram_size[0] = GUEST_RAM0_SIZE; | ||
56 | + ram_size[1] = machine->ram_size - GUEST_RAM0_SIZE; | ||
57 | + block_len = GUEST_RAM1_BASE + ram_size[1]; | ||
58 | + } | ||
59 | + | ||
60 | + memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len, | ||
61 | + &error_fatal); | ||
62 | + | ||
63 | + memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo", &ram_memory, | ||
64 | + GUEST_RAM0_BASE, ram_size[0]); | ||
65 | + memory_region_add_subregion(sysmem, GUEST_RAM0_BASE, &ram_lo); | ||
66 | + DPRINTF("Initialized region xen.ram.lo: base 0x%llx size 0x%lx\n", | ||
67 | + GUEST_RAM0_BASE, ram_size[0]); | ||
68 | + | ||
69 | + if (ram_size[1] > 0) { | ||
70 | + memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi", &ram_memory, | ||
71 | + GUEST_RAM1_BASE, ram_size[1]); | ||
72 | + memory_region_add_subregion(sysmem, GUEST_RAM1_BASE, &ram_hi); | ||
73 | + DPRINTF("Initialized region xen.ram.hi: base 0x%llx size 0x%lx\n", | ||
74 | + GUEST_RAM1_BASE, ram_size[1]); | ||
75 | + } | ||
76 | +} | ||
77 | + | ||
78 | void arch_handle_ioreq(XenIOState *state, ioreq_t *req) | ||
79 | { | ||
80 | hw_error("Invalid ioreq type 0x%x\n", req->type); | ||
81 | @@ -141,6 +176,14 @@ static void xen_arm_init(MachineState *machine) | ||
82 | |||
83 | xam->state = g_new0(XenIOState, 1); | ||
84 | |||
85 | + if (machine->ram_size == 0) { | ||
86 | + DPRINTF("ram_size not specified. QEMU machine started without IOREQ" | ||
87 | + "(no emulated devices including Virtio)\n"); | ||
88 | + return; | ||
89 | + } | ||
90 | + | ||
91 | + xen_init_ram(machine); | ||
92 | + | ||
93 | xen_register_ioreq(xam->state, machine->smp.cpus, &xen_memory_listener); | ||
94 | |||
95 | xen_create_virtio_mmio_devices(xam); | ||
96 | @@ -188,6 +231,8 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data) | ||
97 | mc->init = xen_arm_init; | ||
98 | mc->max_cpus = 1; | ||
99 | mc->default_machine_opts = "accel=xen"; | ||
100 | + /* Set explicitly here to make sure that real ram_size is passed */ | ||
101 | + mc->default_ram_size = 0; | ||
102 | |||
103 | #ifdef CONFIG_TPM | ||
104 | object_class_property_add(oc, "tpm-base-addr", "uint64_t", | ||
105 | diff --git a/include/hw/xen/xen_native.h b/include/hw/xen/xen_native.h | ||
106 | index a4b1aa9e5d..5d2718261f 100644 | ||
107 | --- a/include/hw/xen/xen_native.h | ||
108 | +++ b/include/hw/xen/xen_native.h | ||
109 | @@ -539,4 +539,12 @@ static inline int xendevicemodel_set_irq_level(xendevicemodel_handle *dmod, | ||
110 | #define GUEST_VIRTIO_MMIO_SPI_LAST 43 | ||
111 | #endif | ||
112 | |||
113 | +#if defined(__i386__) || defined(__x86_64__) | ||
114 | +#define GUEST_RAM_BANKS 2 | ||
115 | +#define GUEST_RAM0_BASE 0x40000000ULL /* 3GB of low RAM @ 1GB */ | ||
116 | +#define GUEST_RAM0_SIZE 0xc0000000ULL | ||
117 | +#define GUEST_RAM1_BASE 0x0200000000ULL /* 1016GB of RAM @ 8GB */ | ||
118 | +#define GUEST_RAM1_SIZE 0xfe00000000ULL | ||
119 | +#endif | ||
120 | + | ||
121 | #endif /* QEMU_HW_XEN_NATIVE_H */ | ||
122 | -- | ||
123 | 2.39.2 | ||
124 | |||