From patchwork Sat Jan 10 20:28:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1463 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=1768077039; bh=2sgns7wctCaa72CxiqnHP4cL00g2Y84en6Fo0vXt3nc=; 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=c0iZuo2lZo8ePbUFzBdttfUofixnTGzfBpYm34HRfvsp53YND4k40eBP16opEeUy1 8eab5pTui2NGrkfNyUQVyZzyDjOndASUG+JHU54hFuFSJ7ivg9pFGQN134HhsA0xuE dnhO+9RZlw6cSYThKNFW7a96yncUuA+zyzYDYostcfX4MwBv893WYys03leNYuvooW lq7bhuoOi8+i4cHhGKzKUrD+Wve9J9IEYN1jOcOyegHkApd4elk27XE6sNHhp/qg5E PQbQVne+XfsbjrmhPR4EEJq8y1fbJ/ZjRTllb8Meqa8mW7zfEKyjbIfNIlQ+ArYZJV ccHZDqZQoG9gQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 37F1E69299 for ; Sat, 10 Jan 2026 13:30:39 -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 6w2pWPRozWYr for ; Sat, 10 Jan 2026 13:30:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077039; bh=2sgns7wctCaa72CxiqnHP4cL00g2Y84en6Fo0vXt3nc=; 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=c0iZuo2lZo8ePbUFzBdttfUofixnTGzfBpYm34HRfvsp53YND4k40eBP16opEeUy1 8eab5pTui2NGrkfNyUQVyZzyDjOndASUG+JHU54hFuFSJ7ivg9pFGQN134HhsA0xuE dnhO+9RZlw6cSYThKNFW7a96yncUuA+zyzYDYostcfX4MwBv893WYys03leNYuvooW lq7bhuoOi8+i4cHhGKzKUrD+Wve9J9IEYN1jOcOyegHkApd4elk27XE6sNHhp/qg5E PQbQVne+XfsbjrmhPR4EEJq8y1fbJ/ZjRTllb8Meqa8mW7zfEKyjbIfNIlQ+ArYZJV ccHZDqZQoG9gQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 278C769291 for ; Sat, 10 Jan 2026 13:30:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077037; bh=Lz08hWcZYKXMaNYhbXvFjIeG/YtK8e7ZHCug35G1DRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K/I5gcGYetHNwrKTY/GA0PdMudsh0OPFrpAG+bMpWUweRakNAuXZCtmM0vqtyBf8q M+bIT+PZ2VuUWNeeHVVKz8It/atMswZ6BGL6TXW5ySjBBxpAGD1t7ly18DFQByNyPx VL2F3nNIP+uDJz99YykYfDaKz+jROpIAjsSM9j6LYaWxeznl/TBkspQ03mXabP8VVM f6rRHPndWrtNhI4B5jjdf5/VRunlhkPl7lBE5WRJlBsq5wh0rBB1C3wYdko/1Df+4M kWZHGnOdpAisZsbSBcgX8FZGpDneg1xUJAMya2HMGAghD/488LK+tBT+1W9k6xd949 5Ubk/ZPgD1zjQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 29B566927E; Sat, 10 Jan 2026 13:30:37 -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 OsbKvgVOXuIs; Sat, 10 Jan 2026 13:30:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077032; bh=6AyPAr9B6osGMj7amuqy4WUryIFuID7wHRMmV5rAe48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=quhDY2Y5ytfYl76TlVBIRq02OktpiXZnKdhVXEpPNSkTmuWu3XJieQr1SEQAwCdRr rM99dT+P1yeCRjCGzdYEos6VfNegUPu2UkLRny8xy8EBum48qJ74BmEfAh7MIz5hSZ uAWXcR/Cgf5qQZKMsCzPphcGLgg7jnuXV1qhkRvXvnKDqaXDf1F32mtHjvVb22jpXQ BDtgS+YvCYh3+35iPt5A4WN0WlqxaPuhHCmzDlC/YNskJr/NOplHwVI2iDvPyRfH5T RRxB63TzE0fXH/KX96+5ZRzmBNjhAxCmn11Y4s/JQ9iYKPI2Y2hNsTNthHkGz5VymR UHe21BpsjyhSg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7F8BF69290; Sat, 10 Jan 2026 13:30:32 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:49 -0700 Message-ID: <20260110202906.187370-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260110202906.187370-1-sjg@u-boot.org> References: <20260110202906.187370-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IE4L3LQ7HOMECNKYNSONAQXBN6TC63ZI X-Message-ID-Hash: IE4L3LQ7HOMECNKYNSONAQXBN6TC63ZI 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 17/26] boot: pxe: Add size parameter to parse_pxefile() 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 parse_pxefile() function uses map_sysmem() to map the file contents. Currently it passes 0 for the size, which works but is not ideal. Add an explicit size parameter so callers can provide the actual file size. Internal callers use ctx->pxe_file_size which is set by get_pxe_file(). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 7 ++++--- include/pxe_utils.h | 4 +++- test/boot/pxe.c | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 2d9081e6e9b..6416ee3ddff 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1004,7 +1004,8 @@ void pxe_menu_uninit(struct pxe_menu *cfg) free(cfg); } -struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg) +struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg, + ulong size) { struct pxe_menu *cfg; char *buf; @@ -1014,7 +1015,7 @@ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg) if (!cfg) return NULL; - buf = map_sysmem(menucfg, 0); + buf = map_sysmem(menucfg, size); r = parse_pxefile_top(ctx, buf, menucfg, cfg, 1); unmap_sysmem(buf); @@ -1306,7 +1307,7 @@ static struct pxe_menu *pxe_prepare(struct pxe_context *ctx, struct pxe_menu *cfg; int ret; - cfg = parse_pxefile(ctx, pxefile_addr_r); + cfg = parse_pxefile(ctx, pxefile_addr_r, ctx->pxe_file_size); if (!cfg) { printf("Error parsing config file\n"); return NULL; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 266204b97ef..50e0c0c6b93 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -299,10 +299,12 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg); * * @ctx: PXE context (provided by the caller) * @menucfg: Address of the PXE file in memory + * @size: Size of file in bytes * Return: NULL on error, otherwise a pointer to a pxe_menu struct. Use * pxe_menu_uninit() to free it. */ -struct pxe_menu *parse_pxefile(struct pxe_context *ctx, ulong menucfg); +struct pxe_menu *parse_pxefile(struct pxe_context *ctx, ulong menucfg, + ulong size); /** * pxe_process_includes() - Process include files in a parsed menu diff --git a/test/boot/pxe.c b/test/boot/pxe.c index a1ce27ea2a7..1a990a8e348 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -161,7 +161,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(1, ret); /* get_pxe_file returns 1 on success */ /* Parse the config file */ - cfg = parse_pxefile(&ctx, addr); + cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); ut_assertnonnull(cfg); /* Process any include files */ @@ -465,7 +465,7 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) /* Read and parse the config file */ ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); - cfg = parse_pxefile(&ctx, addr); + cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); ut_assertnonnull(cfg); /* Consume parsing output */ @@ -574,7 +574,7 @@ static int pxe_test_errors_norun(struct unit_test_state *uts) /* Read and parse the config file */ ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); - cfg = parse_pxefile(&ctx, addr); + cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); ut_assertnonnull(cfg); /* Consume parsing output */ @@ -693,7 +693,7 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) ctx.quiet = true; ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); - cfg = parse_pxefile(&ctx, addr); + cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); ut_assertnonnull(cfg); /* Process any include files */ @@ -1268,7 +1268,7 @@ static int pxe_test_fit_embedded_fdt_norun(struct unit_test_state *uts) /* Read and parse the config file */ ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); - cfg = parse_pxefile(&ctx, addr); + cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); ut_assertnonnull(cfg); /* Consume parsing output */