From patchwork Fri Jan 9 23:11:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1412 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=1768000408; bh=wwPbHcPt1hPZ82UwKyTnk2inWAQT+9p+PA/iZyjKsj8=; 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=EjAMjORE3liZzYr12GIyGq6pbSyQLvHkUBEUvgAqmQFfAMe+U+LFdxNvr5KSXn8Mj t3hk/Zwyx77w1Oi6kse5DyCg90JiUfU8qvgUhGn/kEFE2kVZvQ3zDivXyuth1+YPtL mBMRkI8i/MnL3ZIIxBVgNnLuLgQWmK3buLeJ6ltIoo6yGD7AMbIEwfpHO6QgsMLg06 p+I89M3q+KjJqooFETTBDikXhuU86myHIksHDpEzcccLRocMVseIycB/jSJumlhD7L FeBbhDG+gQ4dbbYVd4UmfQv6MNpB5osOIxoc1j55WXpMSuwE+65kGR0STQZ9iKaZBy hbRsq+ClWKoxQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 387696923D for ; Fri, 9 Jan 2026 16:13:28 -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 Be5R69LZF6KZ for ; Fri, 9 Jan 2026 16:13:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000408; bh=wwPbHcPt1hPZ82UwKyTnk2inWAQT+9p+PA/iZyjKsj8=; 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=EjAMjORE3liZzYr12GIyGq6pbSyQLvHkUBEUvgAqmQFfAMe+U+LFdxNvr5KSXn8Mj t3hk/Zwyx77w1Oi6kse5DyCg90JiUfU8qvgUhGn/kEFE2kVZvQ3zDivXyuth1+YPtL mBMRkI8i/MnL3ZIIxBVgNnLuLgQWmK3buLeJ6ltIoo6yGD7AMbIEwfpHO6QgsMLg06 p+I89M3q+KjJqooFETTBDikXhuU86myHIksHDpEzcccLRocMVseIycB/jSJumlhD7L FeBbhDG+gQ4dbbYVd4UmfQv6MNpB5osOIxoc1j55WXpMSuwE+65kGR0STQZ9iKaZBy hbRsq+ClWKoxQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 15F3869240 for ; Fri, 9 Jan 2026 16:13:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000406; bh=OYAmkvPmWIhjMU3yi4BHXP2wj9BOC/P2QLPtCr6elWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g52MmInSxulnJ8ZyR5eDLKgwqnD8WWSufY9J5YMqv2KA/qwA6LEB5CL/XA5Sqn1I+ hgHJ1ezRYqh8GOCIHIatSJGPN0HdsJsuHDDchWkwb1MTMehksZlGL9m14zMrpoNE70 zGTKbHKEievjQKhkGu1RsTKOlsM0jLgylAYRzsqdPBp01XOXpkqjt+G8IVBfeVJrbR 9yEd6TBFFOvZXmwSmUcJ57zprjP1wx67c9VchygSi+ouJsYRoqG2rw5YmKvrYzjhnk C6iDaPkc9oYdmqy64vdh7aV8lMpmJ5YCYNrF4Ywk2VxKEURvZ/5j8QIzB5YhM33g2a fwzTs7a+AdO5w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8673E5FF82; Fri, 9 Jan 2026 16:13:26 -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 pN7lOmYX0Fzq; Fri, 9 Jan 2026 16:13:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000402; bh=mA+jIegmE3diD4NALB1Z03MCYhj49zjoC7w2C8oeW1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XjnT/ST8O79dgMVfUBve7UpWeIOi1RSpvzasb8EcO947Mi/K2jT+7TimLw+xhUCv4 gXRkUnxKx3NxJ2LMdPyz/fefV6CQYAO/o3AkTMHu4QzbCJYVCp7gfYn8SoYvHtamZ5 tGcuejnK49i4SCRaJ7zLs5M1aWgENLuYCr173kOBFRAJ7KqXlq06M4ZC6X6+0QTp29 unzNvRllHKlxXvlk/Zhmrmha8Mu+vfTcQfvLJDRncXL+tPM798ReF/cNzGiUAqVRdr WHNGMyArkZs6XQCCQroDkuIzOUObo+B0XOPYX02HlHhNNCZQHIBcv0cXw4ZIh9cPfE PRQdw0aJheaHQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C3C7769218; Fri, 9 Jan 2026 16:13:21 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:25 -0700 Message-ID: <20260109231151.4056804-17-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: QERII5GIH3PBQHJY35PJPBIHOIZNJBZS X-Message-ID-Hash: QERII5GIH3PBQHJY35PJPBIHOIZNJBZS 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 16/32] boot: pxe: Add FDT pointer to context for kaslrseed 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 The label_boot_kaslrseed() function reads fdt_addr_r from the environment and maps it to get the working FDT. This requires CONFIG_CMDLINE to be enabled for the environment access. Add a new 'fdt' field to struct pxe_context to hold the working FDT pointer. Set this after loading the FDT file in label_process_fdt() and use it in label_boot_kaslrseed(). This removes the environment dependency and ensures the correct FDT is used. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 27 +++++++++++---------------- include/pxe_utils.h | 2 ++ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 0994e7e5196..93e00b6f97e 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -277,30 +277,23 @@ static int label_localboot(struct pxe_label *label) /* * label_boot_kaslrseed generate kaslrseed from hw rng */ - -static void label_boot_kaslrseed(void) +static void label_boot_kaslrseed(struct pxe_context *ctx) { #if CONFIG_IS_ENABLED(DM_RNG) - ulong fdt_addr; - struct fdt_header *working_fdt; int err; - /* Get the main fdt and map it */ - fdt_addr = hextoul(env_get("fdt_addr_r"), NULL); - working_fdt = map_sysmem(fdt_addr, 0); - err = fdt_check_header(working_fdt); + err = fdt_check_header(ctx->fdt); if (err) return; /* add extra size for holding kaslr-seed */ /* err is new fdt size, 0 or negtive */ - err = fdt_shrink_to_minimum(working_fdt, 512); + err = fdt_shrink_to_minimum(ctx->fdt, 512); if (err <= 0) return; - fdt_kaslrseed(working_fdt, true); + fdt_kaslrseed(ctx->fdt, true); #endif - return; } /** @@ -577,15 +570,17 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, printf("Skipping fdtdir %s for failure retrieving dts\n", label->fdtdir); } - } + } else { + ctx->fdt = map_sysmem(addr, 0); - if (label->kaslrseed) - label_boot_kaslrseed(); + if (label->kaslrseed) + label_boot_kaslrseed(ctx); #ifdef CONFIG_OF_LIBFDT_OVERLAY - if (label->fdtoverlays) - label_boot_fdtoverlay(ctx, label); + if (label->fdtoverlays) + label_boot_fdtoverlay(ctx, label); #endif + } } else { *fdt_argp = NULL; } diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 7f5b8c040d6..9bca8d7868d 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -152,6 +152,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * @initrd_str: initrd string to process (only used if @initrd_addr) * @conf_fdt_str: FDT-address string * @conf_fdt: FDT address + * @fdt: Working FDT pointer, for kaslrseed and overlay operations * @restart: true to use BOOTM_STATE_RESTART instead of BOOTM_STATE_START (only * supported with FIT / bootm) * @fake_go: Do a 'fake' boot, up to the last possible point, then return @@ -190,6 +191,7 @@ struct pxe_context { char *initrd_str; char *conf_fdt_str; ulong conf_fdt; + void *fdt; /* working FDT pointer, for kaslrseed/overlays */ bool restart; bool fake_go; };