]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/riscv: virt: Limit RAM size in a 32-bit system
authorBin Meng <bin.meng@windriver.com>
Sat, 20 Feb 2021 14:48:06 +0000 (22:48 +0800)
committerAlistair Francis <alistair.francis@wdc.com>
Thu, 4 Mar 2021 14:43:29 +0000 (09:43 -0500)
RV32 supports 34-bit physical address hence the maximum RAM size
should be limited. Limit the RAM size to 10 GiB, which leaves
some room for PCIe high mmio space.

For 32-bit host, this is not needed as machine->ram_size cannot
represent a RAM size that big. Use a #if size test to only do
the size limitation for the 64-bit host.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20210220144807.819-4-bmeng.cn@gmail.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
hw/riscv/virt.c

index 1d05bb3ef9cb2fa1cf7110868520e5a12c075f38..c4b8f455f8bf06accce8aa4b45e5bf8dd52a728a 100644 (file)
@@ -590,6 +590,16 @@ static void virt_machine_init(MachineState *machine)
         }
     }
 
+    if (riscv_is_32bit(&s->soc[0])) {
+#if HOST_LONG_BITS == 64
+        /* limit RAM size in a 32-bit system */
+        if (machine->ram_size > 10 * GiB) {
+            machine->ram_size = 10 * GiB;
+            error_report("Limiting RAM size to 10 GiB");
+        }
+#endif
+    }
+
     /* register system main memory (actual RAM) */
     memory_region_init_ram(main_mem, NULL, "riscv_virt_board.ram",
                            machine->ram_size, &error_fatal);