From patchwork Fri Jan 9 23:11:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1424 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000456; bh=kzEcyc/895siSfU5kGn2ApFL8PaW3S3UW/J/mTvRuYI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=j0O3tWoJ0vWq7ITuLDBfRCsre4Yh+FkgCyrzD3ycK+jEnhBdm4uOHL89eWDuLPyIJ 8kXtC9+od7JeLEpWVhqoLd2vV/EL8WM9j7JdCrlbBNa8X3bkfsNnpW2mblKxhQYZQT ukC4Z7JabIWdDG1Xz6rReDwHPjnIk89mT2S+F6p7gZY4CJdBJX4YiBbCFhiP1MA1o/ CiE6X+LANCuK3q2DKrVS8UmExoBPc7QfVFSLJ67d9lw46Ea5+Jgmh40aNqNHLYTjaE vLBPqV1DzdC5K8V3xMeBuBW4pcqcEu3jDn9td5UIcNkTCl/JosEQaOWsfv0HDNGQp+ TpRx6EsfiUqkw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6C5B869243 for ; Fri, 9 Jan 2026 16:14:16 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Q_M6JH0VFR3y for ; Fri, 9 Jan 2026 16:14:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000456; bh=kzEcyc/895siSfU5kGn2ApFL8PaW3S3UW/J/mTvRuYI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=j0O3tWoJ0vWq7ITuLDBfRCsre4Yh+FkgCyrzD3ycK+jEnhBdm4uOHL89eWDuLPyIJ 8kXtC9+od7JeLEpWVhqoLd2vV/EL8WM9j7JdCrlbBNa8X3bkfsNnpW2mblKxhQYZQT ukC4Z7JabIWdDG1Xz6rReDwHPjnIk89mT2S+F6p7gZY4CJdBJX4YiBbCFhiP1MA1o/ CiE6X+LANCuK3q2DKrVS8UmExoBPc7QfVFSLJ67d9lw46Ea5+Jgmh40aNqNHLYTjaE vLBPqV1DzdC5K8V3xMeBuBW4pcqcEu3jDn9td5UIcNkTCl/JosEQaOWsfv0HDNGQp+ TpRx6EsfiUqkw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5A58769221 for ; Fri, 9 Jan 2026 16:14:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000453; bh=bBtX5M3Yzaz7JAdp19kOeyrXzUqK1YCoge27GjAstAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R2XA0u1RluELJkRQjp0n/guvGTGP0wxHgyNUcsKQdf9cbp6L/IEh278ulQYrQdvwU 9Y4NSse6rSOCOmkg5+RN9amfzStJjfiwv1v7MrWgLz5jjjzh8cOeo35riRt/6/51vm YRr9DBHceDlf+4Cz7V+OxCuEbkHLz+1dLCoLYJAHZXRTsgEoooJlY404KmfLYEewDH WMQOREJueY+uAytSba8E/qfGvJl6UgFWnHeEJsgrLf2gPiUVcX4Imp1D0sD9eC+DIh XKc6/QdfRLrrdhsnpzQRKiEwNQCNhC5++wroprq2NBCH91YkygnA1wEraMEl7kl00N Rwc8/GBE4b3tA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7218969218; Fri, 9 Jan 2026 16:14:13 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id F_O23fvbQm8l; Fri, 9 Jan 2026 16:14:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000449; bh=xigozcrX0gw49LODqe71uDspyGnZccWu+FJ+HcsaRA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aVAvo0fguoOegUuq0Mb4N2f1w5Fo9GJibL8DFqA4InElbDDEujreTRdnOZr0UexAd uzmAF3YMNTzIuWPMaGfA5byOsrOzvADhLXIJcHM4fPDzUT6QzEco4IxRUU/gcuzw6u jCQWLKjzagf9/DCAVc7bZi2r6zKSgz6Zw0cjxyRDi00q06HK+NjFa7Xo+X504jsnPy pXKYkxMhDa6Arv/KsJxba1gMM1mXi54m5X5VCROPVuz4mJTRQsWgydtZjP5vQ39sgK uUG5KxaTccTSdvMEDjOnR4HcJBuh8WrsvW8hRTO5oQ7Mn87o7lJCTz7Fv8ZXBNZ0DV ro92PLaHKss6g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 05BF35FF82; Fri, 9 Jan 2026 16:14:08 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:37 -0700 Message-ID: <20260109231151.4056804-29-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XQECIXQZNPUBCHO5R6DVMTAWEXNJWVQU X-Message-ID-Hash: XQECIXQZNPUBCHO5R6DVMTAWEXNJWVQU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 28/32] boot: pxe: Split label_boot_fdtoverlay() into load and apply functions List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Split label_boot_fdtoverlay() into two separate functions: - label_load_fdtoverlays(): loads all overlay files and stores addresses - label_apply_fdtoverlays(): applies loaded overlays to working FDT This separation allows for future flexibility in when overlays are loaded versus applied. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 8d565d971fc..4bae830f353 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -297,25 +297,21 @@ static void label_boot_kaslrseed(struct pxe_context *ctx) } /** - * label_boot_fdtoverlay() - Loads fdt overlays specified in 'fdtoverlays' - * or 'devicetree-overlay' + * label_load_fdtoverlays() - Load FDT overlay files + * + * Load all overlay files specified in the label. The loaded addresses are + * stored in each overlay's addr field. * * @ctx: PXE context * @label: Label to process */ -static void label_boot_fdtoverlay(struct pxe_context *ctx, - struct pxe_label *label) +static void label_load_fdtoverlays(struct pxe_context *ctx, + struct pxe_label *label) { struct pxe_fdtoverlay *overlay; - struct fdt_header *blob; ulong fdtoverlay_addr; bool use_lmb; char *envaddr; - int err; - - err = fdt_check_header(ctx->fdt); - if (err) - return; /* * Get the overlay load address. If fdtoverlay_addr_r is defined, @@ -331,10 +327,10 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, use_lmb = true; } - /* First pass: load all overlay files */ alist_for_each(overlay, &label->fdtoverlays) { ulong addr = fdtoverlay_addr; ulong size; + int err; err = get_relfile(ctx, overlay->path, &addr, SZ_4K, (enum bootflow_img_t)IH_TYPE_FLATDT, &size); @@ -348,11 +344,30 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, if (!use_lmb) fdtoverlay_addr = addr + size; } +} + +/** + * label_apply_fdtoverlays() - Apply loaded FDT overlays to working FDT + * + * Apply all previously loaded overlays to the working FDT. + * + * @ctx: PXE context + * @label: Label containing overlays to apply + */ +static void label_apply_fdtoverlays(struct pxe_context *ctx, + struct pxe_label *label) +{ + struct pxe_fdtoverlay *overlay; + struct fdt_header *blob; + int err; + + err = fdt_check_header(ctx->fdt); + if (err) + return; /* Resize main fdt to make room for overlays */ fdt_shrink_to_minimum(ctx->fdt, 8192); - /* Second pass: apply all loaded overlays */ alist_for_each(overlay, &label->fdtoverlays) { if (!overlay->addr) continue; @@ -500,8 +515,10 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label) if (label->kaslrseed) label_boot_kaslrseed(ctx); - if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->fdtoverlays.count) - label_boot_fdtoverlay(ctx, label); + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->fdtoverlays.count) { + label_load_fdtoverlays(ctx, label); + label_apply_fdtoverlays(ctx, label); + } return 0; }