qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] hw/riscv: virt: Limit RAM size in a 32-bit system


From: Bin Meng
Subject: [PATCH 3/4] hw/riscv: virt: Limit RAM size in a 32-bit system
Date: Fri, 22 Jan 2021 20:29:57 +0800

From: Bin Meng <bin.meng@windriver.com>

RV32 supports 34-bit physical address hence the maximum RAM size
should be limitted. Limit the RAM size to 10 GiB, which leaves
some room for PCIe high mmio space.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
---

 hw/riscv/virt.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 1d05bb3ef9..4f44509360 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -590,6 +590,19 @@ static void virt_machine_init(MachineState *machine)
         }
     }
 
+    /* limit RAM size in a 32-bit system */
+    if (riscv_is_32bit(&s->soc[0])) {
+        /*
+         * Cast machine->ram_size to 64-bit for 32-bit host,
+         * to make the build on 32-bit host happy.
+         */
+        if ((uint64_t)(machine->ram_size) > 10 * GiB) {
+            /* 32-bit host won't have a chance to execute here */
+            machine->ram_size = 10 * GiB;
+            error_report("Limitting RAM size to 10 GiB");
+        }
+    }
+
     /* register system main memory (actual RAM) */
     memory_region_init_ram(main_mem, NULL, "riscv_virt_board.ram",
                            machine->ram_size, &error_fatal);
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]