From patchwork Fri Jan 9 23:11:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1422 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=1768000446; bh=tPpUDQmCKkpjnLZkEoUtSQqw9B2jGLU7toQJW/8tcCw=; 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=kFr/TiEICYCxQGaUu/P4TTkLtye47Iy3/EQRvNP93VH4SmjnqGPoNbORxJXQ+8o/Y xO1ZOHjFoZLK1HHdxNVWFirXVNJ14a+bPSrHS47uYVfqibWPlmYR6BpTaSj7QHjeS6 29CmadfM+58wEg5j/dMslZGvhVrka2819/KGvuK+GFiCJtUg37jc7S+sZ2LornS0jp aZeLz4VhlZ2SWt3heB5S2FPYH6EkXtJUtYcdiOgxfKPY89P0ynxdeC0y14GGu10kEn CLEAmyp5eliA5fZnJXY+djHHhpyiKXfCOXExFZoB7XlMIefCIHXg5/VAq20meQiQ+z Gx8xhbwWh0CQQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 82B3769243 for ; Fri, 9 Jan 2026 16:14:06 -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 prbWrlrz0A3p for ; Fri, 9 Jan 2026 16:14:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000446; bh=tPpUDQmCKkpjnLZkEoUtSQqw9B2jGLU7toQJW/8tcCw=; 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=kFr/TiEICYCxQGaUu/P4TTkLtye47Iy3/EQRvNP93VH4SmjnqGPoNbORxJXQ+8o/Y xO1ZOHjFoZLK1HHdxNVWFirXVNJ14a+bPSrHS47uYVfqibWPlmYR6BpTaSj7QHjeS6 29CmadfM+58wEg5j/dMslZGvhVrka2819/KGvuK+GFiCJtUg37jc7S+sZ2LornS0jp aZeLz4VhlZ2SWt3heB5S2FPYH6EkXtJUtYcdiOgxfKPY89P0ynxdeC0y14GGu10kEn CLEAmyp5eliA5fZnJXY+djHHhpyiKXfCOXExFZoB7XlMIefCIHXg5/VAq20meQiQ+z Gx8xhbwWh0CQQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6F19369221 for ; Fri, 9 Jan 2026 16:14:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000444; bh=VgM+iCp7NNY3QHzmO5dOkVU8kmKQab1dxNwgeIiyLEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYgsNbLoe0NGT4f75x1a7NRVp9BHqC5ZRUl0Qd+uYvvsYB9Cqy1ZxqNNjqCQDgib6 M6sk8yz3oREBkb/YDTU7YHNpOhnFQcNDlZ2roHqERvP7Bjo2VG2jRRFNIvSh3vUdWe 6K1w/J6FmSBUjKSHRPRMQIRSuBPjSWi6eXWpJWhNaWAjkffwpSKSKfeWovqfJOzRhQ V3zWyqFLiceW/tz1KKSg6rhTCiGclcDhlMagK7+OWapmaNjXA5fuwEMezs5DvXT6yV HC1aZx6m4lGiBZ0uGpFhV5ovFjllzvLmAByj6O7L/CxRZx17WBT6ibeLCaJkMZ8Ycg GEVz7T+JGNdcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1018F69218; Fri, 9 Jan 2026 16:14:04 -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 iiVkADHVTboY; Fri, 9 Jan 2026 16:14:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000440; bh=PxkJvu7RV8zE2dxk7M9/j8o02UToeuS8RFxMO2h3l9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kx+bgk8vn4wtp/X+e2wzGqDGpj2dOLcHXDWND6V67KMvQFc2QUA5R8Fpu+byOreOx quyIFjyNZNZ4FIFSi1xi5ih2nlBf4Uc7SYcqtXlXFuxhWZWRx0akKdUT+XN+MM0XvU j1joohREHXTkxXwSxGLsZCkNfDaUIxXOz0N6CjSGaUs3w4FfgnU2V98uqp8F3Ogb5O FS5vgBOQ7d1Zs0Sd69C9MBTYrGTtrXTEeGr529w/sSVPItHBGOwxPfv1GUoe9FVqfp 2WfYn8V28vzZY72COsVO0CM/ivBC4Ll43akCcdfjvAdOneEFtUpEtIXH0DrS34dIlR k8yE52kdTVnOA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A7E895FF82; Fri, 9 Jan 2026 16:13:59 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:35 -0700 Message-ID: <20260109231151.4056804-27-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: KNGCFSRYDQGEAC6FXNV7DRD44ZR6SUU4 X-Message-ID-Hash: KNGCFSRYDQGEAC6FXNV7DRD44ZR6SUU4 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 26/32] boot: pxe: Load overlays to sequential addresses 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 Update label_boot_fdtoverlay() to load each overlay to a unique address. If fdtoverlay_addr_r is defined, start at that address and increment by the overlay size after each load. If not defined, let LMB allocate a fresh address for each overlay by passing addr = 0. This ensures that multiple overlays don't overwrite each other in memory before they are applied. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index e368b15e500..a50fa4bc333 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -307,23 +307,39 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, struct pxe_label *label) { struct fdt_header *blob; + ulong fdtoverlay_addr; char **overlayp; - ulong 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, + * overlays are loaded sequentially at increasing addresses. Otherwise, + * LMB allocates a fresh address for each overlay. + */ + envaddr = env_get("fdtoverlay_addr_r"); + if (envaddr) { + fdtoverlay_addr = hextoul(envaddr, NULL); + use_lmb = false; + } else { + fdtoverlay_addr = 0; + use_lmb = true; + } + /* Apply each overlay file in order */ alist_for_each(overlayp, &label->fdtoverlays) { const char *overlayfile = *overlayp; + ulong addr = fdtoverlay_addr; + ulong size; /* Load overlay file */ - err = get_relfile_envaddr(ctx, overlayfile, "fdtoverlay_addr_r", - SZ_4K, - (enum bootflow_img_t)IH_TYPE_FLATDT, - &addr, NULL); + err = get_relfile(ctx, overlayfile, &addr, SZ_4K, + (enum bootflow_img_t)IH_TYPE_FLATDT, &size); if (err < 0) { printf("Failed loading overlay %s\n", overlayfile); continue; @@ -343,6 +359,10 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, if (err) printf("Failed to apply overlay %s, skipping\n", overlayfile); + + /* Move to next address if using fixed addresses */ + if (!use_lmb) + fdtoverlay_addr = addr + size; } }