From patchwork Sat Jan 10 20:28:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1464 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=1768077043; bh=opI5LxWWtk8uT4r+EpNHIJovq4KmeRRMF4/3rGv9mgM=; 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=AVSbz8PpocHErLPrZbBAdyFuL9hSFEvKmfjdwPNWrdsNNVjohW/8MA4NGPYHTjPXG vymrrpJ0DX7hpZoGTwFNFj2OwR6f6W6NDiTEqf0cUqyQe0WMBjVdy0Fhfjqcg/AV7R gcT2DvO0vWa9rFKaFuO6mHqJ4QHwSHnNHDbZ1PUUvo0RQcK5XmednK59RzJ4bGUve/ kt0iCPETG3DQbBP7IEpZAug+2gkxy+StEYZV8nlYrWY4G/QafzSQjYUm6weCPxYHbA ui58VT3L+//oF4VZa9hsT9mBFxE5HTr0i0pHXBLnyxB6zonOPIVeF8US+iHlRsr7XB 03p5203BAWFXQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 051C5692A6 for ; Sat, 10 Jan 2026 13:30:43 -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 0wQ7oWn1epKC for ; Sat, 10 Jan 2026 13:30:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077042; bh=opI5LxWWtk8uT4r+EpNHIJovq4KmeRRMF4/3rGv9mgM=; 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=ru5bp7WmZC5gKnrbrnggdaQFDLIWkNqyTTIgWDyiD2yX7YR3yeYN9d8+OedGmcFm0 vPUwHlB1AbmD/KJ3UDHGqsKAVGnSMUGJWGZpkWztNZNhOTXDJwLj5FyqvZiJwt7bzc DI3YTvVpAdhJliEgpjQ9qZucGplsAcZ0MdfLkz8YqV/v4hsOdTbS+ONwQuNf3mT5NW ++aV8KC7gY3YdT+DxJ73a4yCMPkcSj+KN42oVA9p5F1WQ1Xim1PumG78hvcHMZjxdF ZbLJEyzjV6hHM4C22JBhBg54kwWhVT2/59ERUi9OYYvq+ToUt05SPjN0RPV9kW0BPV KVEg2Z3g9eT9w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DFD5569296 for ; Sat, 10 Jan 2026 13:30:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077041; bh=fVli9Ps8/gTcU+7ZAszk5hLcpnebRX5WEdjdZeTMhnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wLeD+svvQwE6OvL6/frzxvteIBFHyJHpKoWS3QoLwQo2qdf4sAYlxKzv9np3Xo0XC 2hu4L8210aAd7zbFPfBAONzHksHDHF2FPG7OanqNbLNwlIyC+tG/N6hiYIO0cYxrPB lA6gU36RdHvvaXiMLhugqlYEN6f1/gWtNFfRFdgFl8vKTMG68HxF4XP1ybGeSQpT9T FJBRIdq5QEm9TD3t4Tc4DE7drh5H5sDn2aK4cg8ql2jSvKYSI8KL+I8KvY3qm3mbSR V+PSuhagZShNZkj6n5S8BB3u8NWqZ9gvKlz/FAmvMkYsPxedbxiRXQgjWbZiuY8IRZ hLG0EMXI7/eiA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 98F6A69291; Sat, 10 Jan 2026 13:30:41 -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 xmj4_o-Igzv4; Sat, 10 Jan 2026 13:30:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077037; bh=fpnRXU4GpO7xTTmtA890awzBcSe0LDheEj/PTyniKww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l4FI1ANTH6dbaIxStbxJmxQDbQ6YyI5vAVTZ20FG8Es7MMMtBmxOM3Q5Z1jlHndKm EyKca387WuAFeDsVuSDmLqwlb9fweOj+IXkKZE5X6wDccXTSKCQyFc5Mwm4B4HNd7t CkG8drY0DDFRMnTEaGXMRb7r+7Y579y3hfi6PcsYsHeLrHhnLZViy6ufQcyonLFk7F ryk86uOwYaxHwmd3ImwLUhU2oBV7p4sd6HhWHDbU6WEkZbdswrvY4LxlWjMVKUvSUX LwU5taLwM7LB084N6j6TSB5+nXjyhCSvtEAIbEURPBngurmW3OjT+lYRhOjp6X91qB IUmTZO/JqC/MQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 27E4269186; Sat, 10 Jan 2026 13:30:37 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:50 -0700 Message-ID: <20260110202906.187370-19-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: GNGDAR4P22PJ2S6O67KLHOUCDYBVHMVG X-Message-ID-Hash: GNGDAR4P22PJ2S6O67KLHOUCDYBVHMVG 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 18/26] boot: pxe: Add pxe_process_str() for nul-terminated strings 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 pxe_process() function requires a nul-terminated string at the given address. Rename the function to pxe_process_str() to make this requirement clear, and add a note to the documentation. Add a size parameter to pxe_process() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/ext_pxe_common.c | 2 +- boot/pxe_utils.c | 17 +++++++++++++++-- cmd/pxe.c | 2 +- cmd/sysboot.c | 2 +- doc/develop/bootstd/extlinux.rst | 2 +- doc/develop/bootstd/pxelinux.rst | 2 +- include/pxe_utils.h | 16 ++++++++++++++-- 7 files changed, 34 insertions(+), 9 deletions(-) diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 930e54ea84d..2bc76a4d0fb 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -115,7 +115,7 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, return log_msg_ret("elb", ret); plat->ctx.restart = restart; addr = map_to_sysmem(bflow->buf); - ret = pxe_process(&plat->ctx, addr, false); + ret = pxe_process_str(&plat->ctx, addr, false); } if (ret) return log_msg_ret("elb", -EFAULT); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 6416ee3ddff..3f751f25bea 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1325,11 +1325,12 @@ static struct pxe_menu *pxe_prepare(struct pxe_context *ctx, return cfg; } -int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) +int pxe_process(struct pxe_context *ctx, ulong addr, ulong size, bool prompt) { struct pxe_menu *cfg; - cfg = pxe_prepare(ctx, pxefile_addr_r, prompt); + ctx->pxe_file_size = size; + cfg = pxe_prepare(ctx, addr, prompt); if (!cfg) return 1; @@ -1340,6 +1341,18 @@ int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) return 0; } +int pxe_process_str(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) +{ + void *ptr; + int len; + + ptr = map_sysmem(pxefile_addr_r, 0); + len = strnlen(ptr, SZ_64K); + unmap_sysmem(ptr); + + return pxe_process(ctx, pxefile_addr_r, len, prompt); +} + int pxe_probe(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) { ctx->cfg = pxe_prepare(ctx, pxefile_addr_r, prompt); diff --git a/cmd/pxe.c b/cmd/pxe.c index 9f40f13c201..2cda2597f28 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -286,7 +286,7 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) printf("Out of memory\n"); return CMD_RET_FAILURE; } - ret = pxe_process(&ctx, pxefile_addr_r, false); + ret = pxe_process(&ctx, pxefile_addr_r, ctx.pxe_file_size, false); pxe_destroy_ctx(&ctx); if (ret) return CMD_RET_FAILURE; diff --git a/cmd/sysboot.c b/cmd/sysboot.c index e6f89c999cc..b48272b2126 100644 --- a/cmd/sysboot.c +++ b/cmd/sysboot.c @@ -119,7 +119,7 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc, return 1; } - ret = pxe_process(&ctx, pxefile_addr_r, prompt); + ret = pxe_process(&ctx, pxefile_addr_r, ctx.pxe_file_size, prompt); pxe_destroy_ctx(&ctx); if (ret) return CMD_RET_FAILURE; diff --git a/doc/develop/bootstd/extlinux.rst b/doc/develop/bootstd/extlinux.rst index bf27dc57aaa..0c8526d7325 100644 --- a/doc/develop/bootstd/extlinux.rst +++ b/doc/develop/bootstd/extlinux.rst @@ -21,7 +21,7 @@ When invoked on a bootdev, this bootmeth searches for the file and creates a bootflow if found. When the bootflow is booted, the bootmeth calls ``pxe_setup_ctx()`` to set up -the context, then ``pxe_process()`` to process the file. Depending on the +the context, then ``pxe_process_str()`` to process the file. Depending on the contents, this may boot an operating system or provide a list of options to the user, perhaps with a timeout. diff --git a/doc/develop/bootstd/pxelinux.rst b/doc/develop/bootstd/pxelinux.rst index c4b7fbb4c9c..c3d5e6f2408 100644 --- a/doc/develop/bootstd/pxelinux.rst +++ b/doc/develop/bootstd/pxelinux.rst @@ -19,7 +19,7 @@ bootflow if found. See a full description of the search procedure. When the bootflow is booted, the bootmeth calls ``pxe_setup_ctx()`` to set up -the context, then ``pxe_process()`` to process the file. Depending on the +the context, then ``pxe_process_str()`` to process the file. Depending on the contents, this may boot an Operating System or provide a list of options to the user, perhaps with a timeout. diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 50e0c0c6b93..e8045511c6a 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -366,14 +366,26 @@ int pxe_setup_ctx(struct pxe_context *ctx, pxe_getfile_func getfile, */ void pxe_destroy_ctx(struct pxe_context *ctx); +/** + * pxe_process_str() - Process a PXE file through to boot + * + * Note: The file at @pxefile_addr_r must be a nul-terminated string. + * + * @ctx: PXE context created with pxe_setup_ctx() + * @pxefile_addr_r: Address of config to process + * @prompt: Force a prompt for the user + */ +int pxe_process_str(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt); + /** * pxe_process() - Process a PXE file through to boot * * @ctx: PXE context created with pxe_setup_ctx() - * @pxefile_addr_r: Address to load file + * @addr: Address of config to process + * @size: Size of continue to process * @prompt: Force a prompt for the user */ -int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt); +int pxe_process(struct pxe_context *ctx, ulong addr, ulong size, bool prompt); /** * pxe_get_file_size() - Read the value of the 'filesize' environment variable