From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: David Dgien <dgienda125@gmail.com>, Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 01/12] boards: qemu-virt: reserve BIOS device tree
Date: Thu, 15 Jan 2026 12:54:27 +0100 [thread overview]
Message-ID: <20260115115924.3428886-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260115115924.3428886-1-a.fatoum@barebox.org>
On the ARM Virt platform, QEMU places its device tree at the start of
RAM and doesn't provide a standard FW_CFG to access it.
To be able to keep reusing it when chainloading barebox in future and
passing it to the kernel, reserve this piece of memory.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/boards/qemu-virt/board.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/common/boards/qemu-virt/board.c b/common/boards/qemu-virt/board.c
index 0c9cc1a75d3b..53945aefb7aa 100644
--- a/common/boards/qemu-virt/board.c
+++ b/common/boards/qemu-virt/board.c
@@ -6,6 +6,8 @@
#include <common.h>
#include <init.h>
#include <of.h>
+#include <memory.h>
+#include <compressed-dtb.h>
#include <deep-probe.h>
#include <security/policy.h>
#include "qemu-virt-flash.h"
@@ -47,6 +49,8 @@ static const struct of_device_id virt_of_match[] = {
};
BAREBOX_DEEP_PROBE_ENABLE(virt_of_match);
+static bool is_qemu_virt;
+
/*
* We don't have a dedicated qemu-virt device tree and instead rely
* on what Qemu passes us. To be able to get fundamental changes
@@ -64,6 +68,8 @@ static int virt_board_driver_init(void)
if (!id)
return 0;
+ is_qemu_virt = true;
+
if (id->data) {
init = id->data;
init();
@@ -94,3 +100,29 @@ static int virt_board_driver_init(void)
return 0;
}
postcore_initcall(virt_board_driver_init);
+
+static __maybe_unused int virt_board_reserve_fdt(void)
+{
+ resource_size_t start = ~0, end = ~0;
+
+ if (!is_qemu_virt)
+ return 0;
+
+ memory_bank_first_find_space(&start, &end);
+ if (start != ~0) {
+ void *fdt = (void *)start;
+
+ if (!blob_is_fdt(fdt))
+ return 0;
+
+ request_sdram_region("qemu-virt-fdt", start,
+ fdt_totalsize(fdt),
+ MEMTYPE_BOOT_SERVICES_DATA,
+ MEMATTRS_RO);
+ }
+
+ return 0;
+}
+#ifdef CONFIG_ARM
+postmem_initcall(virt_board_reserve_fdt);
+#endif
--
2.47.3
next prev parent reply other threads:[~2026-01-15 12:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 11:54 [PATCH 00/12] ARM32: modules: fix bitrot and add test Ahmad Fatoum
2026-01-15 11:54 ` Ahmad Fatoum [this message]
2026-01-15 11:54 ` [PATCH 02/12] ARM: qemu-virt: add image for use as -bios Ahmad Fatoum
2026-01-16 8:33 ` Sascha Hauer
2026-01-16 10:21 ` Ahmad Fatoum
2026-01-16 12:52 ` Ahmad Fatoum
2026-01-16 15:16 ` Sascha Hauer
2026-01-15 11:54 ` [PATCH 03/12] kbuild: build *.mod.c with -std=gnu11 Ahmad Fatoum
2026-01-15 11:54 ` [PATCH 04/12] ARM32: mark modules as incompatible with ARM_MMU_PERMISSIONS Ahmad Fatoum
2026-01-15 11:54 ` [PATCH 05/12] treewide: fix some missing EXPORT_SYMBOL Ahmad Fatoum
2026-01-15 11:54 ` [PATCH 06/12] pci: ecam: enable build as module Ahmad Fatoum
2026-01-15 11:54 ` [PATCH 07/12] kbuild: add support for installing and stripping modules Ahmad Fatoum
2026-01-15 11:54 ` [PATCH 08/12] ARM32: module: handle more relocations Ahmad Fatoum
2026-01-15 11:54 ` [PATCH 09/12] commands: pm_domain: make command tristate Ahmad Fatoum
2026-01-15 11:54 ` [PATCH 10/12] test: conftest: add support for describing FW_CFG environment in YAML Ahmad Fatoum
2026-01-15 11:54 ` [PATCH 11/12] defaultenv: add barebox_modules_env target Ahmad Fatoum
2026-01-15 11:54 ` [PATCH 12/12] test: arm: add simple driver/command module test Ahmad Fatoum
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=20260115115924.3428886-2-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
--cc=dgienda125@gmail.com \
/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