Message ID | 20210122122958.12311-4-bmeng.cn@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | hw/riscv: Clean-ups and map high mmio for PCIe of 'virt' machine | expand |
On Fri, Jan 22, 2021 at 4:34 AM Bin Meng <bmeng.cn@gmail.com> wrote: > > 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> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > > 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 > >
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);