|
| 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 | + |
0 commit comments