From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: "Leonard Göhrs" <l.goehrs@pengutronix.de>,
"Ahmad Fatoum" <a.fatoum@barebox.org>
Subject: [PATCH 2/2] efi: loader: remove dependency on LIBFDT
Date: Tue, 20 Jan 2026 11:49:53 +0100 [thread overview]
Message-ID: <20260120104957.41978-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260120104957.41978-1-a.fatoum@barebox.org>
LIBFDT is often available, because CONFIG_BOARD_GENERIC_DT pulls it in,
but in the normal case, we unflatten DT and have no need for libfdt at
all.
Remove the libfdt dependency from the EFI loader code by opencoding the
magic check.
Fixes: 229bc3b37e64 ("efi: loader: implement bootm handler")
Reported-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
efi/loader/bootm.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/efi/loader/bootm.c b/efi/loader/bootm.c
index dffe53bcf9c8..da664847def8 100644
--- a/efi/loader/bootm.c
+++ b/efi/loader/bootm.c
@@ -124,15 +124,20 @@ static efi_status_t copy_fdt(void **fdtp)
*/
static efi_status_t efi_install_fdt(void *fdt)
{
+ const struct fdt_header *hdr = fdt;
/*
* The EBBR spec requires that we have either an FDT or an ACPI table
* but not both.
*/
efi_status_t ret;
- /* Install device tree */
- if (fdt_check_header(fdt)) {
- pr_err("invalid device tree\n");
+ if (hdr->magic != cpu_to_fdt32(FDT_MAGIC)) {
+ pr_err("bad magic: 0x%08x\n", fdt32_to_cpu(hdr->magic));
+ return EFI_LOAD_ERROR;
+ }
+
+ if (hdr->version != cpu_to_fdt32(17)) {
+ pr_err("bad dt version: 0x%08x\n", fdt32_to_cpu(hdr->version));
return EFI_LOAD_ERROR;
}
--
2.47.3
prev parent reply other threads:[~2026-01-20 10:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 10:49 [PATCH 1/2] efi: loader: protocol: gop: guard behind CONFIG_EFI_LOADER_GOP Ahmad Fatoum
2026-01-20 10:49 ` Ahmad Fatoum [this message]
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=20260120104957.41978-2-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
--cc=l.goehrs@pengutronix.de \
/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