Skip to content

Commit f553951

Browse files
abrodkingalak
authored andcommitted
qemu: Allow setup of ARC's "virt" board memory size
We used to be very generous with memory allocation for ARC's "virt" board assuming people would run Linux on it and all 2 GiB of RAM will be consumed anyway. But in case of Zephyr we don't need that much, yet QEMU tries to allocate 2 GiB right away meaninglessly claiming hosts's memory. And while it's typically not a big deal if 1 QEMU instance is run on an up-to-date host (we have 10s of GiBs to our disposal), in case of massive parallel QEMU execution like in Zephyr's "twister", it really starts to get in a way. So we now allow user to specify amount of memory we'd like to have on emulated target and thus significantly lower memory pressure and requirements on "twister"-running hosts. See #291. Signed-off-by: Alexey Brodkin <[email protected]>
1 parent c47457e commit f553951

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
From a76ddb02f29a696dd70a251055aacf9956cd8149 Mon Sep 17 00:00:00 2001
2+
From: Alexey Brodkin <[email protected]>
3+
Date: Mon, 9 Aug 2021 06:55:54 -0700
4+
Subject: [PATCH] arc: virt: Make target memory size configurable
5+
6+
We used to allocate entire usable 2GiB of memory for ARC's "virt" board
7+
assuming the Linux kernel with its user-space will anyway utilize all that.
8+
9+
But since then "virt" board was accommodated by Zephyr project where much
10+
smaller apps are being executed and that huge overhead in memory
11+
footprint started to get in the way.
12+
13+
See https://github.com/zephyrproject-rtos/sdk-ng/issues/291 for example.
14+
15+
With this change one may say "-m 8M" and get only 8 MiB DDR instantiated
16+
for the simulated board.
17+
18+
Still we keep the same default of 2 GiB in case no "-m" option is given.
19+
20+
Signed-off-by: Alexey Brodkin <[email protected]>
21+
---
22+
hw/arc/virt.c | 7 ++++---
23+
1 file changed, 4 insertions(+), 3 deletions(-)
24+
25+
diff --git a/hw/arc/virt.c b/hw/arc/virt.c
26+
index 5ba05b6452..e2132671f7 100644
27+
--- a/hw/arc/virt.c
28+
+++ b/hw/arc/virt.c
29+
@@ -14,6 +14,7 @@
30+
*/
31+
32+
#include "qemu/osdep.h"
33+
+#include "qemu/units.h"
34+
#include "qapi/error.h"
35+
#include "boot.h"
36+
#include "hw/boards.h"
37+
@@ -26,7 +27,6 @@
38+
#include "hw/sysbus.h"
39+
40+
#define VIRT_RAM_BASE 0x80000000
41+
-#define VIRT_RAM_SIZE 0x80000000
42+
#define VIRT_IO_BASE 0xf0000000
43+
#define VIRT_IO_SIZE 0x10000000
44+
#define VIRT_UART0_OFFSET 0x0
45+
@@ -115,7 +115,7 @@ static void virt_init(MachineState *machine)
46+
int n;
47+
48+
boot_info.ram_start = VIRT_RAM_BASE;
49+
- boot_info.ram_size = VIRT_RAM_SIZE;
50+
+ boot_info.ram_size = machine->ram_size;
51+
boot_info.kernel_filename = machine->kernel_filename;
52+
boot_info.kernel_cmdline = machine->kernel_cmdline;
53+
54+
@@ -139,7 +139,7 @@ static void virt_init(MachineState *machine)
55+
56+
/* Init system DDR */
57+
system_ram = g_new(MemoryRegion, 1);
58+
- memory_region_init_ram(system_ram, NULL, "arc.ram", VIRT_RAM_SIZE,
59+
+ memory_region_init_ram(system_ram, NULL, "arc.ram", machine->ram_size,
60+
&error_fatal);
61+
memory_region_add_subregion(system_memory, VIRT_RAM_BASE, system_ram);
62+
63+
@@ -175,6 +175,7 @@ static void virt_machine_init(MachineClass *mc)
64+
mc->init = virt_init;
65+
mc->max_cpus = 1;
66+
mc->is_default = true;
67+
+ mc->default_ram_size = 2 * GiB;
68+
}
69+
70+
DEFINE_MACHINE("virt", virt_machine_init)
71+
--
72+
2.16.2
73+

meta-zephyr-sdk/recipes-devtools/qemu/zephyr-qemu_git.bb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SRC_URI = "git://github.com/qemu/qemu.git;protocol=https \
2727
file://0015-hw-arm-mps2-tz-Allow-board-to-specify-a-boot-RAM-siz.patch \
2828
file://0016-hw-arm-Model-TCMs-in-the-SSE-300-not-the-AN547.patch \
2929
file://0017-target-arm-Use-correct-SP-in-M-profile-exception-ret.patch \
30+
file://0018-arc-virt-Make-target-memory-size-configurable.patch \
3031
"
3132

3233
SRC_URI[bios-128k.sha256sum] = "943c077c3925ee7ec85601fb12937a0988c478a95523a628cd7e61c639dd6e81"

0 commit comments

Comments
 (0)