All of lore.kernel.org
 help / color / mirror / Atom feed
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 3/4] hw/riscv: virt: Limit RAM size in a 32-bit system
Date: Fri, 22 Jan 2021 20:29:57 +0800	[thread overview]
Message-ID: <20210122122958.12311-4-bmeng.cn@gmail.com> (raw)
In-Reply-To: <20210122122958.12311-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 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



  parent reply	other threads:[~2021-01-22 12:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 12:29 [PATCH 0/4] hw/riscv: Clean-ups and map high mmio for PCIe of 'virt' machine Bin Meng
2021-01-22 12:29 ` [PATCH 1/4] hw/riscv: Drop 'struct MemmapEntry' Bin Meng
2021-01-22 21:22   ` Alistair Francis
2021-01-22 21:22     ` Alistair Francis
2021-01-25 17:41   ` Philippe Mathieu-Daudé
2021-01-22 12:29 ` [PATCH 2/4] hw/riscv: virt: Drop the 'link_up' parameter of gpex_pcie_init() Bin Meng
2021-01-22 21:22   ` Alistair Francis
2021-01-22 21:22     ` Alistair Francis
2021-01-22 12:29 ` Bin Meng [this message]
2021-01-22 21:26   ` [PATCH 3/4] hw/riscv: virt: Limit RAM size in a 32-bit system Alistair Francis
2021-01-22 21:26     ` Alistair Francis
2021-01-22 12:29 ` [PATCH 4/4] hw/riscv: virt: Map high mmio for PCIe Bin Meng
2021-02-12 21:47   ` Alistair Francis
2021-02-12 21:47     ` Alistair Francis
2021-02-12 22:05 ` [PATCH 0/4] hw/riscv: Clean-ups and map high mmio for PCIe of 'virt' machine Alistair Francis
2021-02-12 22:05   ` 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=20210122122958.12311-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.