From: Bin Meng <bmeng.cn@gmail.com>
To: Alistair Francis <Alistair.Francis@wdc.com>,
qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: Bin Meng <bin.meng@windriver.com>
Subject: [PATCH v3 3/4] hw/riscv: virt: Limit RAM size in a 32-bit system
Date: Sat, 20 Feb 2021 22:48:06 +0800 [thread overview]
Message-ID: <20210220144807.819-4-bmeng.cn@gmail.com> (raw)
In-Reply-To: <20210220144807.819-1-bmeng.cn@gmail.com>
From: Bin Meng <bin.meng@windriver.com>
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>
---
Changes in v3:
- Fix the typo (limit) in the commit message and codes
Changes in v2:
- Use a #if size test to only do the size limitation for the 64-bit host
hw/riscv/virt.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 1d05bb3ef9..c4b8f455f8 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -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);
--
2.25.1
next prev parent reply other threads:[~2021-02-20 14:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-20 14:48 [PATCH v3 0/4] hw/riscv: Clean-ups and map high mmio for PCIe of 'virt' machine Bin Meng
2021-02-20 14:48 ` [PATCH v3 1/4] hw/riscv: Drop 'struct MemmapEntry' Bin Meng
2021-02-20 14:48 ` [PATCH v3 2/4] hw/riscv: virt: Drop the 'link_up' parameter of gpex_pcie_init() Bin Meng
2021-02-20 14:48 ` Bin Meng [this message]
2021-03-03 19:05 ` [PATCH v3 3/4] hw/riscv: virt: Limit RAM size in a 32-bit system Alistair Francis
2021-02-20 14:48 ` [PATCH v3 4/4] hw/riscv: virt: Map high mmio for PCIe Bin Meng
2021-02-28 5:15 ` [PATCH v3 0/4] hw/riscv: Clean-ups and map high mmio for PCIe of 'virt' machine Bin Meng
2021-03-03 19:06 ` Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210220144807.819-4-bmeng.cn@gmail.com \
--to=bmeng.cn@gmail.com \
--cc=Alistair.Francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).