diff options
author | Mark Hatle <mark.hatle@amd.com> | 2024-03-22 15:53:37 -0600 |
---|---|---|
committer | Mark Hatle <mark.hatle@amd.com> | 2024-03-26 19:02:44 -0600 |
commit | d3bb371f8a8063f59dc9b3a654530063da967627 (patch) | |
tree | 395cfa9a3bb1b1030548be573c6fc9734288055a /meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch | |
parent | 13e2e08f028da93469d6a0ee18a153e9b5ae303d (diff) | |
parent | 8b38759ff39db98c29651a2d80eedb2fb1a105aa (diff) | |
download | meta-xilinx-d3bb371f8a8063f59dc9b3a654530063da967627.tar.gz |
Merge remote-tracking branch 'xilinx/rel-v2024.1' into master-next
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch')
-rw-r--r-- | meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch new file mode 100644 index 00000000..7c2b272d --- /dev/null +++ b/meta-xilinx-virtualization/recipes-devtools/qemu/qemu-xilinx-7.1/0015-xen_arm-Initialize-RAM-and-add-hi-low-memory-regions.patch | |||
@@ -0,0 +1,105 @@ | |||
1 | From a284a53c5374e19ac37b884f2dd50293e7c8070e Mon Sep 17 00:00:00 2001 | ||
2 | From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> | ||
3 | Date: Sat, 30 Jul 2022 17:18:06 +0300 | ||
4 | Subject: [PATCH 15/16] 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 | ||
12 | toolstack. | ||
13 | |||
14 | The toolstack should then pass real ram_size using "-m" arg. | ||
15 | If "-m" is not given, create a QEMU machine without IOREQ, TPM and VIRTIO to | ||
16 | keep it usable for /etc/init.d/xencommons. | ||
17 | |||
18 | Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> | ||
19 | Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com> | ||
20 | Reviewed-by: Stefano Stabellini <stefano.stabellini@amd.com> | ||
21 | --- | ||
22 | hw/arm/xen_arm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ | ||
23 | 1 file changed, 46 insertions(+) | ||
24 | |||
25 | diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c | ||
26 | index 2012ee7aff..fde919df29 100644 | ||
27 | --- a/hw/arm/xen_arm.c | ||
28 | +++ b/hw/arm/xen_arm.c | ||
29 | @@ -56,6 +56,8 @@ struct XenArmState { | ||
30 | XenIOState *state; | ||
31 | }; | ||
32 | |||
33 | +static MemoryRegion ram_lo, ram_hi; | ||
34 | + | ||
35 | #define VIRTIO_MMIO_DEV_SIZE 0x200 | ||
36 | |||
37 | #define NR_VIRTIO_MMIO_DEVICES \ | ||
38 | @@ -82,6 +84,39 @@ static void xen_create_virtio_mmio_devices(XenArmState *xam) | ||
39 | } | ||
40 | } | ||
41 | |||
42 | +static void xen_init_ram(MachineState *machine) | ||
43 | +{ | ||
44 | + MemoryRegion *sysmem = get_system_memory(); | ||
45 | + ram_addr_t block_len, ram_size[GUEST_RAM_BANKS]; | ||
46 | + | ||
47 | + if (machine->ram_size <= GUEST_RAM0_SIZE) { | ||
48 | + ram_size[0] = machine->ram_size; | ||
49 | + ram_size[1] = 0; | ||
50 | + block_len = GUEST_RAM0_BASE + ram_size[0]; | ||
51 | + } else { | ||
52 | + ram_size[0] = GUEST_RAM0_SIZE; | ||
53 | + ram_size[1] = machine->ram_size - GUEST_RAM0_SIZE; | ||
54 | + block_len = GUEST_RAM1_BASE + ram_size[1]; | ||
55 | + } | ||
56 | + | ||
57 | + memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len, | ||
58 | + &error_fatal); | ||
59 | + | ||
60 | + memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo", &ram_memory, | ||
61 | + GUEST_RAM0_BASE, ram_size[0]); | ||
62 | + memory_region_add_subregion(sysmem, GUEST_RAM0_BASE, &ram_lo); | ||
63 | + DPRINTF("Initialized region xen.ram.lo: base 0x%llx size 0x%lx\n", | ||
64 | + GUEST_RAM0_BASE, ram_size[0]); | ||
65 | + | ||
66 | + if (ram_size[1] > 0) { | ||
67 | + memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi", &ram_memory, | ||
68 | + GUEST_RAM1_BASE, ram_size[1]); | ||
69 | + memory_region_add_subregion(sysmem, GUEST_RAM1_BASE, &ram_hi); | ||
70 | + DPRINTF("Initialized region xen.ram.hi: base 0x%llx size 0x%lx\n", | ||
71 | + GUEST_RAM1_BASE, ram_size[1]); | ||
72 | + } | ||
73 | +} | ||
74 | + | ||
75 | void arch_handle_ioreq(XenIOState *state, ioreq_t *req) | ||
76 | { | ||
77 | hw_error("Invalid ioreq type 0x%x\n", req->type); | ||
78 | @@ -155,6 +190,14 @@ static void xen_arm_init(MachineState *machine) | ||
79 | |||
80 | xam->state = g_new0(XenIOState, 1); | ||
81 | |||
82 | + if (machine->ram_size == 0) { | ||
83 | + DPRINTF("ram_size not specified. QEMU machine will be started without" | ||
84 | + " TPM, IOREQ and Virtio-MMIO backends\n"); | ||
85 | + return; | ||
86 | + } | ||
87 | + | ||
88 | + xen_init_ram(machine); | ||
89 | + | ||
90 | if (xen_init_ioreq(xam->state, machine->smp.cpus)) { | ||
91 | return; | ||
92 | } | ||
93 | @@ -173,6 +216,9 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data) | ||
94 | mc->desc = "Xen Para-virtualized PC"; | ||
95 | mc->init = xen_arm_init; | ||
96 | mc->max_cpus = 1; | ||
97 | + /* Set explicitly here to make sure that real ram_size is passed */ | ||
98 | + mc->default_ram_size = 0; | ||
99 | + | ||
100 | machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); | ||
101 | } | ||
102 | |||
103 | -- | ||
104 | 2.17.1 | ||
105 | |||