From: Kuan-Jui Chiu <kchiu@axiado.com>
Cc: Kuan-Jui Chiu <kchiu@axiado.com>,
mark.caveayland@nutanix.com, philmd@oss.qualcomm.com,
163wangjack@gmail.com, peter.maydell@linaro.org,
qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: [PATCH v8 07/13] hw/arm/ax3000-boards: Add modify_dtb for discontiguous memory
Date: Wed, 18 Nov 2026 23:13:47 -0800 [thread overview]
Message-ID: <20261119071355.3520249-8-kchiu@axiado.com> (raw)
In-Reply-To: <20261119071355.3520249-1-kchiu@axiado.com>
Ax3000 SoC has two memory banks:
1. 0x3C000000 with 1088 MiB
2. 0x400000000 wit 2 GiB
When user boot kernel directly on axiado-scm3003 models, kernel would
believe these memory are contiguous which cause the crash
This patch add modify_dtb callback to revise the memory block
Signed-off-by: Kuan-Jui Chiu <kchiu@axiado.com>
---
hw/arm/ax3000-boards.c | 48 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/hw/arm/ax3000-boards.c b/hw/arm/ax3000-boards.c
index bc1f818d74..75e0aedb4d 100644
--- a/hw/arm/ax3000-boards.c
+++ b/hw/arm/ax3000-boards.c
@@ -12,10 +12,58 @@
#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include "qom/object.h"
+#include "system/device_tree.h"
+
+/*
+ * arm_load_dtb() drops every /memory node found in the DTB and replaces them
+ * with a single node spanning [loader_start, loader_start + ram_size). The
+ * AX3000 DRAM is split into two banks with the MMIO region in between, so the
+ * generated node would describe unbacked addresses as RAM. Describe the banks
+ * ourselves instead.
+ */
+static void ax3000_modify_dtb(const struct arm_boot_info *info, void *fdt)
+{
+ g_autofree char *nodename = NULL;
+ uint64_t reg[AX3000_NUM_BANKS * 2];
+ char **node_path;
+ Error *err = NULL;
+ int i;
+
+ node_path = qemu_fdt_node_unit_path(fdt, "memory", &err);
+ if (err) {
+ error_report_err(err);
+ exit(1);
+ }
+ for (i = 0; node_path[i]; i++) {
+ if (g_str_has_prefix(node_path[i], "/memory")) {
+ qemu_fdt_nop_node(fdt, node_path[i]);
+ }
+ }
+ g_strfreev(node_path);
+
+ const struct {
+ hwaddr addr;
+ size_t size;
+ } dram_table[] = {
+ { AX3000_DRAM0_BASE, AX3000_DRAM0_SIZE},
+ { AX3000_DRAM1_BASE, AX3000_DRAM1_SIZE}
+ };
+
+ for (i = 0; i < AX3000_NUM_BANKS; i++) {
+ reg[i * 2] = cpu_to_be64(dram_table[i].addr);
+ reg[i * 2 + 1] = cpu_to_be64(dram_table[i].size);
+ }
+
+ nodename = g_strdup_printf("/memory@%" HWADDR_PRIx, dram_table[0].addr);
+ qemu_fdt_add_subnode(fdt, nodename);
+ qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory");
+ qemu_fdt_setprop(fdt, nodename, "reg", reg, sizeof(reg));
+}
static struct arm_boot_info ax3000_binfo = {
.loader_start = AX3000_DRAM0_BASE,
.board_id = -1,
+ .modify_dtb = ax3000_modify_dtb,
};
static void ax3000_machine_init(MachineState *machine)
--
2.34.1
next prev parent reply other threads:[~2026-11-19 7:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 7:13 [PATCH v8 00/13] Add Axiado SoC AX3005 and EVB Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 01/13] hw/char/cadence_uart: Reduce the size of MMIO to 0x80 Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 02/13] hw/char/cadence_uart: Add BXRS register definition Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 03/13] hw/arm/ax3000-soc: Enable BXRS support of CADENCE UART Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 04/13] hw/arm: Rename ax3000-boards as axiado-boards Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 05/13] hw/arm/ax3000: Specify SoC name in header and variable Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 06/13] hw/arm/ax3000-boards: Add memory guard Kuan-Jui Chiu
2026-11-19 7:13 ` Kuan-Jui Chiu [this message]
2026-11-19 7:13 ` [PATCH v8 08/13] hw/arm/ax3000-boards: Remove redundant pointer from struct Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 09/13] hw/arm/ax3000-soc: Revise variables accodring to QEMU idioms Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 10/13] hw/arm: Add Axiado SoC AX3005 Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 11/13] hw/arm: Add Axiado Ax3005 EVB Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 12/13] docs/system/arm: Document Axiado boards Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 13/13] tests/functional/aarch64: Add functional test for Axiado EVKs Kuan-Jui Chiu
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=20261119071355.3520249-8-kchiu@axiado.com \
--to=kchiu@axiado.com \
--cc=163wangjack@gmail.com \
--cc=mark.caveayland@nutanix.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@oss.qualcomm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@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.