From patchwork Sat Jan 10 20:28:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447 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=1768076967; bh=KLlJpNa/2MD792wCIZYU7LzM6DMou+SUu7kU0fydkXg=; 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=FQK2anIGkvxavZEwi7GL9yiXACQfmKaZsOjPHnu3BG9U5Ms0XFq4p1W9Na9oJo37G WIT/Xep3mn5upM+PZJFfavT1re4rFl00RpN6QG3SGC+XcZDe+nc/u64bPK+fAUeMC1 Ig8tGgOCXMQsYrpHkKANBUwmdrdz8nrPu69m4PbBvfh4PI0vHPckQ7ilj9twjiT2Mw Xs6W0uLYA+ogP11vCdH8RqJy0OAo3mkS1xhJWo2eFWPclOPVE8kCmqMGfPY+r7KkcY NlHxvIPjl/vI8VDtChMoQaf6VCz5Cc1OCzXEEC5q4TdQAymFicWkNUyh4KwlAv12vV 0vgv2pGPavxUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4962469291 for ; Sat, 10 Jan 2026 13:29:27 -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 4p2EXmm_kVKo for ; Sat, 10 Jan 2026 13:29:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076967; bh=KLlJpNa/2MD792wCIZYU7LzM6DMou+SUu7kU0fydkXg=; 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=FQK2anIGkvxavZEwi7GL9yiXACQfmKaZsOjPHnu3BG9U5Ms0XFq4p1W9Na9oJo37G WIT/Xep3mn5upM+PZJFfavT1re4rFl00RpN6QG3SGC+XcZDe+nc/u64bPK+fAUeMC1 Ig8tGgOCXMQsYrpHkKANBUwmdrdz8nrPu69m4PbBvfh4PI0vHPckQ7ilj9twjiT2Mw Xs6W0uLYA+ogP11vCdH8RqJy0OAo3mkS1xhJWo2eFWPclOPVE8kCmqMGfPY+r7KkcY NlHxvIPjl/vI8VDtChMoQaf6VCz5Cc1OCzXEEC5q4TdQAymFicWkNUyh4KwlAv12vV 0vgv2pGPavxUA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3837169281 for ; Sat, 10 Jan 2026 13:29:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076965; bh=EIxCMFFqKvBbAPr9Vfv30wvgOK2ZTrDEOQ8hDrYrqIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VI+pflx14fi5Zksjp3spGj+F7seYP/ZfZL1Zjl3ksvvhanOMYT2LlebkSC6xeaj5h JkSGM0rIoho2Qpk5yXRPYRYJYI34HZLpgx5omz8+F2nhShJ7QZu0j3SSnFd7j9UZa4 OgJ+4ma3PPNNWLqIxW3ZN9SuidxEtGUhQbShhGixKsR1hItkaWBjeQuKqLtFjbCnho t/4+Ob1bGFSnHEAe/r3z49IhaGTJ7ISedUWNJE0TAGAH4PpMA3fE32qs+4Pdb4lHk+ ri+GMiT3Qunpdk0nRzxHQQjA526M5ExP7uUfPJgmdCC1GDgv+P9N4qskW6zPSLDQrd oNaDhqFKrQCKg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6D95C69221; Sat, 10 Jan 2026 13:29:25 -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 UsTuXfVdaWMY; Sat, 10 Jan 2026 13:29:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076961; bh=Rbe8Fly0Dj/UF6Z+KGejD78R+D4tRLRd7P2NUkB6bG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FoLKVJaGVPH4ATWsrJBm0Cv+ZU2JmrlOc/3rBEfCgzJeLKZgoyBY6hmoS8MzrmGms 5GBqE2s2qNwsCuiRBkdufKYfJc5kXpkJbofnh7+QPHuhu+WhNulhz/2twwaLOirTFn VoUnSALioYH9opcfyS4eyAMh2v5BmX99Jx571zQYEXQ8iaOBJpzC5XE7vsB405xC3+ 13XB8B2wureAKjruxtSoTRVv3aRMqZX3gEQHxyteGeyNFHKNAFcWd1fEXcenmmXyKU 6VL2YZSRXEcshMIoVFVePshyAFQC9t81sBaoSfdrY6pDlnFmyUOO+5ihnZmNt7CBKW csdoS8zpYZLoA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0E7A269186; Sat, 10 Jan 2026 13:29:21 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:33 -0700 Message-ID: <20260110202906.187370-2-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: LEJDBFPWPBMRFLS7QXZGV2Q3GDKITBTZ X-Message-ID-Hash: LEJDBFPWPBMRFLS7QXZGV2Q3GDKITBTZ 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 01/26] lib: abuf: Add abuf_init_addr() helper 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 Add a helper function that combines abuf_init() and abuf_map_sysmem() into a single call. This simplifies code that needs to set up an abuf from a memory address. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- include/abuf.h | 12 ++++++++++++ lib/abuf.c | 6 ++++++ test/lib/abuf.c | 23 +++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/include/abuf.h b/include/abuf.h index 804ab0e3e57..42a80819d82 100644 --- a/include/abuf.h +++ b/include/abuf.h @@ -214,6 +214,18 @@ void abuf_init_const(struct abuf *abuf, const void *data, size_t size); */ void abuf_init_const_addr(struct abuf *abuf, ulong addr, size_t size); +/** + * abuf_init_addr() - Set up a new buffer at a given address + * + * This is similar to abuf_init_const_addr() but uses abuf_map_sysmem() + * internally. Note that the abuf is unallocated. + * + * @abuf: abuf to set up + * @addr: Address to use + * @size: Size of buffer + */ +void abuf_init_addr(struct abuf *abuf, ulong addr, size_t size); + /** * abuf_init_size() - Set up an allocated abuf * diff --git a/lib/abuf.c b/lib/abuf.c index 440f6a40023..f283f8e6e69 100644 --- a/lib/abuf.c +++ b/lib/abuf.c @@ -188,6 +188,12 @@ void abuf_init_const_addr(struct abuf *abuf, ulong addr, size_t size) { return abuf_init_const(abuf, map_sysmem(addr, size), size); } + +void abuf_init_addr(struct abuf *abuf, ulong addr, size_t size) +{ + abuf_init(abuf); + abuf_map_sysmem(abuf, addr, size); +} #endif void abuf_init_move(struct abuf *abuf, void *data, size_t size) diff --git a/test/lib/abuf.c b/test/lib/abuf.c index e97bb8b66bc..e6032998e94 100644 --- a/test/lib/abuf.c +++ b/test/lib/abuf.c @@ -91,6 +91,29 @@ static int lib_test_abuf_init_const_addr(struct unit_test_state *uts) } LIB_TEST(lib_test_abuf_init_const_addr, 0); +/* Test abuf_init_addr() */ +static int lib_test_abuf_init_addr(struct unit_test_state *uts) +{ + struct abuf buf; + ulong start; + void *ptr; + + start = ut_check_free(); + + ptr = map_sysmem(0x100, 0); + + abuf_init_addr(&buf, 0x100, 10); + ut_asserteq_ptr(ptr, buf.data); + ut_asserteq(10, buf.size); + ut_asserteq(false, buf.alloced); + + /* No memory should have been allocated */ + ut_assertok(ut_check_delta(start)); + + return 0; +} +LIB_TEST(lib_test_abuf_init_addr, 0); + /* Test abuf_map_sysmem() and abuf_addr() */ static int lib_test_abuf_map_sysmem(struct unit_test_state *uts) { From patchwork Sat Jan 10 20:28:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1448 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=1768076971; bh=Z5Ls6s3VhMnAYiKnx8c3cZgRAgoYkNov1JRDKKl0hrk=; 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=pe2M5VhTy6Y9bAF8riiwek1pNFMyLWNmH5e64RQMm7LYjLNRn4Y+24lvC5g2OTVcv /zDuroF9oKl3wxYLI9Lj6yjdTJXyIvTBLpy6L1drRLIK2G3pNOx2+bcM4dziwIQnqV AWuSZ0/tuWSj8ohHPcTF4ZPErUssKMFaOsxjkkm72f3ery6TSRgwV2d8AL8VyvNlRT kqhDAKkFLfwwlJZw/9wFX8Nj4N6d1WrrnLbiMxK9hrugIuUm/9J8C9bbCGqL48Vm/g 71YkyKxWwi7j5YAd/KUDPplZ8ILsovPSd4TAt0HkoINnGphGnP7PTu3U/xZkpe+tyn lcnsvtSFfNi8w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B11AB69296 for ; Sat, 10 Jan 2026 13:29:31 -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 JUZsCAyyG6Yh for ; Sat, 10 Jan 2026 13:29:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076971; bh=Z5Ls6s3VhMnAYiKnx8c3cZgRAgoYkNov1JRDKKl0hrk=; 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=pe2M5VhTy6Y9bAF8riiwek1pNFMyLWNmH5e64RQMm7LYjLNRn4Y+24lvC5g2OTVcv /zDuroF9oKl3wxYLI9Lj6yjdTJXyIvTBLpy6L1drRLIK2G3pNOx2+bcM4dziwIQnqV AWuSZ0/tuWSj8ohHPcTF4ZPErUssKMFaOsxjkkm72f3ery6TSRgwV2d8AL8VyvNlRT kqhDAKkFLfwwlJZw/9wFX8Nj4N6d1WrrnLbiMxK9hrugIuUm/9J8C9bbCGqL48Vm/g 71YkyKxWwi7j5YAd/KUDPplZ8ILsovPSd4TAt0HkoINnGphGnP7PTu3U/xZkpe+tyn lcnsvtSFfNi8w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A115C6928E for ; Sat, 10 Jan 2026 13:29:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076970; bh=VNteaEQI31oKdF7jQbXaOixlpNm3VRfoc9OxP3V5DIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xei7AJX0VyyS9nq5twS9mqzHka8aCLqZeCtBT+b06+M0o9s9Ct7cnVMmPYh5aFGrA HezNLYp7EmmEOH7kp5Zy7+Y/KXjqZL1qgSKJq4+gdJn9/nh5mAJGFKuGcBFt0/3rRi YsR0z0h8vIHX3seNNID6RDGdvcrz9QbdQ6p9H4xX+Rohr6TLUyw6GCzalqiIAjmGu9 h4Vcg3Imcml+Vi0nQsF2T8XKiPZgKKAJGxFRcLfl2PXAz6biVBB+NTmtUr0mj/DkTj Ts5YV6NgMbt6AOuP4g+lNnDlsUEy+xKYQzMRxprj3kBm4v1m4PfQ9v2P+MPf8iJz4k nwjsYG2YKS+gw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 215B46927E; Sat, 10 Jan 2026 13:29:30 -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 N8-B9mlzlLRp; Sat, 10 Jan 2026 13:29:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076966; bh=+gbYBtcPf8uLfc/MnRVPERkvU8kI7b2vbaVH+NLn/ec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNBzQbGc0jH8Rc5DTGg6kcsejc4KQt/tkR+Hh/MeXFzqaeVJ3AMCjCFWBzOzh7XqL y0H3RYCjPngpFBTDl6O6sMyQxfNI59IAx4edzF/GKR1PIHJqKVx4Vl5ll3gRvFOhWs s2QW+dDp8lhfOWQ23pYszWUxPyp8aOV0DI0PbrZJrUjFcDjMuen71rGVxUxTmsnQMz DiJOnmo1g61YPTuMr75gt9gmzWW6Ts5sTpiyD2X4XYcx1N5CGK3VfKLc7pDnS3t3ML rIxhcF1yciFprhzSx4QCEqhDLrfS5kVs1K2ICjD4KgBXQg32bWFugnj5M/ycY/oVXe c7i+v/cXVSLUg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B603B69186; Sat, 10 Jan 2026 13:29:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:34 -0700 Message-ID: <20260110202906.187370-3-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: 2ZU5PJFG4MRAO2E7VNMRCDDXWBB3OUPG X-Message-ID-Hash: 2ZU5PJFG4MRAO2E7VNMRCDDXWBB3OUPG 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 02/26] boot: pxe: Free bmp in pxe_menu_uninit() 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 bmp field of pxe_menu is allocated by parse_sliteral() in parse_menu() but is never freed. Add the missing free() call in pxe_menu_uninit() to prevent a memory leak. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 52032d683c3..9444effbb6a 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -985,6 +985,7 @@ void pxe_menu_uninit(struct pxe_menu *cfg) free(cfg->title); free(cfg->default_label); free(cfg->fallback_label); + free(cfg->bmp); list_for_each_safe(pos, n, &cfg->labels) { label = list_entry(pos, struct pxe_label, list); From patchwork Sat Jan 10 20:28: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: 1449 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=1768076976; bh=NU63DzlC2dUhgtf9Y8hn22pwdcIL1Y/YIgotydSs35w=; 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=LJNkhiVd0vCulm15+Z+94oD+8PlLdElEkzm2qs52J5RshnBgXUtxsh1rXZcySx9V3 SssQ4UrnJUnycuvi0YopUUOkgRvMthS4SODbzu661IM/zrEQTUa5HqhMtz1M1n8MhY Qz+0T+41vT5zM3cQHc0LsFXGtbd5Gbbm7BZSji6hqG0OZFIqGpHI17UdZPFfkcedAc o1JWzs7KRrVeP9IPA4DISrz/ySdox/psCkjpBAl54uvt3EorPh3rKKLkfOw0y9znPD 2AhbCWxESt6tjuPB1mT6j1A16Uwbjt1/JF3MMjHR/m4cpNnzQTk8L3omP4eoYG6gAB rx++0QSUVj/Jw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2C44569291 for ; Sat, 10 Jan 2026 13:29:36 -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 A3i-kiTVejUR for ; Sat, 10 Jan 2026 13:29:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076976; bh=NU63DzlC2dUhgtf9Y8hn22pwdcIL1Y/YIgotydSs35w=; 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=LJNkhiVd0vCulm15+Z+94oD+8PlLdElEkzm2qs52J5RshnBgXUtxsh1rXZcySx9V3 SssQ4UrnJUnycuvi0YopUUOkgRvMthS4SODbzu661IM/zrEQTUa5HqhMtz1M1n8MhY Qz+0T+41vT5zM3cQHc0LsFXGtbd5Gbbm7BZSji6hqG0OZFIqGpHI17UdZPFfkcedAc o1JWzs7KRrVeP9IPA4DISrz/ySdox/psCkjpBAl54uvt3EorPh3rKKLkfOw0y9znPD 2AhbCWxESt6tjuPB1mT6j1A16Uwbjt1/JF3MMjHR/m4cpNnzQTk8L3omP4eoYG6gAB rx++0QSUVj/Jw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1BD0F6928E for ; Sat, 10 Jan 2026 13:29:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076974; bh=WNUqBkxpq6EzqWkWj2R6kypqGuRhBAthrbgrrAAOy1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IEgFlHPZmxDBE8K/+VofNiZvjDZlz7ANuCeyHriKQdXxWkuKu7CeMJ6wEcEEbY3Yo PLkedQ39vNoACar0uFhuRZU/uZ410ZJU8W623ATRVxYM9TlLGTw1/Doa98asjor7+0 6HVpLvJj102j3QPdNUPZ0yJzScAuaBgj24g3lMA+dgYUH4zjzZRgO78HBKy+NqmUpz P/hcXSLwWF1BaUjPdutsEJXVWqHI1H9j9D4yRjbFDAPPZSPjdjuykjK9sjg3YnVi7v ZQi64Q5C9pW0VnsXGs62Swzb36+91psjvDCU3xXlxoVV0L0rdQw7NzErlbXj5n+/F0 3Fjm8FDZVidyQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D08826927E; Sat, 10 Jan 2026 13:29:34 -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-sFZejUFf6U; Sat, 10 Jan 2026 13:29:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076970; bh=MuswaGNNSK1TeA4fn8bkYzLC49X4DbpeNDQvpB/8HSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w6W5RzXSZPhFANkpqBlFtsE+ssEo0iQ5yxI6UP/GPKFLkvkgPiW8An6uAD12+2HLE rnxg+umXXMT9v44/1VEIDEaf0CUKqV2N/18eLKlwLrWuJ9NVHWho2Sr5dGF3JmcIKb T9vZu7RJvlGGtQCzCS6cN0JD8DmSDOB5PzpXSexW8SwspwlhUt1AKf4BM74pjEtSid FhN949Jp0rIeO/+LZH7d9GY3MtM5bfuixZvLAdydweAmg9+tuG+gOow6BRgX1Yg6j6 ZP8Gx0FSu7f7jRZRneHk6AnkiAmGCyocv852uEN+hviKQalvojKStsu/gQ4Jx82mr+ RhmTAXf/Fxhsg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6D21669186; Sat, 10 Jan 2026 13:29:30 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:35 -0700 Message-ID: <20260110202906.187370-4-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: SOLHVAMLW7SLWFK3HJHYQ6HXQKC2ZHQS X-Message-ID-Hash: SOLHVAMLW7SLWFK3HJHYQ6HXQKC2ZHQS 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 03/26] boot: pxe: Fix token memory leaks in parser 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 get_token() function allocates memory for t.val when parsing keywords and string literals, but callers do not free this memory. Fix this by: - Initialising t.val to NULL in get_token() so free() is safe for T_EOL/T_EOF tokens which do not allocate - Adding free(t.val) calls in parse_menu(), parse_label_menu(), parse_label(), and parse_pxefile_top() after token processing Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 6d148756b0d..8c720db5e75 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -232,6 +232,7 @@ static void get_token(char **p, struct token *t, enum lex_state state) char *c = *p; t->type = T_INVALID; + t->val = NULL; /* eat non EOL whitespace */ while (isblank(*c)) @@ -418,6 +419,7 @@ static int parse_menu(struct pxe_context *ctx, char **c, struct pxe_menu *cfg, char *s = *c; int err = 0; + t.val = NULL; get_token(c, &t, L_KEYWORD); switch (t.type) { @@ -434,6 +436,7 @@ static int parse_menu(struct pxe_context *ctx, char **c, struct pxe_menu *cfg, printf("Ignoring malformed menu command: %.*s\n", (int)(*c - s), s); } + free(t.val); if (err < 0) return err; @@ -452,6 +455,7 @@ static int parse_label_menu(char **c, struct pxe_menu *cfg, char *s; s = *c; + t.val = NULL; get_token(c, &t, L_KEYWORD); switch (t.type) { @@ -471,6 +475,7 @@ static int parse_label_menu(char **c, struct pxe_menu *cfg, (int)(*c - s), s); } + free(t.val); eol_or_eof(c); return 0; @@ -534,8 +539,10 @@ static int parse_label(char **c, struct pxe_menu *cfg) } list_add_tail(&label->list, &cfg->labels); + t.val = NULL; while (1) { s = *c; + free(t.val); get_token(c, &t, L_KEYWORD); err = 0; @@ -595,8 +602,10 @@ static int parse_label(char **c, struct pxe_menu *cfg) if (p) { label->say = strndup(*c + 1, p - *c - 1); - if (!label->say) + if (!label->say) { + free(t.val); return -ENOMEM; + } *c = p; } break; @@ -608,11 +617,14 @@ static int parse_label(char **c, struct pxe_menu *cfg) * something for the menu level context to handle. */ *c = s; + free(t.val); return 1; } - if (err < 0) + if (err < 0) { + free(t.val); return err; + } } } @@ -637,8 +649,10 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, ulong base, return -EMLINK; } + t.val = NULL; while (1) { s = p; + free(t.val); get_token(&p, &t, L_KEYWORD); err = 0; @@ -686,6 +700,7 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, ulong base, case T_EOL: break; case T_EOF: + free(t.val); return 1; default: printf("Ignoring unknown command: %.*s\n", @@ -693,7 +708,9 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, ulong base, eol_or_eof(&p); } - if (err < 0) + if (err < 0) { + free(t.val); return err; + } } } From patchwork Sat Jan 10 20:28:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1450 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=1768076982; bh=alqbKcYW68anGXjzNMxW5rxAYJY6bv8WHTdxO1HL9GQ=; 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=n/QDalMsADLxDJzAD3rAV2g46vIO1kIntE6sg1qdlbU8L7Rj8u4MGxWwr6lQS36p3 Txrtf9nX3FTq4BuWD65WTLdljKsnJslBLIYMu5e9dsrPFf41D/NvW401mTtQGA56/D pwaYOH2m09AWGFGAnxMi+6ncqtHimxGAUOWjPuyqcEkOWq3mtbbvD2SmxRJVlAhorN H2vkKspqXVSCso3aSpIpp/wkPJfUP0+mW2TK6PpsXdLIfSBg0fe/ku2YpPSdRU2qHy NFgaB5EOL9eXNi/E1hvOFwDvf0wlkT6N3s3QNK2tTn1ALT+4M+ivdovkhsGc2mZHZ6 j0zD6nMx8Ag5g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 181DE69291 for ; Sat, 10 Jan 2026 13:29:42 -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 PJYvbYguR8o4 for ; Sat, 10 Jan 2026 13:29:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076982; bh=alqbKcYW68anGXjzNMxW5rxAYJY6bv8WHTdxO1HL9GQ=; 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=n/QDalMsADLxDJzAD3rAV2g46vIO1kIntE6sg1qdlbU8L7Rj8u4MGxWwr6lQS36p3 Txrtf9nX3FTq4BuWD65WTLdljKsnJslBLIYMu5e9dsrPFf41D/NvW401mTtQGA56/D pwaYOH2m09AWGFGAnxMi+6ncqtHimxGAUOWjPuyqcEkOWq3mtbbvD2SmxRJVlAhorN H2vkKspqXVSCso3aSpIpp/wkPJfUP0+mW2TK6PpsXdLIfSBg0fe/ku2YpPSdRU2qHy NFgaB5EOL9eXNi/E1hvOFwDvf0wlkT6N3s3QNK2tTn1ALT+4M+ivdovkhsGc2mZHZ6 j0zD6nMx8Ag5g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0624C69281 for ; Sat, 10 Jan 2026 13:29:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076979; bh=UTTgChXt1KvjFlM8sUDPQR8W8oMLFjAcmmQh+RiSSTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tXVAbkp0/ktt9fBL6tfWFF7bkvUyWlFyHA+AHka8llx5ablgHGqXWRLzHp19h6NO8 m+LlBPVDhMP5C1qtgkudBgAVqxCZJRUgbOZ1m8C7dUeyI5GNKXE75bwA6VR7oYtwWY WMkG7Uzj1pyxuFzM+IZCucaSPwUq9Ir0+gPdOJy+BiEf3BLpINpV++9RSbyDG+OIh7 VFd5NHEigz5KB7uTa+yRcaEW/CTj0Sxs8bxNyO6urT1rOFvQu1bwLfJkco71/d7fP5 BFsGrJNsT7MLRrz9kTjNXEVjj5p75STnQS1jGjUWSJGBX9CzMf8MljRvkc0Wp83osf tZvrdDLrLP9AA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8606B6927E; Sat, 10 Jan 2026 13:29: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 10026) with ESMTP id BmgkcWeJh4LM; Sat, 10 Jan 2026 13:29:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076975; bh=3pYdJC3b6+Ta/2MFwIxjPBqsxD9NWuKEajKSdrc9pBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LgZncEKFMLQ8zly4GBaQS1X+F1Y5KPHCq/XUEeHqaNhnI7wCPYx4tpMF3fx1Dgdxn Td99hqi/qXKV7fWvZZuzMmAqGnOQMBOt21bLBSCYKi7HH41TrTPbkqBfMq0Q9DTpKO cPmgXARQHORSACPvCXq8XoKKBItEO0mnwQrkjXGTwU7NmRjVydApYGdEaUtBMWFr7Z INfb4Af2TLlJKz5QTe2okutM6vUZV8CJL+KOCsxMtBpXcb9sI3gjldU++2KtRYEQ7o xC1SdICT8ujO6viAXzByCG7rffbhHlxrAKD0kG4HqHb1eAW5BQVRcmlc6dFlfNHey4 OVOX9TljgInaA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 23F1669186; Sat, 10 Jan 2026 13:29:35 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:36 -0700 Message-ID: <20260110202906.187370-5-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: 7CFFQX5FDK736VNVOQ4JLYUXKCA6OP24 X-Message-ID-Hash: 7CFFQX5FDK736VNVOQ4JLYUXKCA6OP24 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 04/26] boot: pxe: Free menu label in label_destroy() 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 menu field of pxe_label is allocated by parse_sliteral() in parse_label_menu() but is never freed. Add the missing free() call in label_destroy() to prevent a memory leak. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 8c720db5e75..e5af05d4120 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -116,6 +116,7 @@ void label_destroy(struct pxe_label *label) struct pxe_fdtoverlay *overlay; free(label->name); + free(label->menu); free(label->kernel_label); free(label->kernel); free(label->config); From patchwork Sat Jan 10 20:28: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: 1451 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=1768076986; bh=CF8Sf3nUHPPWtOtARNwP40iiMMAU8M0LgTGR7ISUfPA=; 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=PDPPtSNaXpNNPvKSobE6vEpDobxH7a9b1LPFxW+o4m7uC30rwaQsppiMUa2jlHL/Y /Wn1umCXrExpNdnN8Otz6wB2lq0s+KpE5G6nCTW7Cw8BIq/hdmqtlSB6JWWX7sW9SX bWwvPxAvhuCgcnWqC0MPGBuQkXhwggLe08XkG1aTupyarfyEcEfeuLGaHykp2rkzEa eHvMWcLek+rX/QJYLkR1YzA0epB1Jqn9q4cpJsRRS0hU8vZlFyIHVM2qPHym9+N3Q8 4j9Nu+MlkfmzLZdtcMdI1Pj86cEb5g50moCDyrDzIg5cQ7qDfCZAVzKbibhjSEqQ6+ 6BS+Ld5G0UOBQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8DA8569291 for ; Sat, 10 Jan 2026 13:29:46 -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 I6HJ0C9rDLC1 for ; Sat, 10 Jan 2026 13:29:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076986; bh=CF8Sf3nUHPPWtOtARNwP40iiMMAU8M0LgTGR7ISUfPA=; 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=PDPPtSNaXpNNPvKSobE6vEpDobxH7a9b1LPFxW+o4m7uC30rwaQsppiMUa2jlHL/Y /Wn1umCXrExpNdnN8Otz6wB2lq0s+KpE5G6nCTW7Cw8BIq/hdmqtlSB6JWWX7sW9SX bWwvPxAvhuCgcnWqC0MPGBuQkXhwggLe08XkG1aTupyarfyEcEfeuLGaHykp2rkzEa eHvMWcLek+rX/QJYLkR1YzA0epB1Jqn9q4cpJsRRS0hU8vZlFyIHVM2qPHym9+N3Q8 4j9Nu+MlkfmzLZdtcMdI1Pj86cEb5g50moCDyrDzIg5cQ7qDfCZAVzKbibhjSEqQ6+ 6BS+Ld5G0UOBQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7BD3A69281 for ; Sat, 10 Jan 2026 13:29:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076984; bh=wmFepeOcu8V2jmwvasn5OGY45Xys/tApu+COkSPYBLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EQIyGfkkRqdzsH5Pp/1mjgFAtQAuqxLL/f+OIWTykZAwOXoPJEENmJpDjMmlfIOkN 8ppHGf0cyN2jJ3S7Vcs6o/KsciHaZoIV8fF7cWgLRsSEcHJ7qTNEx+lEhyLM/nwK5q Y3Ocz5h/VdSGDOsrOcK52aZX4vR0kB5tb/g5A3AmYUKfpNZcuYgA1/qAnCBSWMAV+U lTPAp34RONQwsyFjJJUOY1ROifSLf95aVVt+qY07xE4+jPg35xmfnSM/tAZsyYoXnD FGbUwtfGmFrW16lF3/tS08dYh4VPAqaQu+WM5+X4V2rsqxL9jvmFE/fWAncOuZ0utL j3Enp3YGYUd6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C38769281; Sat, 10 Jan 2026 13:29:44 -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 1NykMFLMjoy9; Sat, 10 Jan 2026 13:29:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076980; bh=jHBLx8LVwseYMVgofBq64jj7uitZNP8jf84jV0zZd5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AkctMjbxXN7nQxqKTNN+RFsui54qh0McNQrE2t89mHkwMjWWoSSVs3EubvVSebvHH +jfkFbkAJ6Ix1VpiT8iqUULPuIV7lmNNd1gglAYxIj9uQ3gIUJu/mS/VEitH8sB+TV bdlp55gcpdnphAR4JOZ/7Y9DIZQEr++QBKYPUIfmGmQzpFJFEjGuiexaYEU5iMtmgz mCPByyd34hL+PpdNY0UmOKvpgJVmv6O0OxoL/4m5FL3tqC4wPmGaQ9Dl+h7tid4UWj cKq4AykRwxhWyZmrlkGrEgfiV1NW7/yvx9m6EL1XIt7XWWCJJQJgxFwSMOyE6RdSHJ Qk4dCp108yRUg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C7BDF69186; Sat, 10 Jan 2026 13:29:39 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:37 -0700 Message-ID: <20260110202906.187370-6-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: 3HQ4PYEUTYPSMV56QMHF4QXNSEVMCL4A X-Message-ID-Hash: 3HQ4PYEUTYPSMV56QMHF4QXNSEVMCL4A 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 05/26] boot: pxe: Fix memory leak in parse_fdtoverlays() 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_sliteral() call allocates a string for val, but it is never freed after parsing the overlay paths. Each path is duplicated by strndup/strdup, so the original string can be freed. Save the original pointer and free it on exit and error paths. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index e5af05d4120..f6b7887f603 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -317,12 +317,13 @@ static int parse_sliteral(char **c, char **dst) */ static int parse_fdtoverlays(char **c, struct alist *overlays) { - char *val; + char *val, *start; int err; err = parse_sliteral(c, &val); if (err < 0) return err; + start = val; while (*val) { struct pxe_fdtoverlay item; @@ -348,10 +349,13 @@ static int parse_fdtoverlays(char **c, struct alist *overlays) if (!item.path || !alist_add(overlays, item)) { free(item.path); + free(start); return -ENOMEM; } } + free(start); + return 1; } From patchwork Sat Jan 10 20:28:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1452 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=1768076991; bh=WUKplOR4Ao5Oshhx/7Jd0OlB0IazMc8e68nHqAh9x+I=; 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=BoaOsX7dDjDLu/iODhGFhstUWgHz35y+DNpaQ7jkCmKOu8skV7hws+NYBGaOuDd8x jx7zb2d/oml8yxZGYZRDlljoHHPt0uThL46oXf9gXrAHJPreSJ/Da1N24Q8TovLQ7Q qhE9cjH95FdfTKJXZuqwOrfmBRYi5c58NGDuHf09oMQpUNAKIkwoTI16pEyiEPk15a EjBFWqnJUZNku9n6rDLqTRuohd2OLyS297gBIhz28TbtR3EotV0fueTV+wUdavma3g +28t5pVsssy4f0lee5cXKdP5VE56ihfZVcQarn8fqejtWZW4z1bjpqf028VcXqqQjT 3Tl5ZdJcW3Emg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 03B7769291 for ; Sat, 10 Jan 2026 13:29:51 -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 5i9TcOQXbpcT for ; Sat, 10 Jan 2026 13:29:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076990; bh=WUKplOR4Ao5Oshhx/7Jd0OlB0IazMc8e68nHqAh9x+I=; 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=Nk855ToNFKbxW1RMYFqERp/KLAGz9M5pOMH9k18FbO2wC/DHTcbHtyAjWSZbN2eaa g+sEHOvdpFWi5n7gXt+m2qmsEFsAxhlWxi6HBQamVtPiq3ueGdbd1V9xjt/2IIZeC5 g2N4n92bVxm524OSkME6m3iLfBLxSQ/819rW4XdrySMsOnBkiir80/Hc3HQVNlNGwU Ci9na5bIRmDalufd0Ig3rFGF1XnEf/RG9K6q00JQigqJORSEPT38eVoVO/MKIz0FT8 SN7MRSoN9dunvcVFT45M30E3z+viu6cQCvPylqrPjcURlC6TgiizJbZoqVX4SgtmoJ vm+vZ3osRRgeQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E348F69281 for ; Sat, 10 Jan 2026 13:29:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076988; bh=8pOqCJK5mBONuhlSyhQkPgZZnUT9dLJVLyRVo2+VC7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AtTiUWD19IJ9rdBabL45Rz/ytYAYailW08FJ8ZcqwAUlqI3XjUGiphYulRvsaoZAd PcOPhOUJV1n4UoTMRrsPEPUH8ZlJoB5VXOthbkNczn8INyKJDBTzm2WhFYBEE6H9Vd P8VvnoBBXcLN8RLJZucqTcY+mrps6HoA+sZLL86ChMPPxyqKGlMnaRhvHcydo7f8XI t6Glnx1T778arqUBpyKDPcsQHjc00Swwhkl7hFtlXG7saWKmS7PTrnzk7ROwqMDkWL VERg4wILhA7JrWvBztKwCkQcQs1PuJl4LXaGOAVnMvYSpXJZ+WZ0vT+cVX+5d4o00d +PjMLm7c3/f/g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DF2E869186; Sat, 10 Jan 2026 13:29:48 -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 fV2y1yQpA38M; Sat, 10 Jan 2026 13:29:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076984; bh=vCHtCFJBjhZHg49apV6IgEce9NcseyGNaPrqiF6+vEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZagjuLdStHUa1UKIj4zkAu7zsfykim535y62MOJmlgfsGDJtLvhc3IggFI3PVk0QN y6Ouo6BBvg854afAx6ikLAUGazSR4xC3xtylUMGNsQdNtMZOFTF9Nk5jekqZ0JK9O6 hQ/4BmZRZFTAQOOkl7fWvbRhM6JNzFDyM0Wl0mj0HDZkPLi72Bz2fAf+LAR7B6BAN1 hwS9zdEoOaHOOS4PBnCnIKeeA723qTr+fmlxejMH5sAgMXP66ti52UGe1FvOnCgKrc SgfnyCuErMTqnCxvm++RJGGSYX3SrACIqgh/9OaMy1o6fb0ByaHA24gurTu7KvDDut 03QIBkuv3RSKg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 70D756927E; Sat, 10 Jan 2026 13:29:44 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:38 -0700 Message-ID: <20260110202906.187370-7-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: LFXV2L4QPF2NYRJBEZRD7LRIVF6NRCLR X-Message-ID-Hash: LFXV2L4QPF2NYRJBEZRD7LRIVF6NRCLR 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 06/26] boot: pxe: Make pxe_prepare() static and document it 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 This function is only used within pxe_utils.c so make it static. Add documentation while we are here. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 9444effbb6a..b55d736beb8 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1282,8 +1282,18 @@ void pxe_destroy_ctx(struct pxe_context *ctx) free(ctx->bootdir); } -struct pxe_menu *pxe_prepare(struct pxe_context *ctx, ulong pxefile_addr_r, - bool prompt) +/** + * pxe_prepare() - Prepare a PXE menu by parsing and processing includes + * + * Parses the PXE config file and processes any include directives. + * + * @ctx: PXE context + * @pxefile_addr_r: Address where config file is loaded + * @prompt: true to force the menu prompt + * Return: Parsed menu on success, NULL on error + */ +static struct pxe_menu *pxe_prepare(struct pxe_context *ctx, + ulong pxefile_addr_r, bool prompt) { struct pxe_menu *cfg; int ret; From patchwork Sat Jan 10 20:28:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1453 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=1768076996; bh=jiFd77DZXBzF521tvdwOoJorEW4/nwqkKuBM1vdqabo=; 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=j2ZZ8M5WBpvpkKcqlrx8CUBAvQGUxzuLyRukA/SS21WLZJ6KXAnCoKHlJ3Rbf+T5T IcsRXkiaZQp4A+u0deEAN2k8BLHGsfzoxtvYBzP3+30tD6wa8r4RjJO5DvGLCHRj4c 0ipaDxXvu7ajZIB76YeefiG7sE38tza2qNqnNvT0grqpBa4z8atulLPzqu0YyDYC2e aSgzpFdN1kQySMyY4oyJOLuLgsBN4PNrci0AkFX+YUS7b89tjrHOg4dNrH+DKTjS6P vZw6BjCD4KEVN6MrCDPDXDt5xiCR9NGb0+hpXo//zcemlu+yH01C7i2KSAQ8Axt6wK BRVAquCWHQ8Jw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 648F169291 for ; Sat, 10 Jan 2026 13:29:56 -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 VkMyeOGYncFp for ; Sat, 10 Jan 2026 13:29:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076996; bh=jiFd77DZXBzF521tvdwOoJorEW4/nwqkKuBM1vdqabo=; 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=j2ZZ8M5WBpvpkKcqlrx8CUBAvQGUxzuLyRukA/SS21WLZJ6KXAnCoKHlJ3Rbf+T5T IcsRXkiaZQp4A+u0deEAN2k8BLHGsfzoxtvYBzP3+30tD6wa8r4RjJO5DvGLCHRj4c 0ipaDxXvu7ajZIB76YeefiG7sE38tza2qNqnNvT0grqpBa4z8atulLPzqu0YyDYC2e aSgzpFdN1kQySMyY4oyJOLuLgsBN4PNrci0AkFX+YUS7b89tjrHOg4dNrH+DKTjS6P vZw6BjCD4KEVN6MrCDPDXDt5xiCR9NGb0+hpXo//zcemlu+yH01C7i2KSAQ8Axt6wK BRVAquCWHQ8Jw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 54CD369281 for ; Sat, 10 Jan 2026 13:29:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076993; bh=j7knzbEoRTTqQh7yb6kuV9hiZ3XCGozElkVaCVuosF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z3FsFJsEz9ta78Tj4xjsmQR/8YZlZwEhMQdn6CP++3ElEAMfY27f+PQCl96CRbo8B PJ9m4DbHv/T8pS5i+9eoq9Kmuiy3XtBxatgOQSzg0t/sfEt0NPwfRCIKYYbW/6TpEa zNNJ56qkiWJavsTQ3I9UIdgb+Gq9vIsPUxYCVMibj2uMyamK63yoc5shdXW4QnWb1j NOGJoyqvW2fDGy7JTtXXcjHwE5KzWD3EowkMJlm+atQyHQLf72VAORgnmkPhck6ju/ LDy3D8kxPYQnlNcaez4DVKVu+TW4cGnJTvF7TAZYsuXKeSmTO2ps2ROqpv/CBYQdqF Th0myeAn1qjnw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9568B69186; Sat, 10 Jan 2026 13:29:53 -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 MmKf8HZ4cKcY; Sat, 10 Jan 2026 13:29:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076989; bh=IWSgUaE0NZEyGcp/U+TyrcyqllErGds+o9Lx/MEVe0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KR19NACn0IL7Log4/DfNBciYe/CtY3/3aKJ3JMM0vFLKlhebjsuKQzbDqA9+mSJh7 kScfF9EiwVhh3IgWWUbdmLA5n7LOiCwQBS+p1EwOV0NzLQuqkAsBwUwqlCwUPbSa8t bq7kQR/+ARp24n/ThiKD3AAP7kfv9A21CBNjPZvDnO2qYuVrjShDCiSJuSoUw200Lr YoTLXyElziu0/HzJdvZHZIpcEYxOqk+dyJRQuhyj7Vh7qkZ5aX5cHfVxu7oygX4Uds pVmUC9fBBxRZQt83ARKs1LBD3Cs1JJQ1S+fVsBaTAOVRam/IK6fGaC6xm5CQLiNL/4 0vQSxzCratPAg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2D2836927E; Sat, 10 Jan 2026 13:29:49 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:39 -0700 Message-ID: <20260110202906.187370-8-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: OFDNMV2DVDBP3IWWYYFY6Q6XRUDOVLBP X-Message-ID-Hash: OFDNMV2DVDBP3IWWYYFY6Q6XRUDOVLBP 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 07/26] boot: pxe: Simplify pxe_parse_include() to take only address 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 Change pxe_parse_include() to take just the memory address instead of both a buffer pointer and address. The function now calls map_sysmem() internally to get the buffer, simplifying the caller interface. Move the function to the bottom of the header file while we are here, since it will form part of the new API. Also mark 'inc' const since it is not used. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 18 +++++++++++------- include/pxe_utils.h | 31 +++++++++++++++---------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index b55d736beb8..384a4e4f8ab 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1035,7 +1035,6 @@ int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, ulong base) { struct pxe_include *inc; - char *buf; uint i; int r; @@ -1053,9 +1052,7 @@ int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, return r; } - buf = map_sysmem(base, 0); - r = pxe_parse_include(ctx, inc, buf, base); - unmap_sysmem(buf); + r = pxe_parse_include(ctx, inc, base); if (r < 0) return r; @@ -1064,10 +1061,17 @@ int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, return 0; } -int pxe_parse_include(struct pxe_context *ctx, struct pxe_include *inc, - char *buf, ulong base) +int pxe_parse_include(struct pxe_context *ctx, const struct pxe_include *inc, + ulong addr) { - return parse_pxefile_top(ctx, buf, base, inc->cfg, inc->nest_level); + char *buf; + int ret; + + buf = map_sysmem(addr, 0); + ret = parse_pxefile_top(ctx, buf, addr, inc->cfg, inc->nest_level); + unmap_sysmem(buf); + + return ret; } /* diff --git a/include/pxe_utils.h b/include/pxe_utils.h index a03e00e2a4a..f6ee0417a9b 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -299,22 +299,6 @@ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, ulong menucfg); int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, ulong base); -/** - * pxe_parse_include() - Parse an included file into its target menu - * - * After loading an include file referenced in cfg->includes, call this - * to parse it and merge any labels into the target menu. This may add - * more entries to cfg->includes if the included file has its own includes. - * - * @ctx: PXE context - * @inc: Include info with path and target menu - * @buf: Buffer containing the included file content - * @base: Memory address where buf is located - * Return: 1 on success, -ve on error - */ -int pxe_parse_include(struct pxe_context *ctx, struct pxe_include *inc, - char *buf, ulong base); - /** * format_mac_pxe() - Convert a MAC address to PXE format * @@ -512,4 +496,19 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, ulong base, */ void label_destroy(struct pxe_label *label); +/** + * pxe_parse_include() - Parse an included file into its target menu + * + * After loading an include file referenced in cfg->includes, call this + * to parse it and merge any labels into the target menu. This may add + * more entries to cfg->includes if the included file has its own includes. + * + * @ctx: PXE context + * @inc: Include info with path and target menu + * @addr: Memory address where file is located + * Return: 1 on success, -ve on error + */ +int pxe_parse_include(struct pxe_context *ctx, const struct pxe_include *inc, + ulong addr); + #endif /* __PXE_UTILS_H */ From patchwork Sat Jan 10 20:28:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1454 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=1768077001; bh=/VON7Y6XKqm0HTcC+P7owMoySj+FrJYYU6dddtd1GqA=; 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=TYw5aHPnEIR0+X6bGVRIhzuE1zTeBA3wWqnYtSPScMV86igDux5U/RLn4cEVgfOlA tAyPadjuOiHN4lhJr2xBCGU745ESPjeiaq/lLqUg6bY01sB8ahEJi8K095pv4gQlqc bJyzOiidoBKZEeuD6LZ9cmf2CkwgynqPfGHXt6pCn6LpU0BEYla/NiMFjOZKDsT81X HrA0FQNuVpH0HngbrNuq+a88U5PhBtQqsxYRZjUaL17JRhNpqLdqceuFnq3zxt3bq6 Cg9eYWKnrCr5DE20xEqfzdB0maXgtg8+yl7V17RhEnucA7CN4d/f4xzi/t6ix716K3 Or21l/QtPGGhg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0875E69291 for ; Sat, 10 Jan 2026 13:30:01 -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 T6uy2ZUatHP4 for ; Sat, 10 Jan 2026 13:30:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077000; bh=/VON7Y6XKqm0HTcC+P7owMoySj+FrJYYU6dddtd1GqA=; 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=QMoLRMsV39GXGZPXNN+x9oyczm/DdfhSqktS9KHX1izGt2pbFqWcpXtbJb4NtlS5L HZnvPL0cZpNWuVuBa9zdGJJdnaJcA3kPfokvMODVsEbto/c9jll2UOTA4b8NLQRlP8 wVoDwqzwOBTn1Kttmx+9iqDLZkKK0DtfNiODns6any9Okh3wBjQQpic6dvSy6XmkNX Lpe29t9PZz0a8caJRvcwK/xTg2MRs1iyFUYwD6w/yJYFTp+YyuaGL4eHEznzY+jBVG GPXcJbg+/aW4BmIQbifjlGIk4KAjz8EofBtzaru6vs3Sp4XJdt6fyUOzpvF9LlxDtG eLj6R90alkK2A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EB2226927E for ; Sat, 10 Jan 2026 13:30:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076998; bh=pp7/XmwgKhyTPHIjRi8uQPEE1DnBLK3CVfH4XdaIc1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjIiTFyPpdQE6C36cJZv6J2Iqw5iN5mcDfZ2iZV0YBO6ZMd5Z1VHO+qbxTGFLDDGN F3dHebb/Oj8YCPkhfeoUX/C4XgnlpTH09KiwijRvcUqBxXMo78MO8+zotxyDbAUPyT y8jF8bRxOmt9KjOvVDvnYq50ymhWiqxM9X/e4MZrq2TI3fiRJPs/q67dW1tWkVhbJY GR4G0WBq1hxsnbWQC0mSeEG+M64MFdx4/vj79GyKq3pNISJogUrQXj+667zPa92oW0 DlEIgs6KBwzI3NXPn9EA7QJtBREwsqc4jcglHCmU5v/sRVA0ptMetaASdpdSdKqFm0 ghvqGkpsUX7zA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C18E969281; Sat, 10 Jan 2026 13:29:58 -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 Tvy5_jFRaPTb; Sat, 10 Jan 2026 13:29:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076994; bh=fqJ2PWl2cn0eDlj3WjPYrKXQKM75ycGzXBdbpjPJOZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VrZkmnZBfrCFs+cbzfVGrCts7XWvfmae92Hs/Uoucv3eoAjIsqMM6PwIZtbvkXnQR IBqLH4Y/QCorvjh5thMuCHKB2RfEOO2RdqTkNacAwYcAdklkXAGQwS6NNNeAueV7mV eEhFIHIumIbZIB4ZYB4KMtfqlgsMkP2gLjDoeY2RRsLhO9Y2b2O1m6ylL3ri2hkZ7f 8ycOnIwR3YB6iGUAJ7I6QBXplLfX4GkBFbWfM8QlzYcUOrjnSoBx8edJcG63MKpzxw H+VxTQPITBtgkpMVlE7kibnrKZIm++Kg9o0JW0BssE59zBQ2BbReL++JwWhes+rvxS Z4YO4H/5Otc1g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D5DF46927E; Sat, 10 Jan 2026 13:29:53 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:40 -0700 Message-ID: <20260110202906.187370-9-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: GGGORAAT3J4JZD4UAACDONHDJWQM52FB X-Message-ID-Hash: GGGORAAT3J4JZD4UAACDONHDJWQM52FB 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 08/26] boot: pxe: Add struct pxe_file for file loading 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 Add a struct to hold information about files that need to be loaded for PXE boot. This allows the caller to load files without using callbacks, similar to how include files are handled. The new struct pxe_file contains: - path: file path to load - type: file type (kernel, initrd, fdt, fdtoverlay) - addr: address where file was loaded (filled by caller) - size: size of loaded file (filled by caller) Also add a files alist to pxe_label to hold the list of files needed for booting that label. For now this is unused. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- include/pxe_utils.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/pxe_utils.h b/include/pxe_utils.h index f6ee0417a9b..2f194b91683 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -51,6 +51,7 @@ struct pxe_fdtoverlay { * @fdt: path to FDT to use * @fdtdir: path to FDT directory to use * @fdtoverlays: list of FDT overlays to apply (alist of struct pxe_fdtoverlay) + * @files: list of files to load (alist of struct pxe_file) * @say: message to print when this label is selected for booting * @ipappend: flags for appending IP address (0x1) and MAC address (0x3) * @attempted: 0 if we haven't tried to boot this label, 1 if we have @@ -71,6 +72,7 @@ struct pxe_label { char *fdt; char *fdtdir; struct alist fdtoverlays; + struct alist files; char *say; int ipappend; int attempted; @@ -93,6 +95,36 @@ struct pxe_include { int nest_level; }; +/** + * enum pxe_file_type_t - type of file to load for PXE boot + * + * @PFT_KERNEL: Kernel image + * @PFT_INITRD: Initial ramdisk + * @PFT_FDT: Flattened device tree + * @PFT_FDTOVERLAY: Device tree overlay + */ +enum pxe_file_type_t { + PFT_KERNEL, + PFT_INITRD, + PFT_FDT, + PFT_FDTOVERLAY, +}; + +/** + * struct pxe_file - a file that needs to be loaded + * + * @path: Path to the file + * @type: Type of file (kernel, initrd, etc.) + * @addr: Address where file was loaded (filled by caller) + * @size: Size of loaded file (filled by caller) + */ +struct pxe_file { + char *path; + enum pxe_file_type_t type; + ulong addr; + ulong size; +}; + /* * Describes a pxe menu as given via pxe files. * From patchwork Sat Jan 10 20:28:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1455 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=1768077005; bh=JFXwrxke57U3S/RYGwKVsLp1Q6pWSF0WGg2CgS95bfE=; 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=QeOBvkuvazcngJOEwvv1RO8rt+A2q95qx1u8wb8sdFH4YgOwgWdw1vwq3a/HeNy5b AjWXw88iZAqxJmLqIXhoLM9x3+z2ZjG8JrfsvK48TzNXGl2OJuJ8exuoFJ9CwFxHjb gUMVPeAS5o1bbkpq8kJmikEpfNBeAk1OrRVl2rHMUX3ptsYAmvPSetkxz2N2tdB+xY gcEMbAKQPnjB6DFyT0P00DorVQCfAJtrqjfHRcHnEzG2rd4pyE21I7XaKCbbAMmMIT tSuzTV+wz7GW9t0LGXgu/lvbKMSMUXuU9OVlRtuhnvejXOnUBcS3MsE4XSFVcw0hw4 HH7+TvEb/Np6g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9809969299 for ; Sat, 10 Jan 2026 13:30:05 -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 UBJHRKeLEcBw for ; Sat, 10 Jan 2026 13:30:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077005; bh=JFXwrxke57U3S/RYGwKVsLp1Q6pWSF0WGg2CgS95bfE=; 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=QeOBvkuvazcngJOEwvv1RO8rt+A2q95qx1u8wb8sdFH4YgOwgWdw1vwq3a/HeNy5b AjWXw88iZAqxJmLqIXhoLM9x3+z2ZjG8JrfsvK48TzNXGl2OJuJ8exuoFJ9CwFxHjb gUMVPeAS5o1bbkpq8kJmikEpfNBeAk1OrRVl2rHMUX3ptsYAmvPSetkxz2N2tdB+xY gcEMbAKQPnjB6DFyT0P00DorVQCfAJtrqjfHRcHnEzG2rd4pyE21I7XaKCbbAMmMIT tSuzTV+wz7GW9t0LGXgu/lvbKMSMUXuU9OVlRtuhnvejXOnUBcS3MsE4XSFVcw0hw4 HH7+TvEb/Np6g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6C27C69290 for ; Sat, 10 Jan 2026 13:30:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077003; bh=izzoFRI0KAKm7agn9h2p7sB8hWex0BCEnjCZrH93Lzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0mytBrGS/sczQIt+fFeqKfrKm/b8uUaB8GH+rc1DqonVyer/d/e29b/uXbWxutgj Y0eWHuTOkYFqIt1fD/akmSJ0a6YfLtAyCEC8kpGHdD/6nu8Bu+NJl0NlEsE5t/zX43 w9IxXRRxzLqiIEF4BZm6zQrISDSpJT4PxrYQtjHeang8SHJy228Kjj6Cr3dI07PiDU 9KxZt+ORltbbTsG5zE+ttOZolhqqNhfDWer8MbNtf+SokKdLkKYab4gwH3eJeLNklr 6yJme05+qJsGDupOY4Z1xENAX470kvYXVPgAsXYCLOLg3E5IdrTyNAbIETHgdhHCCo k8XCpXorUk8ug== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 67BAD69299; Sat, 10 Jan 2026 13:30:03 -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 vBC99DqMvpxz; Sat, 10 Jan 2026 13:30:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768076998; bh=v+G+VeTYvehjKERzzdbVtzdJN3O5bqCSFqL/Hfm476o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mrCulXrXioj3MQUkTx3L6joUPadsTmOZDz1AAs1vdhJAg96ylOpidkwzn3wsyEO/Q yCFXQwbNoRwAx2FpgY0rjBl0GsdJIumW5Sn/yQnotWOsUXA5VW4NqCIzdHoJgKdcXi s87ilzs3ftAmSsD6YbPInHcF8IQm+C4Vj0Ht0GQmFss1ltcioc2I4/97TdK+OwCF7f LlIgxM1qj100YLw0MfR9p/L2PX6MbO595VUXgeQ+kQT50yimFXNoj0adiV9KfDSTX/ 1WDk8ZiPPkhyl98CjlxxHAlFHUv2bui6LukDl6xz/e3pNt47w0cztvoJ2c2b46Pdt4 bmewE/9mMX1GA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8D6D869186; Sat, 10 Jan 2026 13:29:58 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:41 -0700 Message-ID: <20260110202906.187370-10-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: MVQ37FOKYMTQTKRTT63QJ57UACJMXTXR X-Message-ID-Hash: MVQ37FOKYMTQTKRTT63QJ57UACJMXTXR 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 09/26] boot: pxe: Replace pxe_fdtoverlay with pxe_file 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 new struct pxe_file provides a more general way to describe files that need to be loaded. Replace the FDT-overlay-specific struct with the new general-purpose one, setting the type field to PFT_FDTOVERLAY. This change prepares for moving away from callback-based file loading to a model where PXE returns a list of files to load and the caller handles the actual loading. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 8 +++++--- boot/pxe_utils.c | 4 ++-- include/pxe_utils.h | 13 +------------ test/boot/pxe.c | 12 ++++++------ 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index f6b7887f603..29bee4d908c 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -106,14 +106,14 @@ static struct pxe_label *label_create(void) if (!label) return NULL; memset(label, 0, sizeof(struct pxe_label)); - alist_init_struct(&label->fdtoverlays, struct pxe_fdtoverlay); + alist_init_struct(&label->fdtoverlays, struct pxe_file); return label; } void label_destroy(struct pxe_label *label) { - struct pxe_fdtoverlay *overlay; + struct pxe_file *overlay; free(label->name); free(label->menu); @@ -326,7 +326,7 @@ static int parse_fdtoverlays(char **c, struct alist *overlays) start = val; while (*val) { - struct pxe_fdtoverlay item; + struct pxe_file item; char *end; /* Skip leading spaces */ @@ -345,7 +345,9 @@ static int parse_fdtoverlays(char **c, struct alist *overlays) item.path = strdup(val); val += strlen(val); } + item.type = PFT_FDTOVERLAY; item.addr = 0; + item.size = 0; if (!item.path || !alist_add(overlays, item)) { free(item.path); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 384a4e4f8ab..b4bcba422b8 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -308,7 +308,7 @@ static void label_boot_kaslrseed(struct pxe_context *ctx) static void label_load_fdtoverlays(struct pxe_context *ctx, struct pxe_label *label) { - struct pxe_fdtoverlay *overlay; + struct pxe_file *overlay; ulong fdtoverlay_addr; bool use_lmb; char *envaddr; @@ -357,7 +357,7 @@ static void label_load_fdtoverlays(struct pxe_context *ctx, static void label_apply_fdtoverlays(struct pxe_context *ctx, struct pxe_label *label) { - struct pxe_fdtoverlay *overlay; + struct pxe_file *overlay; struct fdt_header *blob; int err; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 2f194b91683..75437885dd3 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -24,17 +24,6 @@ * take a 'include file getter' function. */ -/** - * struct pxe_fdtoverlay - info about an FDT overlay - * - * @path: Path to the overlay file - * @addr: Address where the overlay was loaded (0 if not yet loaded) - */ -struct pxe_fdtoverlay { - char *path; - ulong addr; -}; - /** * struct pxe_label - describes a single label in a pxe file * @@ -50,7 +39,7 @@ struct pxe_fdtoverlay { * @initrd: path to the initrd to use for this label. * @fdt: path to FDT to use * @fdtdir: path to FDT directory to use - * @fdtoverlays: list of FDT overlays to apply (alist of struct pxe_fdtoverlay) + * @fdtoverlays: list of FDT overlays to apply (alist of struct pxe_file) * @files: list of files to load (alist of struct pxe_file) * @say: message to print when this label is selected for booting * @ipappend: flags for appending IP address (0x1) and MAC address (0x3) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 97049e27ab6..260fc918592 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -192,9 +192,9 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->fdtdir); ut_asserteq(2, label->fdtoverlays.count); ut_asserteq_str("/dtb/overlay1.dtbo", - alist_get(&label->fdtoverlays, 0, struct pxe_fdtoverlay)->path); + alist_get(&label->fdtoverlays, 0, struct pxe_file)->path); ut_asserteq_str("/dtb/overlay2.dtbo", - alist_get(&label->fdtoverlays, 1, struct pxe_fdtoverlay)->path); + alist_get(&label->fdtoverlays, 1, struct pxe_file)->path); ut_asserteq_str("Booting default Linux kernel", label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -317,13 +317,13 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) /* Verify overlays were loaded to valid addresses */ ut_assert(alist_get(&label->fdtoverlays, 0, - struct pxe_fdtoverlay)->addr >= PXE_OVERLAY_ADDR); + struct pxe_file)->addr >= PXE_OVERLAY_ADDR); ut_assert(alist_get(&label->fdtoverlays, 1, - struct pxe_fdtoverlay)->addr >= PXE_OVERLAY_ADDR); + struct pxe_file)->addr >= PXE_OVERLAY_ADDR); /* Second overlay should be at a higher address than the first */ - ut_assert(alist_get(&label->fdtoverlays, 1, struct pxe_fdtoverlay)->addr > - alist_get(&label->fdtoverlays, 0, struct pxe_fdtoverlay)->addr); + ut_assert(alist_get(&label->fdtoverlays, 1, struct pxe_file)->addr > + alist_get(&label->fdtoverlays, 0, struct pxe_file)->addr); /* Verify no more console output */ ut_assert_console_end(); From patchwork Sat Jan 10 20:28:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1456 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=1768077010; bh=iR4tR9MPnhsJkjNLSNuY6ptOwi3y94oOhcQEo11Qyrc=; 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=nxD9NOTm2lhXpPZygtc4gh7DzTspmbyh0OVoiTNtKt/sF/LKCPAIvBOk4wXOJ2moT HYvWWvI4W5DVUxeJM/7Yq0r/yq6fcvXH0YNpkfzht8eK5H1eUl1r+g84AH+x6dPIu5 TRwzsSUFu/i1pryw1nYfufh2zL2JsanBsyNxTrMtoRnQNAw+0mDH/Fo/5S62pmx7pj p226c51/lySp6rHjwxV6VC/gVWOMUd+uKdsLh4OR1XqMYBQJG49THlF+eWYgS+GMyO oC6SfYJNa3SrOksyuTiPeapwamVhsHTqQdm8cbWQ7I8sPgpdCa5Acq1JGW6j1eail9 51NyOQ9gHeLqw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 10D8A69298 for ; Sat, 10 Jan 2026 13:30:10 -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 bsv3LALFKRmR for ; Sat, 10 Jan 2026 13:30:10 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077009; bh=iR4tR9MPnhsJkjNLSNuY6ptOwi3y94oOhcQEo11Qyrc=; 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=ZSP3jyZGI4xTxgslyxQiBOOzP+ehv55ur9Cf5B2+TwcafSzeIH3ns6d6b4iqDlmwc B3jwZVObUyxiTLFmxwhB/i54cys89ZB33A+mvdpDrWhQEl2YgblCmx0uT8VYCVpga1 8/xYI1qVvRnxiidkLZlceETjKoLiwmCIpYGI63wc/PNc1sQB6FVGmRdxTjIwf+ogx9 xiRicO/zXVzn5pPG05R8GR4SgLzbJU6YaO9F5SkK9F4S9sU+Vas2fDCHW9sKvsoTfQ 2sMrC74WViXmkA8x6AHRGIS+YYCI1FJFqpYLBSYFKcnzf2a9YO2ZlsBqyYLLtpamCr 1uM610NMewpMg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F325169291 for ; Sat, 10 Jan 2026 13:30:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077008; bh=0lniQ0vch0m0pjQjuxn0kfVZ7QQCKmnr62sV2W+AHAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Am41oNHvgY3DHdxg6XTFSLUKjQUHJq6zBDwO1fySALlmWBJL1EroK+86k/BLQuN9d d5gkLza5Abiy3fMbQVmKkEeYIuEbi9CIGJMTO3A4O4JKVgj2m5B0whEyoyntxcqFB+ Uho/5ZRgvHSFSXjmASvF0gG+aHXigEnOrYND7ZhNUrkME5s9JVK3hfE9/P6pfmOYlt 1GuTABnz89e/DTfFcv/cxbgSTZ8I1WC6DRGvQ0ZUPBkApreiW5ak74MJmqRzJ56Chw SdzsHkBedVBgmsU4hAOrqdYWyWWtpo6Dq43P2vhvGlGbSy3WrlyJ2iJp8/WavWvxiz poAolT4ePemeA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 05DA069186; Sat, 10 Jan 2026 13:30:08 -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 gqFSCkT6uljT; Sat, 10 Jan 2026 13:30:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077003; bh=ddF6+mC23TZFt5vmm4O3XtFKgpmZKhTAH6yGowA/XsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MB4Fy02abw1wJljcLDYVWyIT3nQpNC4W5po8MPawtYVEk0ZCIVn/VEQyr/YIpH19x AhIo09QgzvpdIao8PiuK4NvgCfEXDhSNxkcTiBJiEHc0rAKNLISvWMcDT3mSInV/HU 9LW761cK2rfMIM8DRm4/0Pq8WmxaHikDDI9qVR6YjNLm6X+fBqrY4HsNACGFSZBqox b3kELcaAooeIRzM28gelgF+14YIyNOa7011ZMMSZG+XYChXzI9eiE5zAzGmzU49Hn3 r7uvlvopWC/sl2INGJuQ/ON4sOrTSkEjn83V9kInUiTD3dYeFuPSFSa41Odvhugqsf rhHqMTFp1hMMw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4A3F96927E; Sat, 10 Jan 2026 13:30:03 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:42 -0700 Message-ID: <20260110202906.187370-11-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: GZSNCXKURT5AUXPV63SFA5K4TEN3SRCQ X-Message-ID-Hash: GZSNCXKURT5AUXPV63SFA5K4TEN3SRCQ 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 10/26] boot: pxe: Use the files list instead of fdtoverlays 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 Use the new files list for handling the FDT overlays, using the type PFT_FDTOVERLAY. Add a helper function to check if any overlays exist in the list, to preserve the existing behaviour of only adding new overlays if not done already. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 33 ++++++++++++++++++++++++--------- boot/pxe_utils.c | 13 ++++++++----- include/pxe_utils.h | 2 -- test/boot/pxe.c | 26 +++++++++++++------------- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 29bee4d908c..b516da8f759 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -106,14 +106,14 @@ static struct pxe_label *label_create(void) if (!label) return NULL; memset(label, 0, sizeof(struct pxe_label)); - alist_init_struct(&label->fdtoverlays, struct pxe_file); + alist_init_struct(&label->files, struct pxe_file); return label; } void label_destroy(struct pxe_label *label) { - struct pxe_file *overlay; + struct pxe_file *file; free(label->name); free(label->menu); @@ -124,9 +124,9 @@ void label_destroy(struct pxe_label *label) free(label->initrd); free(label->fdt); free(label->fdtdir); - alist_for_each(overlay, &label->fdtoverlays) - free(overlay->path); - alist_uninit(&label->fdtoverlays); + alist_for_each(file, &label->files) + free(file->path); + alist_uninit(&label->files); free(label->say); free(label); } @@ -312,10 +312,25 @@ static int parse_sliteral(char **c, char **dst) return 1; } +/* + * Check if a files list contains any FDT overlays. + */ +static bool has_fdtoverlays(struct alist *files) +{ + struct pxe_file *file; + + alist_for_each(file, files) { + if (file->type == PFT_FDTOVERLAY) + return true; + } + + return false; +} + /* * Parse a space-separated list of overlay paths into an alist. */ -static int parse_fdtoverlays(char **c, struct alist *overlays) +static int parse_fdtoverlays(char **c, struct alist *files) { char *val, *start; int err; @@ -349,7 +364,7 @@ static int parse_fdtoverlays(char **c, struct alist *overlays) item.addr = 0; item.size = 0; - if (!item.path || !alist_add(overlays, item)) { + if (!item.path || !alist_add(files, item)) { free(item.path); free(start); return -ENOMEM; @@ -589,8 +604,8 @@ static int parse_label(char **c, struct pxe_menu *cfg) err = parse_sliteral(c, &label->fdtdir); break; case T_FDTOVERLAYS: - if (!label->fdtoverlays.count) - err = parse_fdtoverlays(c, &label->fdtoverlays); + if (!has_fdtoverlays(&label->files)) + err = parse_fdtoverlays(c, &label->files); break; case T_LOCALBOOT: label->localboot = 1; diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index b4bcba422b8..a2a2b986de1 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -327,11 +327,14 @@ static void label_load_fdtoverlays(struct pxe_context *ctx, use_lmb = true; } - alist_for_each(overlay, &label->fdtoverlays) { + alist_for_each(overlay, &label->files) { ulong addr = fdtoverlay_addr; ulong size; int err; + if (overlay->type != PFT_FDTOVERLAY) + continue; + err = get_relfile(ctx, overlay->path, &addr, SZ_4K, (enum bootflow_img_t)IH_TYPE_FLATDT, &size); if (err < 0) { @@ -368,8 +371,8 @@ static void label_apply_fdtoverlays(struct pxe_context *ctx, /* Resize main fdt to make room for overlays */ fdt_shrink_to_minimum(ctx->fdt, 8192); - alist_for_each(overlay, &label->fdtoverlays) { - if (!overlay->addr) + alist_for_each(overlay, &label->files) { + if (overlay->type != PFT_FDTOVERLAY || !overlay->addr) continue; blob = map_sysmem(overlay->addr, 0); @@ -515,7 +518,7 @@ 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) + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->files.count) label_apply_fdtoverlays(ctx, label); return 0; @@ -679,7 +682,7 @@ int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, } } - if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->fdtoverlays.count) + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->files.count) label_load_fdtoverlays(ctx, label); return 0; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 75437885dd3..266204b97ef 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -39,7 +39,6 @@ * @initrd: path to the initrd to use for this label. * @fdt: path to FDT to use * @fdtdir: path to FDT directory to use - * @fdtoverlays: list of FDT overlays to apply (alist of struct pxe_file) * @files: list of files to load (alist of struct pxe_file) * @say: message to print when this label is selected for booting * @ipappend: flags for appending IP address (0x1) and MAC address (0x3) @@ -60,7 +59,6 @@ struct pxe_label { char *initrd; char *fdt; char *fdtdir; - struct alist fdtoverlays; struct alist files; char *say; int ipappend; diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 260fc918592..df7cf2a781a 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -190,11 +190,11 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq_str("/initrd.img", label->initrd); ut_asserteq_str("/dtb/board.dtb", label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(2, label->fdtoverlays.count); + ut_asserteq(2, label->files.count); ut_asserteq_str("/dtb/overlay1.dtbo", - alist_get(&label->fdtoverlays, 0, struct pxe_file)->path); + alist_get(&label->files, 0, struct pxe_file)->path); ut_asserteq_str("/dtb/overlay2.dtbo", - alist_get(&label->fdtoverlays, 1, struct pxe_file)->path); + alist_get(&label->files, 1, struct pxe_file)->path); ut_asserteq_str("Booting default Linux kernel", label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -214,7 +214,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_asserteq_str("/dtb/", label->fdtdir); - ut_asserteq(0, label->fdtoverlays.count); + ut_asserteq(0, label->files.count); ut_assertnull(label->say); ut_asserteq(3, label->ipappend); ut_asserteq(0, label->attempted); @@ -234,7 +234,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(0, label->fdtoverlays.count); + ut_asserteq(0, label->files.count); ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -254,7 +254,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(0, label->fdtoverlays.count); + ut_asserteq(0, label->files.count); ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -274,7 +274,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(0, label->fdtoverlays.count); + ut_asserteq(0, label->files.count); ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -296,7 +296,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) * environment, and verify overlay files can be loaded. */ label = list_first_entry(&cfg->labels, struct pxe_label, list); - ut_asserteq(2, label->fdtoverlays.count); + ut_asserteq(2, label->files.count); /* Set environment variables for file loading */ ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); @@ -316,14 +316,14 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(PXE_FDT_ADDR, ctx.fdt_addr); /* Verify overlays were loaded to valid addresses */ - ut_assert(alist_get(&label->fdtoverlays, 0, + ut_assert(alist_get(&label->files, 0, struct pxe_file)->addr >= PXE_OVERLAY_ADDR); - ut_assert(alist_get(&label->fdtoverlays, 1, + ut_assert(alist_get(&label->files, 1, struct pxe_file)->addr >= PXE_OVERLAY_ADDR); /* Second overlay should be at a higher address than the first */ - ut_assert(alist_get(&label->fdtoverlays, 1, struct pxe_file)->addr > - alist_get(&label->fdtoverlays, 0, struct pxe_file)->addr); + ut_assert(alist_get(&label->files, 1, struct pxe_file)->addr > + alist_get(&label->files, 0, struct pxe_file)->addr); /* Verify no more console output */ ut_assert_console_end(); @@ -702,7 +702,7 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) /* Get the first label (linux) which has fdtoverlays */ label = list_first_entry(&cfg->labels, struct pxe_label, list); ut_asserteq_str("linux", label->name); - ut_assert(label->fdtoverlays.count > 0); + ut_assert(label->files.count > 0); /* Enable output for loading phase */ ctx.quiet = false; From patchwork Sat Jan 10 20:28:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1457 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=1768077012; bh=ooeb4UOIPFESr06RGaHibIaBgqcNB2aCui3O7EkSM6U=; 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=B2xV0rvw5qyCgNQDbxUhKk8wYSX9OENVxtocFZcUUDoTtO5+A5D7WoU0aiqAySp/4 xP8XGivKgZ/pELlMJ7Btcx0MBokclNrhrHmKyOn4U9kbFeYxG+bk1ZiOUN23Q/SQ9c afvccX5j8lRA5wACNFFMr1/Ru95th191TPhk/SXKdExVcRwKDtdzutjhq4WpoktX1a 4E2iK8GF9/ohnqj27+vii87LptphIaL+o0BauqsJ9PFaMbtgPMm2zmM8PgObDSxj/A Iwl6zLrME+azyvgRuH27QFkNcd9NeXqLVssBsAjKAHxIaRPi/ZFN3XxzN8MNSZjaDb W2eazBwxorKJA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7564C69186 for ; Sat, 10 Jan 2026 13:30:12 -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 vl4RwYAaE97g for ; Sat, 10 Jan 2026 13:30:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077011; bh=ooeb4UOIPFESr06RGaHibIaBgqcNB2aCui3O7EkSM6U=; 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=oeI/lgwyTLDkZuTWi1gHC/MRT7qlKbmJr9ZUotEs+4ZevT6lnUIqad0HqmcAoEgvR txVrStAfrZzJlgOBDNa3mS3Bm5E5fWNt/lE8AeMO1U6SIsyv4PY1O/Pl7/pA4tDDXY Y4M246JHjkQKr73gil8Exu1PMnMVq7wMzdVJoz+L+Bx6nFQ+ubmVdWzFlWczetA6az Z7MIfAg8wmAfPDrIuRaw7nHp+8jt4+hU9QPvAdZzQ+QId9nnfdP1JfCU0qxDNtJpg6 wzL3AQ0K2Hb29w8pUt9/IsRXF3VEE6DijjcQOTxF+lrig6lrsNkoQk4oXn1EWhlOOi j18zjxQSgzXUw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 01BD669290 for ; Sat, 10 Jan 2026 13:30:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077008; bh=C9m6aPC19sG9G+ZZllqlzkO2IJohMUBy/Bl6W8Qp+dY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AAwo4WfgZzXHMIsr1VJvRqppUmLx29pTYqraz70xvDKGOKwqtPzJxu9x2f3pj42tC xl/0y4+5byyc5j253L4LqqisHaX3p6buJIiMg22NlUbXCoHfpYwAIMOUcnThpSRjjw tO1mmD4yC7EIeC5yRy7bwsIQOdxiygjbQof48MQ1MuhTBmjhESvsXdsg9/bl/KEbjq q4MIM3m9fGMCrRb+LAcO023kaWTumd5v9gxrwzZ7T2ITm7dHUco/DU0+EZXCe/ze3y uPfuEottAitQ4viQHFwJZmVhVn9TEnbo542D8vXxTcMwZ7dTgwXpbjYkDuyvmzP0Hc scPkHJ6yNiueQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BE06D69290; Sat, 10 Jan 2026 13:30:08 -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 tzgAq3RBG_4X; Sat, 10 Jan 2026 13:30:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077008; bh=shLy0er698rV3LEQwbJtTgrZT68j5UqDXoER31Gtoos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=evVW+l2n1BHKxMqzlr74PPLoZVhIrgmZVWSXFPoEFlwloKhu6zXNKxq/qyjCUvKTf q3CujszWqS72G8yNj6h47+lOKOAjoZpHH9lwJlpaGNLJafwcZiMterivBDMxUrGKUz YQgNz9VN/x+/xLIJzQXeStIyVJQFRd/qgc8gTqlKBdXuJecEU6vRzVh7QcXPUERHEo hNf46mKYsIoHdY/84UveYlupalZuB3dYAf/fkLuuwuSTFWNl6Lhlp1QQvI5JrFX6ER npxQpt4HYIMJsekQVlLTcN2ENDDo6ylJyQVAT+eEqlbrQoTEeORwjOKmL/o1K+lZlY kyawh+KgZuACg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0B7B26927E; Sat, 10 Jan 2026 13:30:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:43 -0700 Message-ID: <20260110202906.187370-12-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: CFLW5TIROX45EWFQUMG4MUU5LVOMDIGE X-Message-ID-Hash: CFLW5TIROX45EWFQUMG4MUU5LVOMDIGE 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 11/26] boot: pxe: Add a helper to add to the file list 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 Add a helper function to add files to a label's file list. This makes it easier to add files. Refactor parse_fdtoverlays() to use the new helper, taking a label pointer instead of an alist pointer. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 61 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index b516da8f759..51fce1d5737 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -327,10 +327,37 @@ static bool has_fdtoverlays(struct alist *files) return false; } +/** + * label_add_file() - Add a file to a label's file list + * + * @label: Label to add file to + * @path: Path to file (will be duplicated) + * @type: Type of file (PFT_KERNEL, PFT_INITRD, etc.) + * Return: 0 on success, -ENOMEM on allocation failure + */ +static int label_add_file(struct pxe_label *label, const char *path, + enum pxe_file_type_t type) +{ + struct pxe_file item; + + item.path = strdup(path); + if (!item.path) + return -ENOMEM; + item.type = type; + item.addr = 0; + item.size = 0; + if (!alist_add(&label->files, item)) { + free(item.path); + return -ENOMEM; + } + + return 0; +} + /* - * Parse a space-separated list of overlay paths into an alist. + * Parse a space-separated list of overlay paths into a label's file list. */ -static int parse_fdtoverlays(char **c, struct alist *files) +static int parse_fdtoverlays(char **c, struct pxe_label *label) { char *val, *start; int err; @@ -341,7 +368,6 @@ static int parse_fdtoverlays(char **c, struct alist *files) start = val; while (*val) { - struct pxe_file item; char *end; /* Skip leading spaces */ @@ -351,23 +377,22 @@ static int parse_fdtoverlays(char **c, struct alist *files) if (!*val) break; - /* Find end of this path */ + /* Find end of this path and temporarily null-terminate */ end = strchr(val, ' '); - if (end) { - item.path = strndup(val, end - val); - val = end; - } else { - item.path = strdup(val); - val += strlen(val); - } - item.type = PFT_FDTOVERLAY; - item.addr = 0; - item.size = 0; + if (end) + *end = '\0'; - if (!item.path || !alist_add(files, item)) { - free(item.path); + err = label_add_file(label, val, PFT_FDTOVERLAY); + if (err) { free(start); - return -ENOMEM; + return err; + } + + if (end) { + *end = ' '; + val = end + 1; + } else { + break; } } @@ -605,7 +630,7 @@ static int parse_label(char **c, struct pxe_menu *cfg) break; case T_FDTOVERLAYS: if (!has_fdtoverlays(&label->files)) - err = parse_fdtoverlays(c, &label->files); + err = parse_fdtoverlays(c, label); break; case T_LOCALBOOT: label->localboot = 1; From patchwork Sat Jan 10 20:28:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1458 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=1768077016; bh=HDzbREbggsIqSuMzZt0bksVgFQGGvICVOxEPPZPbNFU=; 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=sXdpeVNN6t7k9xhLQLPC5jFn0HwexwROFUFeyKqcM3ZmQEuz5/XIf1dRKLd0oXr7s 6CqBHpANxrAsztXTNs4dLnjHZgM2mybw7//4O13WYh/IGGgLvx5X+SdpKlRSA4kYIu ovez4v3jDK8RsHLFH5E26OMyK+rBWWSuEfIiRXtChH4VOz0BFyV75ck69u8nbB7e0w MedPV7Dgn0fz/kKrA7XDijPUyjWYvt9W0FIADeVIrgGSx0d6nzC2FL4Ih8rN6/6Mmr HBNJ2p/VZ1jKLv4P6KJcWqhHbi6sVvocVAr7iukycS91Cz932NDs/DleM3p4QT8Y// 3u/fk8TW2wVpw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8EAFB69296 for ; Sat, 10 Jan 2026 13:30: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 DJEHR_nG5m4j for ; Sat, 10 Jan 2026 13:30:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077016; bh=HDzbREbggsIqSuMzZt0bksVgFQGGvICVOxEPPZPbNFU=; 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=sXdpeVNN6t7k9xhLQLPC5jFn0HwexwROFUFeyKqcM3ZmQEuz5/XIf1dRKLd0oXr7s 6CqBHpANxrAsztXTNs4dLnjHZgM2mybw7//4O13WYh/IGGgLvx5X+SdpKlRSA4kYIu ovez4v3jDK8RsHLFH5E26OMyK+rBWWSuEfIiRXtChH4VOz0BFyV75ck69u8nbB7e0w MedPV7Dgn0fz/kKrA7XDijPUyjWYvt9W0FIADeVIrgGSx0d6nzC2FL4Ih8rN6/6Mmr HBNJ2p/VZ1jKLv4P6KJcWqhHbi6sVvocVAr7iukycS91Cz932NDs/DleM3p4QT8Y// 3u/fk8TW2wVpw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7CB5469290 for ; Sat, 10 Jan 2026 13:30:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077014; bh=HR3aec+n5GdyapjL5rp1X11KXp8kZEtLkWhMjxihhfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NGTNPQtQwaOOl8e30SDbUtWB2OBsuMA4lBFgkRYF7xbEB1jzsxR1StQpI7SS5LyLO KFKR4org9ed2y0OfCgnrcfj0TXwWlJK+VDMMoGBRp/adSs4WH88ZVNm+7vlMS239e6 wqfCr0L0gWeZG0Hmyrb1dP5YLgMPSmNf+kxE3DUPkc+ArXJzBLhWSn0oukjHRhj8TN emOlSHM0CQgesSmmUYoIHHRQT6U6WHXgCPtd4yh6NmR48juEmq5pQbDMcFQ1iTG3OO L5klq4N3loxzJFTeUYI5pxlnEICvg191ZtzGF8g/0fI69w1YAiD7jMXOgRDZVYeNKU 7tALk5d81Iq4g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B955669290; Sat, 10 Jan 2026 13:30:14 -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 XPxMLwaFoCfO; Sat, 10 Jan 2026 13:30:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077009; bh=zsLNuZETk0PNbUmxZyZ21mwTzQykxMZwMKFSEeu0QiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mSQz9xB9NAUIfHBnEWqn2cPZuiwv/m5fSMAdiVu7Iqrtw7UFn5U7d5Qd4cR2wljHp yOzPpmvhcJaAs8hXL/UQ147TktZtlcn5p4PJZwB0vSYHxIzF+G6Mx1ipvMO43IO7rT E7muzfSO2qERsQvjLhRsFda2u5IaH4PAY/v68YHecZ5CSYBpIi195ndlswJ2vlyYba DvG15doBTaXD8DHX12dJ9XymuJf97WD+H5KQN9bKKvZImp13zSraE9EU5WA01RKk6H 8H9GE+V6hHLP7Y/uJbm7a74SjL9O+z2bRj8lxfWqhDXxePvX7QGUc1SF/mjW9shWnt AzSS0O9FTUMLQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0D65B6927E; Sat, 10 Jan 2026 13:30:08 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:44 -0700 Message-ID: <20260110202906.187370-13-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: EO25OHLXKSSZPVYA3B7RQQDL2O2HH3MH X-Message-ID-Hash: EO25OHLXKSSZPVYA3B7RQQDL2O2HH3MH 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 12/26] boot: pxe: Add the kernel to the files list when parsing 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 When parsing a kernel label, add the kernel path to the files list with type PFT_KERNEL. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 15 +++++++-------- test/boot/pxe.c | 32 ++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 51fce1d5737..8bd9d66f486 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -547,16 +547,15 @@ static int parse_label_kernel(char **c, struct pxe_label *label) return -ENOMEM; s = strstr(label->kernel, "#"); - if (!s) - return 1; - - label->config = strdup(s); - if (!label->config) - return -ENOMEM; + if (s) { + label->config = strdup(s); + if (!label->config) + return -ENOMEM; - *s = 0; + *s = 0; + } - return 1; + return label_add_file(label, label->kernel, PFT_KERNEL) ? : 1; } /* diff --git a/test/boot/pxe.c b/test/boot/pxe.c index df7cf2a781a..6b2d521c8e8 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -190,11 +190,13 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq_str("/initrd.img", label->initrd); ut_asserteq_str("/dtb/board.dtb", label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(2, label->files.count); - ut_asserteq_str("/dtb/overlay1.dtbo", + ut_asserteq(3, label->files.count); + ut_asserteq_str("/vmlinuz", alist_get(&label->files, 0, struct pxe_file)->path); - ut_asserteq_str("/dtb/overlay2.dtbo", + ut_asserteq_str("/dtb/overlay1.dtbo", alist_get(&label->files, 1, struct pxe_file)->path); + ut_asserteq_str("/dtb/overlay2.dtbo", + alist_get(&label->files, 2, struct pxe_file)->path); ut_asserteq_str("Booting default Linux kernel", label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -214,7 +216,9 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_asserteq_str("/dtb/", label->fdtdir); - ut_asserteq(0, label->files.count); + ut_asserteq(1, label->files.count); + ut_asserteq_str("/vmlinuz-rescue", + alist_get(&label->files, 0, struct pxe_file)->path); ut_assertnull(label->say); ut_asserteq(3, label->ipappend); ut_asserteq(0, label->attempted); @@ -254,7 +258,9 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(0, label->files.count); + ut_asserteq(1, label->files.count); + ut_asserteq_str("/boot/image.fit", + alist_get(&label->files, 0, struct pxe_file)->path); ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -274,7 +280,9 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(0, label->files.count); + ut_asserteq(1, label->files.count); + ut_asserteq_str("/boot/included-kernel", + alist_get(&label->files, 0, struct pxe_file)->path); ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -296,7 +304,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) * environment, and verify overlay files can be loaded. */ label = list_first_entry(&cfg->labels, struct pxe_label, list); - ut_asserteq(2, label->files.count); + ut_asserteq(3, label->files.count); /* Set environment variables for file loading */ ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); @@ -315,15 +323,15 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(PXE_KERNEL_ADDR, ctx.kern_addr); ut_asserteq(PXE_FDT_ADDR, ctx.fdt_addr); - /* Verify overlays were loaded to valid addresses */ - ut_assert(alist_get(&label->files, 0, - struct pxe_file)->addr >= PXE_OVERLAY_ADDR); + /* Verify overlays were loaded to valid addresses (indices 1 and 2) */ ut_assert(alist_get(&label->files, 1, struct pxe_file)->addr >= PXE_OVERLAY_ADDR); + ut_assert(alist_get(&label->files, 2, + struct pxe_file)->addr >= PXE_OVERLAY_ADDR); /* Second overlay should be at a higher address than the first */ - ut_assert(alist_get(&label->files, 1, struct pxe_file)->addr > - alist_get(&label->files, 0, struct pxe_file)->addr); + ut_assert(alist_get(&label->files, 2, struct pxe_file)->addr > + alist_get(&label->files, 1, struct pxe_file)->addr); /* Verify no more console output */ ut_assert_console_end(); From patchwork Sat Jan 10 20:28:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1459 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=1768077022; bh=WGQuKl5IQQwCvcLXKRZhk4mOLtm5/qdwkxwFvmKZpTY=; 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=XWk1Hio8XBjZxvyKp69Gv2zfzytnRyzrF8p1T6rfEQn6H7LqycGXLavk79GXa+RFh HlSEHNkoE+1Osgh9vImiFhoy6oVn0tF1B3Pj/oSN4BnKo183fzI3awzSWdfWuqp70y UPnXxB42+D8pVwR+1yvuVaEuXuU+ekXHs9nJSIbR8WR+abj2KnoTbjJWUqHIPeuEos JbufjMUGJgEcYVws8xTOl1a7mHBtepuOUwysTIu6eRTxIUr7QioDSLM2f62nj64dfJ CRzBBzRcdDAffexzzTERnawfG4AYYND+X5CawGFZjvvyOHfneEdjYElovYjfB1IaM/ NYGaHW/F7dVNA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0CFC169296 for ; Sat, 10 Jan 2026 13:30:22 -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 dyzaWxmmasrl for ; Sat, 10 Jan 2026 13:30:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077021; bh=WGQuKl5IQQwCvcLXKRZhk4mOLtm5/qdwkxwFvmKZpTY=; 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=iAPCDDjKNoIWFjx1frRjqCg96U1iywHbvILrjRZHT7edKdrGLsBjC5pHHihEuoWf1 PrhQQ7Q7fr2Q6qF1XAGsCcOgC+lkc/xtzLFifPruOr9opx5S5UuwxeHDDthe5ar4F1 9/v/uJK+cQUwCnbOeHPAlrZuGfrbi3hS9JjuN9xyMS0BfJgXt34Y4kzl5/ppZLPzg0 bMB8HBRsvNqwWA3SCVidaJBeyMT01jvuMNNhi0Urj2kO0Qq1yzeSUv0k5m/Ri9UY59 3eLyGrmpcMn5t1VabS6M8dvxoGFyEVneI8dv56THtOOp/pc8O8MBmsShQdn3D2x/QX ilnkcBRroU50w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F004F69290 for ; Sat, 10 Jan 2026 13:30:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077018; bh=sEspRTVauE+lAgAZAaekWoO8QCmulERJcoOWHNPlE1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NMisHsfZleUxLgVeSCF96Jml+RNRXudlcF+SkvFWkvHlT9C2AVzGSNcGldJiDp0C5 rdY0/Ree4LP/3+AGCZ/NavA2R1IQs6Jo4C40gg222OCmzfBntuz8uWia0W7xtxQNyk PbRCt7Z2qBGvtYe/LOq7eB9WP9c6af4ZCEs7z9f4WmUEajulM8RTNaj9koTcd51MPo qFawrkIDqtkV7yBXbEpIohCXZDlFIlMqBSSzRb4Kt6IwOBksECevf973rR7B9m0mtb TGp/2k9pHLD5x51NK19/cCju/dRcYwWPIYR/BpABgsROWUSjvsynU/0xFEfmeyYf87 DjC6N3rbKBGXA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F184969290; Sat, 10 Jan 2026 13:30:18 -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 5PzH5syvFcQZ; Sat, 10 Jan 2026 13:30:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077014; bh=ApPElY0JidemFAiZGLyAXLWKFysvSq0XETC1Q+vyigA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VpGz2GxuN6szxRTlAOb0rncoWIjJKZxXi7drdCQv6FawCOSfmPxO4PxZnzvwbt+NR YGKXGG7dAIXfPVbWqw/zzHjLA7Mg+ziKkvNGYP+9+sKGS3JDcpFj4GJHe8+KhBD5rd Nwj6NdGrFs4LTZALEp8wmdlX+sg5qqClCWjEHGqfOMls14gv8p1J9k8ybftbq+elqT 8YDx3mYMbdUSahZXYt+Ucmu9cINi0aKM7V4xxJxgL6m9Ce91P6lBtLubt7XEfXZN0Q C+SGmwq/q44ZsqTuwQb9XWkEauNdrvqm3S11n+Vq8ua314wj34xq0u78Gw67d0IiD7 +ebNvVvF9tg/Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D7EC569186; Sat, 10 Jan 2026 13:30:13 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:45 -0700 Message-ID: <20260110202906.187370-14-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: UIYOEF7TH4CK3EMVDU7W2T4HE73ZH5FM X-Message-ID-Hash: UIYOEF7TH4CK3EMVDU7W2T4HE73ZH5FM 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 13/26] boot: pxe: Add the initrd to the files list when parsing 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 When parsing an initrd, add the path to the files list with type PFT_INITRD. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 7 ++++++- test/boot/pxe.c | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 8bd9d66f486..7dac5c94759 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -616,8 +616,13 @@ static int parse_label(char **c, struct pxe_menu *cfg) break; case T_INITRD: - if (!label->initrd) + if (!label->initrd) { err = parse_sliteral(c, &label->initrd); + if (err < 0) + break; + err = label_add_file(label, label->initrd, + PFT_INITRD); + } break; case T_FDT: if (!label->fdt) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 6b2d521c8e8..0751228dc99 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -190,13 +190,15 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq_str("/initrd.img", label->initrd); ut_asserteq_str("/dtb/board.dtb", label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(3, label->files.count); + ut_asserteq(4, label->files.count); ut_asserteq_str("/vmlinuz", alist_get(&label->files, 0, struct pxe_file)->path); - ut_asserteq_str("/dtb/overlay1.dtbo", + ut_asserteq_str("/initrd.img", alist_get(&label->files, 1, struct pxe_file)->path); - ut_asserteq_str("/dtb/overlay2.dtbo", + ut_asserteq_str("/dtb/overlay1.dtbo", alist_get(&label->files, 2, struct pxe_file)->path); + ut_asserteq_str("/dtb/overlay2.dtbo", + alist_get(&label->files, 3, struct pxe_file)->path); ut_asserteq_str("Booting default Linux kernel", label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -304,7 +306,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) * environment, and verify overlay files can be loaded. */ label = list_first_entry(&cfg->labels, struct pxe_label, list); - ut_asserteq(3, label->files.count); + ut_asserteq(4, label->files.count); /* Set environment variables for file loading */ ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); @@ -323,15 +325,15 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(PXE_KERNEL_ADDR, ctx.kern_addr); ut_asserteq(PXE_FDT_ADDR, ctx.fdt_addr); - /* Verify overlays were loaded to valid addresses (indices 1 and 2) */ - ut_assert(alist_get(&label->files, 1, - struct pxe_file)->addr >= PXE_OVERLAY_ADDR); + /* Verify overlays were loaded to valid addresses (indices 2 and 3) */ ut_assert(alist_get(&label->files, 2, struct pxe_file)->addr >= PXE_OVERLAY_ADDR); + ut_assert(alist_get(&label->files, 3, + struct pxe_file)->addr >= PXE_OVERLAY_ADDR); /* Second overlay should be at a higher address than the first */ - ut_assert(alist_get(&label->files, 2, struct pxe_file)->addr > - alist_get(&label->files, 1, struct pxe_file)->addr); + ut_assert(alist_get(&label->files, 3, struct pxe_file)->addr > + alist_get(&label->files, 2, struct pxe_file)->addr); /* Verify no more console output */ ut_assert_console_end(); From patchwork Sat Jan 10 20:28:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1460 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=1768077026; bh=/1cCurKWA94dAt09QGObCSSGb1oXga1MoiWDcO7ASGI=; 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=rdk00yaGePwb4TqzOPEdIm66yBxyCoiAQ7WwSOKQf6oBkbxdbwrnAJ9APh2GP9or/ sjKWvMofpMJd0lXyfBi1t9kp3cKe+kCK6riOlJfyx/6fMu84FaDrV6O0ayRmO2U+2E a8V6lL0iQHapIpyF6bsnSc7ly378srpeY9BtZA5563WCYrEYXChRHq/Bew5bbgrLEh R8RbZ/wEGebfwhB65EUgIeF3qAlBivZ+8fh9x5vmtYnlVaE5BQWsABNCYrShEy4LMK HNhA7+p7ooNdg+lEO7qI8M1oJjitDHlJdRH8OjsZJhKSNo9uVIoRU/B0cMzynQU/sU X2JOO+6YsjN3Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9077B69186 for ; Sat, 10 Jan 2026 13:30: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 10024) with ESMTP id qmrGPZfdeaEd for ; Sat, 10 Jan 2026 13:30:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077026; bh=/1cCurKWA94dAt09QGObCSSGb1oXga1MoiWDcO7ASGI=; 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=rdk00yaGePwb4TqzOPEdIm66yBxyCoiAQ7WwSOKQf6oBkbxdbwrnAJ9APh2GP9or/ sjKWvMofpMJd0lXyfBi1t9kp3cKe+kCK6riOlJfyx/6fMu84FaDrV6O0ayRmO2U+2E a8V6lL0iQHapIpyF6bsnSc7ly378srpeY9BtZA5563WCYrEYXChRHq/Bew5bbgrLEh R8RbZ/wEGebfwhB65EUgIeF3qAlBivZ+8fh9x5vmtYnlVaE5BQWsABNCYrShEy4LMK HNhA7+p7ooNdg+lEO7qI8M1oJjitDHlJdRH8OjsZJhKSNo9uVIoRU/B0cMzynQU/sU X2JOO+6YsjN3Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7CC696927E for ; Sat, 10 Jan 2026 13:30:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077024; bh=zqvjX57SRT4nt6JZey8pwp9nf/RnfCOwp58IHP+V9UQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjY5PBERsT+tbT7Tgi3f9YnFOp7d5H4nRIfvf15zVk6UjOKDb9YkVfEHuUCYqVHqu pWtpddqvpDFpSv4lgy82T4aI44/QzpRjRhMNxaXzxN+6xbU/6zn1XKJd5qXd0B2whC LmrKJ8Pd/P545/BrdCkHqkmzRZMUXM26GTKVP3HmzkiFURYr4wjSsAuHrIdVqn8ipa 6C4E19+M2xNxxWoVg2PN7wBif/ZzY5jxinG6LUPe/9F1zZEiKm8qvKIzGVw2YZaHmU V19Yj8YSP8TEZa908MFxLE3rmvH2/vNF8SX7KkG5rekseaHYIhzIhA0LU8S8AZzIds WX273q7dlkOYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5F4B169299; Sat, 10 Jan 2026 13:30:24 -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 JVAxhbQRLwcN; Sat, 10 Jan 2026 13:30:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077018; bh=0Qkz/9ejDqq0EXMeAGfx9SYG/EUqT06S98B0b2ZfGIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m5KbFvjb1k4n267VuMSGFYWegSDhf59ozWCQAqgRjbd5Z9Sc02VtiHBm3GP8dHY17 rnxH95YdFP6yI9U/bq/xT3rZEXPMiHnggbh4fmxWIFUzpI+LXH3sqIBpmo+ZoOqqzR ypdOxxXnwvod1jpwAi4jaNvPRQlnlBfweEat4vY3AzbJiD5lEy15l9X47Onsln2Jtq HW3AdG/8H8WkPCRVlpKRmlLqzdgXXN2yb3zrZxFcHtzOkMRqk0J53lUkaDDNws83SC ++p8Tu9aeRc/7EHbkz6odLB5yZsIWG/RU9yjD7A2xtYIyT9Didau5zawUHYG8xMYKD ZgYTdcddBEDlA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 803746927E; Sat, 10 Jan 2026 13:30:18 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:46 -0700 Message-ID: <20260110202906.187370-15-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: WXS336Z47OSABM2PGODXPUSNQKFRYDNV X-Message-ID-Hash: WXS336Z47OSABM2PGODXPUSNQKFRYDNV 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 14/26] boot: pxe: Add the FDT to the files list when parsing 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 When parsing an fdt directive, add the path to the files list with type PFT_FDT. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 6 +++++- test/boot/pxe.c | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 7dac5c94759..bcbe0495cbb 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -625,8 +625,12 @@ static int parse_label(char **c, struct pxe_menu *cfg) } break; case T_FDT: - if (!label->fdt) + if (!label->fdt) { err = parse_sliteral(c, &label->fdt); + if (err < 0) + break; + err = label_add_file(label, label->fdt, PFT_FDT); + } break; case T_FDTDIR: if (!label->fdtdir) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 0751228dc99..2d690141349 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -190,15 +190,17 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq_str("/initrd.img", label->initrd); ut_asserteq_str("/dtb/board.dtb", label->fdt); ut_assertnull(label->fdtdir); - ut_asserteq(4, label->files.count); + ut_asserteq(5, label->files.count); ut_asserteq_str("/vmlinuz", alist_get(&label->files, 0, struct pxe_file)->path); ut_asserteq_str("/initrd.img", alist_get(&label->files, 1, struct pxe_file)->path); - ut_asserteq_str("/dtb/overlay1.dtbo", + ut_asserteq_str("/dtb/board.dtb", alist_get(&label->files, 2, struct pxe_file)->path); - ut_asserteq_str("/dtb/overlay2.dtbo", + ut_asserteq_str("/dtb/overlay1.dtbo", alist_get(&label->files, 3, struct pxe_file)->path); + ut_asserteq_str("/dtb/overlay2.dtbo", + alist_get(&label->files, 4, struct pxe_file)->path); ut_asserteq_str("Booting default Linux kernel", label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -306,7 +308,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) * environment, and verify overlay files can be loaded. */ label = list_first_entry(&cfg->labels, struct pxe_label, list); - ut_asserteq(4, label->files.count); + ut_asserteq(5, label->files.count); /* Set environment variables for file loading */ ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); @@ -325,15 +327,15 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(PXE_KERNEL_ADDR, ctx.kern_addr); ut_asserteq(PXE_FDT_ADDR, ctx.fdt_addr); - /* Verify overlays were loaded to valid addresses (indices 2 and 3) */ - ut_assert(alist_get(&label->files, 2, - struct pxe_file)->addr >= PXE_OVERLAY_ADDR); + /* Verify overlays were loaded to valid addresses (indices 3 and 4) */ ut_assert(alist_get(&label->files, 3, struct pxe_file)->addr >= PXE_OVERLAY_ADDR); + ut_assert(alist_get(&label->files, 4, + struct pxe_file)->addr >= PXE_OVERLAY_ADDR); /* Second overlay should be at a higher address than the first */ - ut_assert(alist_get(&label->files, 3, struct pxe_file)->addr > - alist_get(&label->files, 2, struct pxe_file)->addr); + ut_assert(alist_get(&label->files, 4, struct pxe_file)->addr > + alist_get(&label->files, 3, struct pxe_file)->addr); /* Verify no more console output */ ut_assert_console_end(); From patchwork Sat Jan 10 20:28:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1461 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=1768077031; bh=R3QT0tAbRMFpnt324kO7fF2mS2ttuBs+sG2MRD0gLSQ=; 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=aPhaDUR90vB6AepR5Irl3Ekuos79Cq9MLVnz3mywCd59++/nPbhptmW5GcSX9oKlt sGHjhlrVwWEiOEO/hxV8O8lzxZMmMTm7Q9SZMbqcSLzWYkxFOzbRAXMkvilmUx5Wmy cfyDdj+dugG/5ENCz3IqYAf+dUviEDkIkSvlSf6RMqFQOnQKPfheA1d7D/evHW0Swu eAxOHaes2JHS3Bk920kmN8pikgk+gHi2jP/GWPDp1RYEyDiqkY1j2HsVk65Ogv0AYI 2N1f0jRJ6fpzgklfoxmrgXYtV3CPgw2sjsH66UXx387NNajVYd748N+Arn2efz4Dnj Sfq7KA/4YkVPA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5042469296 for ; Sat, 10 Jan 2026 13:30:31 -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 cWiwgCmW1pK2 for ; Sat, 10 Jan 2026 13:30:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077031; bh=R3QT0tAbRMFpnt324kO7fF2mS2ttuBs+sG2MRD0gLSQ=; 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=aPhaDUR90vB6AepR5Irl3Ekuos79Cq9MLVnz3mywCd59++/nPbhptmW5GcSX9oKlt sGHjhlrVwWEiOEO/hxV8O8lzxZMmMTm7Q9SZMbqcSLzWYkxFOzbRAXMkvilmUx5Wmy cfyDdj+dugG/5ENCz3IqYAf+dUviEDkIkSvlSf6RMqFQOnQKPfheA1d7D/evHW0Swu eAxOHaes2JHS3Bk920kmN8pikgk+gHi2jP/GWPDp1RYEyDiqkY1j2HsVk65Ogv0AYI 2N1f0jRJ6fpzgklfoxmrgXYtV3CPgw2sjsH66UXx387NNajVYd748N+Arn2efz4Dnj Sfq7KA/4YkVPA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3CEBD69290 for ; Sat, 10 Jan 2026 13:30:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077029; bh=mUsmWKKm2+7fxGa84IoGm7PGooQPTURwv0xyg/ZlBjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZsAIyHJAS+oyb8S5nsiB0IatN1RhYPT21xfdSgguJ1Z8dTZoPljw/PLFgHJ3kk95u ZjsfpoVVZJUDBpYw0ZcGznIVo+fdJhJ+73ab/J6A4lKgZHnF12LdGPg9apr6f/VfW1 r3vJ1/ehksYeM80BdcxodDutTV8MEIMlA/q+TbEuhKLz7moEdELCIut7vyazIGDzLz vPeSS3SZczT4nNb2pV7hnfgOTkkCl1DRhoTGVWC604ChsyDd9jN7nURYsiZvbInHj0 4NJPzQafzI+SPgLAX4omlQA1ZQCWgsjGtGmeojuf8r2a5NxGAocprzEkMsW22KY5cO muIxHXsz5vybw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 389116927E; Sat, 10 Jan 2026 13:30:29 -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 KA31_rZVgv0b; Sat, 10 Jan 2026 13:30:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077023; bh=fK6aoLHVX9e3r+bPhpOEjuaZWbBXESp92NDyJEcb1Bk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LFdNecvMoTtyybs9TXEJqm2IAyISsDWrGNShdjJHtbnm1+PzF4of6i+4I4FTEaLYB 411z/vfU1WAYdRae8eHeG0+Z/96bAkynWPiayZty4D2bWLvHEL+7xtg2R92tZuVKRy w0AcJScBxpaBCJcSXv5qXCJKiN2rMGlgQN8X5Ys3BlYW90tFP7zbRpUxAuGxGGzaz6 2yw3ISHByipE21ComJsy+Hi+/HKVEyKM/hCWDVGVNN7M/+1/ytg6bYCf9UTmRE9hs0 +N9bm6kIYWl/1ugqbstKRc2kM+gLq5X7ePdm+Rlz2aKiWbnypynMgkWYp+FPDxfQS1 P9bl4wZ+5VlQw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3429369290; Sat, 10 Jan 2026 13:30:23 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:47 -0700 Message-ID: <20260110202906.187370-16-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: ISAYWR2U3NV7CLLIDYZY6B4WBTD3ZHVC X-Message-ID-Hash: ISAYWR2U3NV7CLLIDYZY6B4WBTD3ZHVC 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 15/26] boot: pxe: Set pxe_file_size in get_pxe_file() 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 Currently pxe_file_size is only set by the cmd/pxe.c callback, so other callers of get_pxe_file() (like tests) do not have access to the file size. Add an assignment into get_pxe_file() so the size is always available in the context after loading a PXE config file. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 1 + test/boot/pxe.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index a2a2b986de1..2d9081e6e9b 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -151,6 +151,7 @@ int get_pxe_file(struct pxe_context *ctx, const char *file_path, buf = map_sysmem(file_addr + size, 1); *buf = '\0'; unmap_sysmem(buf); + ctx->pxe_file_size = size; return 1; } diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 2d690141349..a1ce27ea2a7 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -1178,7 +1178,7 @@ static int pxe_test_alloc_norun(struct unit_test_state *uts) ut_asserteq_ptr(&info, ctx.userdata); ut_asserteq(true, ctx.allow_abs_path); ut_assertnonnull(ctx.bootdir); - ut_asserteq(0, ctx.pxe_file_size); /* only set by cmd/pxe.c */ + ut_assert(ctx.pxe_file_size); /* set by get_pxe_file() */ ut_asserteq(false, ctx.use_ipv6); ut_asserteq(false, ctx.use_fallback); ut_asserteq(true, ctx.no_boot); From patchwork Sat Jan 10 20:28:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1462 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=1768077034; bh=PwXAkdpC4te6Y0o9xHrSoVC3Tosq1zixbWoj5qSQPU8=; 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=PDB82X4xuaajEj4vK77hJ2L8RmNcwcM2C3Dry0DMkjuApIH8+ZV/tdIJxVP5t+9u6 T4x1nWYrAWFKKFv2sB+zokB2drLhaRTFtAloIlY6/LH4jD1hESJvy8GhLAIr9KffpA YKERqG3+hqHqUv6WE3b8ZgcdCQMxpe87jGCkCnJOycBZTDXkrbgORH7DUbWdmaItfV 0Y8JUrOnq6wWpIM02WNBBfhjNOhk/ZQdok38vl4uL5jrcCrYDL84dJIBysYj4NfX4b vvUyAmlu3rATxBsA+a5+XVTsrkFHYQGgyRolQXlGekEYJ6lbThafew+qoz8ctJeOm7 FZunLr5T8JwOA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C050069299 for ; Sat, 10 Jan 2026 13:30:34 -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 9PJFJbYcO0PV for ; Sat, 10 Jan 2026 13:30:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077034; bh=PwXAkdpC4te6Y0o9xHrSoVC3Tosq1zixbWoj5qSQPU8=; 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=PDB82X4xuaajEj4vK77hJ2L8RmNcwcM2C3Dry0DMkjuApIH8+ZV/tdIJxVP5t+9u6 T4x1nWYrAWFKKFv2sB+zokB2drLhaRTFtAloIlY6/LH4jD1hESJvy8GhLAIr9KffpA YKERqG3+hqHqUv6WE3b8ZgcdCQMxpe87jGCkCnJOycBZTDXkrbgORH7DUbWdmaItfV 0Y8JUrOnq6wWpIM02WNBBfhjNOhk/ZQdok38vl4uL5jrcCrYDL84dJIBysYj4NfX4b vvUyAmlu3rATxBsA+a5+XVTsrkFHYQGgyRolQXlGekEYJ6lbThafew+qoz8ctJeOm7 FZunLr5T8JwOA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AF3DB69291 for ; Sat, 10 Jan 2026 13:30:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077033; bh=hH2wgwp7Ihn/aZbPeAv/cvF/taQOhzPo8zrmfzdebvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jiNbYhj3CYY6Rd9beqM3YudCfXnHhJw1GrNUIda9YMjCoaOugX+28xPzcZPXbfSRT GlPEtjyB5yUc36419odOifND5frds2hpH2AGpeUflcaxkwrQxlk57/e4KE6W6zuBoZ H2OX2g571kSrWLlbrT8VqUVMjT7s7kdPOqbrMPtP1EYvWc6JpVJM0/y+YRfSfB2u3i JyoJgDa8XdCtwhZ+d/3JgAfmIuPtOKgt9OXMLNmhvw/kjfKhJQPKUur+yJ3d4b8JEX g3G8+ylCnG9fYn5TDsg1yBeumyJVL1WjkQW/TKXtiWfD8UF5V6W+FvuDDGTxCLyCfk c0J1uMNanK+Hg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B79CF6927E; Sat, 10 Jan 2026 13:30:33 -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 MIDu-p_dDYKn; Sat, 10 Jan 2026 13:30:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077028; bh=micRvxuLfxGPwm5RUTAqoLUgJNEZ7jvIgUYx4vjEpCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NoGzS6m1RGYpQT/+paea35hG4DIKxg/+NoCwDD+IHsKV9zWYSTk31BNz8Y84p6/Rx +h2weCHcF4ZSs4IO96M3CtBeiVqusOQlLTZhK5VsHp3v4M1VTe7ib0P9IDFiZu4eLo wXd9VHK6ZnpybiG3N4y60pTFHrl8z8P09zC65nBKPxd+Se6b9vJG2oB7al5ZwBzbhL qPtBebOO2yD3j5vmdVbQrzb+qJIQGHaxCGhq5ye/CkeKW+QkEd7RDO8wKF4Jbdy5MU ZclhBRSSMcdHWmDDM8AZHX8tjBbo2qnkF6D74zFO3iRce+9QgJNFlNoqv5QWbs85eQ yPCeHxTpQ6pIw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D78D169186; Sat, 10 Jan 2026 13:30:27 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:48 -0700 Message-ID: <20260110202906.187370-17-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: IRKLEPMRQG3V5RLH4IGBE3VBFAOQR7HP X-Message-ID-Hash: IRKLEPMRQG3V5RLH4IGBE3VBFAOQR7HP 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/26] boot: pxe: Set pxe_file_size in extlinux_read_all() 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 extlinux_read_all() function calls pxe_probe() with a config file that is already loaded in bflow->buf. However, ctx->pxe_file_size is not set, so the parser receives a size of 0 and fails. Set ctx->pxe_file_size from bflow->size before calling pxe_probe(). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/ext_pxe_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 3b1412b86d3..930e54ea84d 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -136,6 +136,7 @@ int extlinux_read_all(struct udevice *dev, struct bootflow *bflow, if (ret) return log_msg_ret("era", ret); addr = map_to_sysmem(bflow->buf); + plat->ctx.pxe_file_size = bflow->size; ret = pxe_probe(&plat->ctx, addr, false); if (ret) return log_msg_ret("elb", -EFAULT); 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 */ 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 From patchwork Sat Jan 10 20:28:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1465 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=1768077048; bh=0O0EyQ4eQIVcDPb6xIws+HjkXmlSFrY8Jj5IQQSKaNM=; 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=VEN28XY3z9FhD8R+ywprk05TFGiNh0PuH7sXCNaGCTlCcQUN5pKxGp+4JCImoBRct E5Vjdll6IeSGGAh6RMA31tZQM4ePMjzwhnERux/m3q1YgtryPkDOAiMtvQheoHktcW WY8QUhSL0BhqyLhVw9dRIfYqr5tR7irk0us4U0OMH3+cUuLyCIaV17ANCLFA+Kl5bQ +7RHy2IdWYugEFjENHwn97C1yKwx82i/wunTNTCN53MeK2vYHYTR0Q1v4d2hoH3dLP zdDin/UewN06iYmTeztOABCdOjO+2UZvslXjM2rJEgxyonzDH1rstsVlH2Ioj5l3E8 62dIfcKtZPvCg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7484369299 for ; Sat, 10 Jan 2026 13:30:48 -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 66Wu5DvGb8MX for ; Sat, 10 Jan 2026 13:30:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077048; bh=0O0EyQ4eQIVcDPb6xIws+HjkXmlSFrY8Jj5IQQSKaNM=; 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=VEN28XY3z9FhD8R+ywprk05TFGiNh0PuH7sXCNaGCTlCcQUN5pKxGp+4JCImoBRct E5Vjdll6IeSGGAh6RMA31tZQM4ePMjzwhnERux/m3q1YgtryPkDOAiMtvQheoHktcW WY8QUhSL0BhqyLhVw9dRIfYqr5tR7irk0us4U0OMH3+cUuLyCIaV17ANCLFA+Kl5bQ +7RHy2IdWYugEFjENHwn97C1yKwx82i/wunTNTCN53MeK2vYHYTR0Q1v4d2hoH3dLP zdDin/UewN06iYmTeztOABCdOjO+2UZvslXjM2rJEgxyonzDH1rstsVlH2Ioj5l3E8 62dIfcKtZPvCg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5FF5569291 for ; Sat, 10 Jan 2026 13:30:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077046; bh=WtBunDvvKMcvsyAuUVn+HvptxZ8oDY86x1FEh+60Ws4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hGC584EoHRQ45m0fDEVgvFkSbRGyMT6z/5pMQyjRFMyMfcn3MkuJSvM1gw2/j825x TeGyb6/hKSiaRylJDMnmMkpUKO/gRWPKQyeXh61YS9kZjWnm/sktWAElXeL+2Ld8vp x7EOdPw70o+IiJ00A/MDiGgWEtx46O4CZ+V4zEZG7AMQYog2Fn89dTcCpqmgcx+t75 OYVE6Dwc2pqD5CwxscNiVPKXzF+lHjKFlshcIPtdYCvCsnowAlLcn+LFJbi5qEZabd lFlXobz6XFtSNjCp6656sJilsWB/qR3iZ4OQZyAQFuV1fDs3sE436Iv3mBgHHNg2lP rgkv/53J0MMyw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4BD8B6927E; Sat, 10 Jan 2026 13:30:46 -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 XzQd_hEH9hlU; Sat, 10 Jan 2026 13:30:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077042; bh=+8bzvZD2Guk0oPKaEI+lkvSI6qFb1tHmCRX3F2pxasM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ri8AX52Cg63rcqhb9CGGDVLyKjvFLdr7gpb+9Aq6l67p1oz9RwwCsj2kl880WKOKT 3FmITYssSzXsUbRO0HI4aImlvrDoYtTkSn9tZ6+OLuhkJ9Po+f1SVZZvzNPuOzs/d+ X3wIZc5T5NH38s6VODy7rENDD+T4VxtTD0UwCcBGDpPPvgxQZ40WiFWKQJsLeWeSpv WYr67bfDcWp9S2CUO9N8IIgSaB9QwjmO/h/DXeIjO/HMB/D9ubJrmHa+i7afO27DVa BdEVKarZVLhuQRWKxGWIncrEKLUifiXWFWCNoV/rceFI0mk8BRgNVuybr3QgkwALeR JNlktUyQwy/cg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DCC1C69186; Sat, 10 Jan 2026 13:30:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:51 -0700 Message-ID: <20260110202906.187370-20-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: YRCOQSRMQWM6BWSDFWJPPBEKMN6XQ7TO X-Message-ID-Hash: YRCOQSRMQWM6BWSDFWJPPBEKMN6XQ7TO 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 19/26] boot: pxe: Update parse_pxefile() to take struct abuf 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 Change parse_pxefile() to accept a struct abuf instead of separate address and size parameters. This provides a cleaner interface and allows the function to use abuf_data() directly without needing to call map_sysmem(). Callers now create an abuf with abuf_map_sysmem() to wrap the memory region before calling parse_pxefile(). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 12 +++++------- include/pxe_utils.h | 9 ++++----- test/boot/pxe.c | 20 +++++++++++++++----- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 3f751f25bea..d2ba0412906 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1004,20 +1004,16 @@ void pxe_menu_uninit(struct pxe_menu *cfg) free(cfg); } -struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg, - ulong size) +struct pxe_menu *parse_pxefile(struct pxe_context *ctx, struct abuf *buf) { struct pxe_menu *cfg; - char *buf; int r; cfg = pxe_menu_init(); if (!cfg) return NULL; - buf = map_sysmem(menucfg, size); - r = parse_pxefile_top(ctx, buf, menucfg, cfg, 1); - unmap_sysmem(buf); + r = parse_pxefile_top(ctx, abuf_data(buf), abuf_addr(buf), cfg, 1); if (r < 0) { pxe_menu_uninit(cfg); @@ -1305,9 +1301,11 @@ static struct pxe_menu *pxe_prepare(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) { struct pxe_menu *cfg; + struct abuf buf; int ret; - cfg = parse_pxefile(ctx, pxefile_addr_r, ctx->pxe_file_size); + abuf_init_addr(&buf, pxefile_addr_r, ctx->pxe_file_size); + cfg = parse_pxefile(ctx, &buf); if (!cfg) { printf("Error parsing config file\n"); return NULL; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index e8045511c6a..9682956932b 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -3,6 +3,7 @@ #ifndef __PXE_UTILS_H #define __PXE_UTILS_H +#include #include #include #include @@ -292,19 +293,17 @@ int get_pxelinux_path(struct pxe_context *ctx, const char *file, void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg); /** - * parse_pxefile() - Parse a pxe file + * parse_pxefile() - Parse a PXE file * * Parse the top-level file. Any includes are stored in cfg->includes and * should be processed by calling pxe_process_includes(). * * @ctx: PXE context (provided by the caller) - * @menucfg: Address of the PXE file in memory - * @size: Size of file in bytes + * @buf: Buffer containing the PXE file * 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, - ulong size); +struct pxe_menu *parse_pxefile(struct pxe_context *ctx, struct abuf *buf); /** * pxe_process_includes() - Process include files in a parsed menu diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 1a990a8e348..56b1dfb4c49 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -139,6 +139,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) struct pxe_context ctx; struct pxe_label *label; struct pxe_menu *cfg; + struct abuf buf; char name[16]; uint i; int ret; @@ -161,7 +162,8 @@ 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, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Process any include files */ @@ -448,6 +450,7 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) struct pxe_label *label; struct pxe_menu *cfg; ulong addr = PXE_LOAD_ADDR; + struct abuf buf; void *fdt; ut_assertnonnull(fs_image); @@ -465,7 +468,8 @@ 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, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Consume parsing output */ @@ -557,6 +561,7 @@ static int pxe_test_errors_norun(struct unit_test_state *uts) struct pxe_label *label; struct pxe_menu *cfg; ulong addr = PXE_LOAD_ADDR; + struct abuf buf; void *fdt; ut_assertnonnull(fs_image); @@ -574,7 +579,8 @@ 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, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Consume parsing output */ @@ -675,6 +681,7 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) struct pxe_label *label; struct pxe_menu *cfg; ulong addr = PXE_LOAD_ADDR; + struct abuf buf; void *fdt; ut_assertnonnull(fs_image); @@ -693,7 +700,8 @@ 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, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Process any include files */ @@ -1248,6 +1256,7 @@ static int pxe_test_fit_embedded_fdt_norun(struct unit_test_state *uts) struct pxe_label *label; struct pxe_menu *cfg; ulong addr = PXE_LOAD_ADDR; + struct abuf buf; ut_assertnonnull(fs_image); ut_assertnonnull(cfg_path); @@ -1268,7 +1277,8 @@ 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, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Consume parsing output */ From patchwork Sat Jan 10 20:28:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1466 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=1768077051; bh=UmieXbEfq1LnV+YNYcHLRTnWmr9gs7YDGH0V6WKXJmM=; 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=h+w+j63MVEohfhPBgqj0sLfr/Hi8+w67JxQkEAL11vuDDzweRNhs24yYTye+rODOr se7O0sN3bXQK5ITZfHwOPP/x3lEUpCuLutvY0zBkisFOaDu88YzqDw3srhi7rf+h5/ 5d4xLjTkTgXB84VHd+T3J6xinLIsKzrDixaaZKW1AKyCT6gm0vuPm/AmKjNswWhteU 7ULViBsh/dASmrdSU5VqiGXKor5rGKdfBM73PKW3zay73v2wEr4FaHhdTylJ4UcZUR sMsIDn/mPXNBzKgLnJfW/6kXJ1MAV1IvsfQy/P9jLty7md7UR0qNX7OMgf18H+i0wm VOADIMavYaZTg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E6DDA69291 for ; Sat, 10 Jan 2026 13:30:51 -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 7w8fUi2boIBQ for ; Sat, 10 Jan 2026 13:30:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077051; bh=UmieXbEfq1LnV+YNYcHLRTnWmr9gs7YDGH0V6WKXJmM=; 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=h+w+j63MVEohfhPBgqj0sLfr/Hi8+w67JxQkEAL11vuDDzweRNhs24yYTye+rODOr se7O0sN3bXQK5ITZfHwOPP/x3lEUpCuLutvY0zBkisFOaDu88YzqDw3srhi7rf+h5/ 5d4xLjTkTgXB84VHd+T3J6xinLIsKzrDixaaZKW1AKyCT6gm0vuPm/AmKjNswWhteU 7ULViBsh/dASmrdSU5VqiGXKor5rGKdfBM73PKW3zay73v2wEr4FaHhdTylJ4UcZUR sMsIDn/mPXNBzKgLnJfW/6kXJ1MAV1IvsfQy/P9jLty7md7UR0qNX7OMgf18H+i0wm VOADIMavYaZTg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D6CA569296 for ; Sat, 10 Jan 2026 13:30:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077050; bh=SH+rYp9MDZSOhoLmNIE+rq9X93EVqfMuxxMFgKQHEBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oYofg/bY7Y8K3Jv3yifyf28/+GT02tDW3euotZSYagCAV60EwKuABVHBfD5rv6J0O yj2Kk/xg1fyIWMzMJe1xSm4HqqwHetjkGD5iYDshSitJdEplCMpOTMvbrMJBgbHfmX M2xarXnO+jY2dLJB7iB6rGcGjQXfT6IqgtNjmRi+yRmIzu1Q4WcS5XwuQVnGDOs12U CyEGVNvwKkbhKJU86aYHGZv7J+JsCcr5tnmDCBXqDznSBIClI5FdFgDxYHIriO/OrN JmID+XKiA2Gf7qlPiwGYfL4zQM+p3y4QabaGNHtmrZId6RAfh0p+BAsdSKXN930qKP huEl9sO+nNQqg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E0A796927E; Sat, 10 Jan 2026 13:30:50 -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 iyoMhtib_Ulh; Sat, 10 Jan 2026 13:30:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077046; bh=mJRDb/anzgA8ZOQyHABfSwRVg09uf5HlyqWQTwkWdu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=twJWNNIJVms0LGFnXmYBJ0OrOo8igt6JnXucr6uwca2k++QGZoAAr0fn/Z3Z/LmnN pLr8fAzGbAGNc3D7Eq33Mzm6X7jTqAR0bLAZOuqJfbX0k8uBEELHzgjHEMlknNoq5w k+kVRsQulT9+7XfCfM2drOc6XtHfZSAo3TiOwix4hKctFp0JVgCp05E/ULRIPEkUjC l/+t6PXb57BD1FP8oOQjW0WMGQa+k9d1CsO0jLbmRgDwoVDvOFUVp7G/JBW2J1kPur ErI3apcXmVwvvbK9XvJVffWJ4YSF5hoAQlbl1RKwh+m+1+FPPG15wOIB8zzW8+xcAr kGOyz+HHU2Y+Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8D16E69186; Sat, 10 Jan 2026 13:30:46 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:52 -0700 Message-ID: <20260110202906.187370-21-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: M4CVXZNSXWZCBQXP5NZAFVBGFKYM746O X-Message-ID-Hash: M4CVXZNSXWZCBQXP5NZAFVBGFKYM746O 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 20/26] boot: pxe: Remove unused base parameter from parse_menu() 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_menu() function takes a base parameter but never uses it. Remove this dead parameter. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index bcbe0495cbb..52216c0b7ef 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -460,7 +460,7 @@ static int handle_include(char **c, struct pxe_menu *cfg, int nest_level) * a file it includes, 3 when parsing a file included by that file, and so on. */ static int parse_menu(struct pxe_context *ctx, char **c, struct pxe_menu *cfg, - unsigned long base, int nest_level) + int nest_level) { struct token t; char *s = *c; @@ -714,9 +714,7 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, ulong base, switch (t.type) { case T_MENU: cfg->prompt = 1; - err = parse_menu(ctx, &p, cfg, - base + ALIGN(strlen(b) + 1, 4), - nest_level); + err = parse_menu(ctx, &p, cfg, nest_level); break; case T_TIMEOUT: err = parse_integer(&p, &cfg->timeout); From patchwork Sat Jan 10 20:28:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1467 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=1768077057; bh=8xQboB7CplAXRhnsmCk+WWzYt4yISfL9hCsIj9y4K/U=; 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=eIdVqR+uhOp1AGbG31bhaoJSHXsyNqWmsfWPgp6OIuOdsF9ZD6JW1UBRubX79K/3y pS759hH77XyKYPyF8y+TWzKpXMFTwZfZsrBGtSktuG/DYUicz3QZTklOkFzm6J/pD8 GeudxNDA333axYXqBOa4uckC0PzTTq8hYgnAj0UOOwb1R8vTaxEXlgtOGxI3B1qwkL 6CyJpQQfP3NGwapIo3ADxQNZqBEhRPvya4TeTTj/ZafxeA0kSMc+AOCtMJXYI2dKAr ocdmESY8fbeticZCW3Ff/BTfAcbPILnSMPM8QjxMKHczYIigcqMGDAULyUoh+yeYEk HY5ewyo+jqjzw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CEF23692A6 for ; Sat, 10 Jan 2026 13:30:57 -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 M8KbbC7WlHHH for ; Sat, 10 Jan 2026 13:30:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077057; bh=8xQboB7CplAXRhnsmCk+WWzYt4yISfL9hCsIj9y4K/U=; 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=eIdVqR+uhOp1AGbG31bhaoJSHXsyNqWmsfWPgp6OIuOdsF9ZD6JW1UBRubX79K/3y pS759hH77XyKYPyF8y+TWzKpXMFTwZfZsrBGtSktuG/DYUicz3QZTklOkFzm6J/pD8 GeudxNDA333axYXqBOa4uckC0PzTTq8hYgnAj0UOOwb1R8vTaxEXlgtOGxI3B1qwkL 6CyJpQQfP3NGwapIo3ADxQNZqBEhRPvya4TeTTj/ZafxeA0kSMc+AOCtMJXYI2dKAr ocdmESY8fbeticZCW3Ff/BTfAcbPILnSMPM8QjxMKHczYIigcqMGDAULyUoh+yeYEk HY5ewyo+jqjzw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B9AFB69291 for ; Sat, 10 Jan 2026 13:30:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077055; bh=pmDJGutB0dYUHHowfSfcKg1y5WvmU3o/NTUO319qULk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aAUz3fJj82u1NO3bOQsOwrmcKjs6CgD//djRuMIN2xuz2aT5CXTOxnUj7KwW+74Wl XpjnCCQSCaezPEiUgRkN3OIzHTHi6Y1NrF6B6dmoWvKfbJpODgesQSlzwmRT4zBjL4 Q5DfKdve/UtZnVGBaZjvFQkF3izFZJarvNt2AknVpMcl3BCXzIX+CaawIQMPaTSoqO XLFxzPldnK7SpoZmczzIj/tNyB07mFO/jdegNNrqRu/oe7rrtGS98slVy6LZX8kzCi F/a+m2otKGhyQ666l79ydUMmAWkJcXeuThRbcuuIh7hZFLyuVt4dQEoQ++QK/bCFHy 9COs3OEbVMIsw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 941366927E; Sat, 10 Jan 2026 13:30:55 -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 oqxRh2LeaYdm; Sat, 10 Jan 2026 13:30:55 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077051; bh=wphXtadLjg5Xuo5bRC4I96vbVVRw5USFljRVUvA/fnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XwHj9LO0eL0MjA7EfD7cHSqxUiTs2YPk8aAsRiBGo7gU7vgqBwQ+fkgErzKKEJAFj rBNbKaUmOX6AJnH2rElk/H8oA1ZfL0D+nfXNHA4kVedFHYYzUg4zfx9qekKe4B2N1s MSyX4ftxb5yW1jMxG+ispVoNpBjlvW0rTigGfFGMcGxnZBAkUxJwyVjhGWuSeNXTR7 DnczIAdvMUMtQkOwTQdNB7PK5MXg+oRKB5Dqklav3Y+SyGvNCI31NmoK4nV2bz/iJL hCYS5ztGTGLCqsiJTeD4zQ1mSBHoFVWDMFEWZAhCbWRVtXDSI/qoDf8K+q8a5c1fad Q89WYGtdT7Nfw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 36F5969186; Sat, 10 Jan 2026 13:30:51 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:53 -0700 Message-ID: <20260110202906.187370-22-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: 6I7HAUKLFUTZIAIDSHGBAYZSLAWGS7RV X-Message-ID-Hash: 6I7HAUKLFUTZIAIDSHGBAYZSLAWGS7RV 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 21/26] boot: pxe: Remove unused base parameter from parse_pxefile_top() 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_top() function takes a base parameter but never uses it. Remove this dead parameter. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 2 +- boot/pxe_utils.c | 4 ++-- include/pxe_utils.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 52216c0b7ef..3d113a6fd83 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -691,7 +691,7 @@ static int parse_label(char **c, struct pxe_menu *cfg) */ #define MAX_NEST_LEVEL 16 -int parse_pxefile_top(struct pxe_context *ctx, char *p, ulong base, +int parse_pxefile_top(struct pxe_context *ctx, char *p, struct pxe_menu *cfg, int nest_level) { struct token t; diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index d2ba0412906..b5320f2f6cf 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1013,7 +1013,7 @@ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, struct abuf *buf) if (!cfg) return NULL; - r = parse_pxefile_top(ctx, abuf_data(buf), abuf_addr(buf), cfg, 1); + r = parse_pxefile_top(ctx, abuf_data(buf), cfg, 1); if (r < 0) { pxe_menu_uninit(cfg); @@ -1069,7 +1069,7 @@ int pxe_parse_include(struct pxe_context *ctx, const struct pxe_include *inc, int ret; buf = map_sysmem(addr, 0); - ret = parse_pxefile_top(ctx, buf, addr, inc->cfg, inc->nest_level); + ret = parse_pxefile_top(ctx, buf, inc->cfg, inc->nest_level); unmap_sysmem(buf); return ret; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 9682956932b..11be00da199 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -510,7 +510,7 @@ int pxe_setup_label(struct pxe_context *ctx, struct pxe_label *label); * * Returns 1 on success, < 0 on error. */ -int parse_pxefile_top(struct pxe_context *ctx, char *p, ulong base, +int parse_pxefile_top(struct pxe_context *ctx, char *p, struct pxe_menu *cfg, int nest_level); /** From patchwork Sat Jan 10 20:28:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1468 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=1768077062; bh=SGuMucpZembfnM1iFMrAWsEVhAravcM/BRxla6SiaC4=; 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=pI27k/n9PNc5QRo8U8ggwum+3xd6Qt4g6k1IBp0R9TuvUcwOi7MPeUmqHFh9SAkzQ EmAFrs/MRt0F9IG2DophcRVBehODoJgJSbd4RmwQRkF3AU5eDcz46iex1G6wYioZ2I DXWQz3R7wlfJZS/6lUoTRlZZIpm+Ug0an/+SfGpRZzcBudmXHef6sL3XEwCGvJsG9b 4xaJ3bXyntmBRhtryMr2IKmW5MCtM2pva9g1vx4yi2wZcQnTrvhM7fvTW8oCle38lK eca7GzJIs2eVmANH6P0PjkbC5XVbU6+SSDx9V7n4tCxOcpycM/hvZ30Ara6lIzesmF TaU70m5PcAk6w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52B7C6927E for ; Sat, 10 Jan 2026 13:31:02 -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 k2BgI0ypS60N for ; Sat, 10 Jan 2026 13:31:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077062; bh=SGuMucpZembfnM1iFMrAWsEVhAravcM/BRxla6SiaC4=; 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=pI27k/n9PNc5QRo8U8ggwum+3xd6Qt4g6k1IBp0R9TuvUcwOi7MPeUmqHFh9SAkzQ EmAFrs/MRt0F9IG2DophcRVBehODoJgJSbd4RmwQRkF3AU5eDcz46iex1G6wYioZ2I DXWQz3R7wlfJZS/6lUoTRlZZIpm+Ug0an/+SfGpRZzcBudmXHef6sL3XEwCGvJsG9b 4xaJ3bXyntmBRhtryMr2IKmW5MCtM2pva9g1vx4yi2wZcQnTrvhM7fvTW8oCle38lK eca7GzJIs2eVmANH6P0PjkbC5XVbU6+SSDx9V7n4tCxOcpycM/hvZ30Ara6lIzesmF TaU70m5PcAk6w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3F79769291 for ; Sat, 10 Jan 2026 13:31:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077060; bh=/TOkdAQuiq3djO64Wcs04bPS8Zjsju9stHuIcX2SGfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kY/Mue/ah6SNKdAOb7PeBKO3CRApQvRMBUOseXiNlsmJyI2Vt9j4ikaZNVQGqzOgY z0P9Y9kjz6ZRr2p2VhHwGUiL7o7JH2CHdAu2rJbYd7dK7Fi3Pc2jbcx+Ny6dWC0QqE w9Bptt260CrWGOXSxP2PCbh6SrVvXYob4NYRjJzfU7xxHZb9I6AhjM8LUNDPocYht9 iTjIfmZSsn2RdrOHnxNMSyJYTe2XUHzO9jN2GY7H27BzsTqhuIJOYpE852lQa97dLR YKGKnVBxD8K4mc8riSYxyLp2MjNn1g1zSpu9ZaVuUjKqW1uljepeyksXblxSOg+lC5 v7bBAcaX9SQ+Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51C5F6927E; Sat, 10 Jan 2026 13:31:00 -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 wDzI1ukBJAiM; Sat, 10 Jan 2026 13:31:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077056; bh=Ty/6NFl0kQickjlykc5C/af1zU6JgtDtQ2NulonviNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F7oRam4iPY7hAsOevsdHpMcDldnOWlmiETU6zBu6+3qKpSsHXjUFN2DbKV6vVNkUQ JyIvT3xQr3c8Bpo3TddRixYYR9ujSDPzCjnETws5GbCZtWwkLHlGJlOa3oVoYOS+hp lbbzmUEZzVibb+QQWfatuBGXIQgRSj+VvyKTsX6z0VHldSADjNMG6PKy52EKZcHwig MEwKcIVGm256tlXfDJ7k9+OI8LOVaBZTK1ArXzHCrGqQ0puNf+2cH+1ih8zvqoxkxP QBk7g70Oh+1yM9SwtlcysTAOKgbSiRQLfrckvVwtGFKOAqtVViGNU9p6UGSMrGTGqJ OKfpaDYfvVewg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D6D7A69186; Sat, 10 Jan 2026 13:30:55 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:54 -0700 Message-ID: <20260110202906.187370-23-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: 24IBIYX5FXH4U3CPLT6USN4FKR5YLJI4 X-Message-ID-Hash: 24IBIYX5FXH4U3CPLT6USN4FKR5YLJI4 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 22/26] boot: pxe: Add a limit parameter to parser 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 Add a `const char *limit` parameter to get_string() and propagate it through all parser functions. This allows the parser to properly detect the end of the buffer without relying solely on a nul terminator. The limit parameter represents the position of the nul terminator (i.e. the end of valid data), allowing the while loop in get_string() to check both *e and e < limit. This provides an additional safety check against buffer overruns. Update all callers in parse_pxefile() and pxe_parse_include() to pass the appropriate limit based on buffer size. Also add a size parameter to pxe_parse_include() so callers pass the size explicitly. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 102 ++++++++++++++++++++++++-------------------- boot/pxe_utils.c | 13 +++--- include/pxe_utils.h | 15 ++++--- 3 files changed, 73 insertions(+), 57 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 3d113a6fd83..42f9125cb1d 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -155,9 +155,11 @@ void label_destroy(struct pxe_label *label) * @t: Pointers to a token to fill in * @delim: Delimiter character to look for, either newline or space * @lower: true to convert the string to lower case when storing + * @limit: End of buffer (position of nul terminator) * Returns the new value of t->val, on success, NULL if out of memory */ -static char *get_string(char **p, struct token *t, char delim, int lower) +static char *get_string(char **p, struct token *t, char delim, int lower, + const char *limit) { char *b, *e; size_t len, i; @@ -170,7 +172,7 @@ static char *get_string(char **p, struct token *t, char delim, int lower) */ b = *p; e = *p; - while (*e) { + while (*e && e < limit) { if ((delim == ' ' && isspace(*e)) || delim == *e) break; e++; @@ -227,8 +229,12 @@ static void get_keyword(struct token *t) * * @p: Points to a pointer to the current position in the input being processed. * Updated to point at the first character after the current token + * @t: Token to fill in + * @state: Lexer state (keyword or string literal) + * @limit: End of buffer (position of nul terminator) */ -static void get_token(char **p, struct token *t, enum lex_state state) +static void get_token(char **p, struct token *t, enum lex_state state, + const char *limit) { char *c = *p; @@ -251,11 +257,11 @@ static void get_token(char **p, struct token *t, enum lex_state state) if (*c == '\n') { t->type = T_EOL; c++; - } else if (*c == '\0') { + } else if (*c == '\0' || c >= limit) { t->type = T_EOF; c++; } else if (state == L_SLITERAL) { - get_string(&c, t, '\n', 0); + get_string(&c, t, '\n', 0, limit); } else if (state == L_KEYWORD) { /* * when we expect a keyword, we first get the next string @@ -264,7 +270,7 @@ static void get_token(char **p, struct token *t, enum lex_state state) * converted to a keyword token of the appropriate type, and * if not, it remains a string token. */ - get_string(&c, t, ' ', 1); + get_string(&c, t, ' ', 1, limit); get_keyword(t); } @@ -296,12 +302,12 @@ static void eol_or_eof(char **c) * Parse a string literal and store a pointer it at *dst. String literals * terminate at the end of the line. */ -static int parse_sliteral(char **c, char **dst) +static int parse_sliteral(char **c, char **dst, const char *limit) { struct token t; char *s = *c; - get_token(c, &t, L_SLITERAL); + get_token(c, &t, L_SLITERAL, limit); if (t.type != T_STRING) { printf("Expected string literal: %.*s\n", (int)(*c - s), s); return -EINVAL; @@ -357,12 +363,13 @@ static int label_add_file(struct pxe_label *label, const char *path, /* * Parse a space-separated list of overlay paths into a label's file list. */ -static int parse_fdtoverlays(char **c, struct pxe_label *label) +static int parse_fdtoverlays(char **c, struct pxe_label *label, + const char *limit) { char *val, *start; int err; - err = parse_sliteral(c, &val); + err = parse_sliteral(c, &val, limit); if (err < 0) return err; start = val; @@ -404,12 +411,12 @@ static int parse_fdtoverlays(char **c, struct pxe_label *label) /* * Parse a base 10 (unsigned) integer and store it at *dst. */ -static int parse_integer(char **c, int *dst) +static int parse_integer(char **c, int *dst, const char *limit) { struct token t; char *s = *c; - get_token(c, &t, L_SLITERAL); + get_token(c, &t, L_SLITERAL, limit); if (t.type != T_STRING) { printf("Expected string: %.*s\n", (int)(*c - s), s); return -EINVAL; @@ -427,13 +434,14 @@ static int parse_integer(char **c, int *dst) * The include is added to cfg->includes. The caller is responsible for * loading these files and calling pxe_parse_include() to parse them. */ -static int handle_include(char **c, struct pxe_menu *cfg, int nest_level) +static int handle_include(char **c, struct pxe_menu *cfg, int nest_level, + const char *limit) { struct pxe_include inc; char *s = *c; int err; - err = parse_sliteral(c, &inc.path); + err = parse_sliteral(c, &inc.path, limit); if (err < 0) { printf("Expected include path: %.*s\n", (int)(*c - s), s); return err; @@ -460,24 +468,24 @@ static int handle_include(char **c, struct pxe_menu *cfg, int nest_level) * a file it includes, 3 when parsing a file included by that file, and so on. */ static int parse_menu(struct pxe_context *ctx, char **c, struct pxe_menu *cfg, - int nest_level) + int nest_level, const char *limit) { struct token t; char *s = *c; int err = 0; t.val = NULL; - get_token(c, &t, L_KEYWORD); + get_token(c, &t, L_KEYWORD, limit); switch (t.type) { case T_TITLE: - err = parse_sliteral(c, &cfg->title); + err = parse_sliteral(c, &cfg->title, limit); break; case T_INCLUDE: - err = handle_include(c, cfg, nest_level); + err = handle_include(c, cfg, nest_level, limit); break; case T_BACKGROUND: - err = parse_sliteral(c, &cfg->bmp); + err = parse_sliteral(c, &cfg->bmp, limit); break; default: printf("Ignoring malformed menu command: %.*s\n", @@ -496,14 +504,14 @@ static int parse_menu(struct pxe_context *ctx, char **c, struct pxe_menu *cfg, * Handles parsing a 'menu line' when we're parsing a label. */ static int parse_label_menu(char **c, struct pxe_menu *cfg, - struct pxe_label *label) + struct pxe_label *label, const char *limit) { struct token t; char *s; s = *c; t.val = NULL; - get_token(c, &t, L_KEYWORD); + get_token(c, &t, L_KEYWORD, limit); switch (t.type) { case T_DEFAULT: @@ -515,7 +523,7 @@ static int parse_label_menu(char **c, struct pxe_menu *cfg, break; case T_LABEL: - parse_sliteral(c, &label->menu); + parse_sliteral(c, &label->menu, limit); break; default: printf("Ignoring malformed menu command: %.*s\n", @@ -532,12 +540,13 @@ static int parse_label_menu(char **c, struct pxe_menu *cfg, * Handles parsing a 'kernel' label. * expecting "filename" or "#cfg" */ -static int parse_label_kernel(char **c, struct pxe_label *label) +static int parse_label_kernel(char **c, struct pxe_label *label, + const char *limit) { char *s; int err; - err = parse_sliteral(c, &label->kernel); + err = parse_sliteral(c, &label->kernel, limit); if (err < 0) return err; @@ -565,7 +574,7 @@ static int parse_label_kernel(char **c, struct pxe_label *label) * get some input we otherwise don't have a handler defined * for. */ -static int parse_label(char **c, struct pxe_menu *cfg) +static int parse_label(char **c, struct pxe_menu *cfg, const char *limit) { struct token t; int len; @@ -577,7 +586,7 @@ static int parse_label(char **c, struct pxe_menu *cfg) if (!label) return -ENOMEM; - err = parse_sliteral(c, &label->name); + err = parse_sliteral(c, &label->name, limit); if (err < 0) { printf("Expected label name: %.*s\n", (int)(*c - s), s); label_destroy(label); @@ -589,20 +598,20 @@ static int parse_label(char **c, struct pxe_menu *cfg) while (1) { s = *c; free(t.val); - get_token(c, &t, L_KEYWORD); + get_token(c, &t, L_KEYWORD, limit); err = 0; switch (t.type) { case T_MENU: - err = parse_label_menu(c, cfg, label); + err = parse_label_menu(c, cfg, label, limit); break; case T_KERNEL: case T_LINUX: case T_FIT: - err = parse_label_kernel(c, label); + err = parse_label_kernel(c, label, limit); break; case T_APPEND: - err = parse_sliteral(c, &label->append); + err = parse_sliteral(c, &label->append, limit); if (label->initrd) break; s = strstr(label->append, "initrd="); @@ -617,7 +626,7 @@ static int parse_label(char **c, struct pxe_menu *cfg) break; case T_INITRD: if (!label->initrd) { - err = parse_sliteral(c, &label->initrd); + err = parse_sliteral(c, &label->initrd, limit); if (err < 0) break; err = label_add_file(label, label->initrd, @@ -626,7 +635,7 @@ static int parse_label(char **c, struct pxe_menu *cfg) break; case T_FDT: if (!label->fdt) { - err = parse_sliteral(c, &label->fdt); + err = parse_sliteral(c, &label->fdt, limit); if (err < 0) break; err = label_add_file(label, label->fdt, PFT_FDT); @@ -634,18 +643,18 @@ static int parse_label(char **c, struct pxe_menu *cfg) break; case T_FDTDIR: if (!label->fdtdir) - err = parse_sliteral(c, &label->fdtdir); + err = parse_sliteral(c, &label->fdtdir, limit); break; case T_FDTOVERLAYS: if (!has_fdtoverlays(&label->files)) - err = parse_fdtoverlays(c, label); + err = parse_fdtoverlays(c, label, limit); break; case T_LOCALBOOT: label->localboot = 1; - err = parse_integer(c, &label->localboot_val); + err = parse_integer(c, &label->localboot_val, limit); break; case T_IPAPPEND: - err = parse_integer(c, &label->ipappend); + err = parse_integer(c, &label->ipappend, limit); break; case T_KASLRSEED: label->kaslrseed = 1; @@ -691,14 +700,13 @@ static int parse_label(char **c, struct pxe_menu *cfg) */ #define MAX_NEST_LEVEL 16 -int parse_pxefile_top(struct pxe_context *ctx, char *p, +int parse_pxefile_top(struct pxe_context *ctx, char *p, const char *limit, struct pxe_menu *cfg, int nest_level) { struct token t; - char *s, *b, *label_name; + char *s, *label_name; int err; - b = p; if (nest_level > MAX_NEST_LEVEL) { printf("Maximum nesting (%d) exceeded\n", MAX_NEST_LEVEL); return -EMLINK; @@ -708,23 +716,23 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, while (1) { s = p; free(t.val); - get_token(&p, &t, L_KEYWORD); + get_token(&p, &t, L_KEYWORD, limit); err = 0; switch (t.type) { case T_MENU: cfg->prompt = 1; - err = parse_menu(ctx, &p, cfg, nest_level); + err = parse_menu(ctx, &p, cfg, nest_level, limit); break; case T_TIMEOUT: - err = parse_integer(&p, &cfg->timeout); + err = parse_integer(&p, &cfg->timeout, limit); break; case T_LABEL: - err = parse_label(&p, cfg); + err = parse_label(&p, cfg, limit); break; case T_DEFAULT: case T_ONTIMEOUT: - err = parse_sliteral(&p, &label_name); + err = parse_sliteral(&p, &label_name, limit); if (label_name) { if (cfg->default_label) free(cfg->default_label); @@ -733,7 +741,7 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, } break; case T_FALLBACK: - err = parse_sliteral(&p, &label_name); + err = parse_sliteral(&p, &label_name, limit); if (label_name) { if (cfg->fallback_label) free(cfg->fallback_label); @@ -742,10 +750,10 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, } break; case T_INCLUDE: - err = handle_include(&p, cfg, nest_level); + err = handle_include(&p, cfg, nest_level, limit); break; case T_PROMPT: - err = parse_integer(&p, &cfg->prompt); + err = parse_integer(&p, &cfg->prompt, limit); // Do not fail if prompt configuration is undefined if (err < 0) eol_or_eof(&p); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index b5320f2f6cf..45f4d365878 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1007,13 +1007,15 @@ void pxe_menu_uninit(struct pxe_menu *cfg) struct pxe_menu *parse_pxefile(struct pxe_context *ctx, struct abuf *buf) { struct pxe_menu *cfg; + char *base; int r; cfg = pxe_menu_init(); if (!cfg) return NULL; - r = parse_pxefile_top(ctx, abuf_data(buf), cfg, 1); + base = abuf_data(buf); + r = parse_pxefile_top(ctx, base, base + buf->size, cfg, 1); if (r < 0) { pxe_menu_uninit(cfg); @@ -1053,7 +1055,7 @@ int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, return r; } - r = pxe_parse_include(ctx, inc, base); + r = pxe_parse_include(ctx, inc, base, ctx->pxe_file_size); if (r < 0) return r; @@ -1063,13 +1065,14 @@ int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, } int pxe_parse_include(struct pxe_context *ctx, const struct pxe_include *inc, - ulong addr) + ulong addr, ulong size) { char *buf; int ret; - buf = map_sysmem(addr, 0); - ret = parse_pxefile_top(ctx, buf, inc->cfg, inc->nest_level); + buf = map_sysmem(addr, size); + ret = parse_pxefile_top(ctx, buf, buf + size, inc->cfg, + inc->nest_level); unmap_sysmem(buf); return ret; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 11be00da199..6f2ac604d6e 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -504,13 +504,17 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label); */ int pxe_setup_label(struct pxe_context *ctx, struct pxe_label *label); -/* - * Entry point for parsing a menu file. nest_level indicates how many times - * we've nested in includes. It will be 1 for the top level menu file. +/** + * parse_pxefile_top() - Entry point for parsing a menu file * + * @ctx: PXE context + * @p: Start of buffer containing the PXE file + * @limit: End of buffer (position of nul terminator) + * @cfg: Menu to parse into + * @nest_level: Nesting level (1 for top level, higher for includes) * Returns 1 on success, < 0 on error. */ -int parse_pxefile_top(struct pxe_context *ctx, char *p, +int parse_pxefile_top(struct pxe_context *ctx, char *p, const char *limit, struct pxe_menu *cfg, int nest_level); /** @@ -538,9 +542,10 @@ void label_destroy(struct pxe_label *label); * @ctx: PXE context * @inc: Include info with path and target menu * @addr: Memory address where file is located + * @size: Size of the file in bytes * Return: 1 on success, -ve on error */ int pxe_parse_include(struct pxe_context *ctx, const struct pxe_include *inc, - ulong addr); + ulong addr, ulong size); #endif /* __PXE_UTILS_H */ From patchwork Sat Jan 10 20:28:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1469 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=1768077068; bh=ZIVsjToa9h/3bRWhf5djCxqUKEgOSBUss85HW62NcsM=; 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=iaP2PoiL+7fHKAS3duhZcHDulSYq+Ui8xQA31Obp8jPqUnUaA7fUFXZ+aFrN2KMTZ jPfguXRVmB/YuBoXMY8Gmk3OMvYNiGCvtG5HLx8+E0lKjbfHkNYST6QpixzAa2JTJI ++rNOuA+UfYCWSf/lbUPApQKAsnlT18lGmI8ymzSdPAl3DidX+lj4tBLs5Ex+j94pT kcSaI8XzgHicHcmO9JcwgWJbd9uhGKcgAP/keirLKM5qA9LUBbbkR1WcpcOy4Kp5UU alK/GqMPDneSySqEQ1Wb4tl6jKm4+nJd5fqnDj+068KoAAvA/9rhznIfZZ9HP9wWQ+ d8KL6JYGmXf4A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D4ABC69186 for ; Sat, 10 Jan 2026 13:31:08 -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 tu691x1qHOhz for ; Sat, 10 Jan 2026 13:31:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077068; bh=ZIVsjToa9h/3bRWhf5djCxqUKEgOSBUss85HW62NcsM=; 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=iaP2PoiL+7fHKAS3duhZcHDulSYq+Ui8xQA31Obp8jPqUnUaA7fUFXZ+aFrN2KMTZ jPfguXRVmB/YuBoXMY8Gmk3OMvYNiGCvtG5HLx8+E0lKjbfHkNYST6QpixzAa2JTJI ++rNOuA+UfYCWSf/lbUPApQKAsnlT18lGmI8ymzSdPAl3DidX+lj4tBLs5Ex+j94pT kcSaI8XzgHicHcmO9JcwgWJbd9uhGKcgAP/keirLKM5qA9LUBbbkR1WcpcOy4Kp5UU alK/GqMPDneSySqEQ1Wb4tl6jKm4+nJd5fqnDj+068KoAAvA/9rhznIfZZ9HP9wWQ+ d8KL6JYGmXf4A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C19B96927E for ; Sat, 10 Jan 2026 13:31:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077066; bh=OVcuTYwyiOVe85kSIR2BpF8tJW1XXcydwrPBCl9HzeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ndvmaOILhlw9m5gwJ1060kbXceJ9brgiIV7cjF2w9JBlg5nadXVcUj8+aw2u1/++H lQtrDCJ05hXAxwtzul9pQQpUDXXcSJrzSt+i/fxX7WLh7RHecJ6PvargC8thjDovYY 9MBjhTA4+ki1ueqlP28oYl/1IX9N+WCPVJri7kv6oMzIpsO7EUHSA0CifoV5cXAp6e cDf1BhJWaDW0j1tA9YxPGYPRVA2Ps03tbGWgZBRfxrvWaaDHaonhMvMvExdTTNfs+m 4S2LSHr23I6Qjslrv06Vp5lmVcUhCT3djkR+TpOpCgP3cBKkf2lykflLAIGXUrA5j4 MB0MmBbSirW/w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C40996927E; Sat, 10 Jan 2026 13:31: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 10026) with ESMTP id 4dvg_IJPK_bt; Sat, 10 Jan 2026 13:31:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077060; bh=Q+DbmnEVf2wx83xFyfnjrqD6n8sW+/SlA7bB7n8qEtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eOQU1tIgKqeCo9/k9z4+Rkhi2YgW5bgiCx0ngOm/uWXODCi4YT3tdy0pqUollWLlF +RJHLXPqecIvBs4F3g2+swPlDOynhw9Y6bHoi9Ft/VbL0P3Hw+a3KrMeXomzPREZr5 crSZ5DmFE57/+LWIRv9lmuFoktL0d2kQw29+n5//2MXxZXGhcTUg2ZUh6gwuxO7Aur xGzWNaACIWVMyWklmTsEA5KIcK0qndLZlkiyO9Xt4vG6SBE81T4robOtTA63yWIWo8 XqzSpeqeL2VjWV3/bEBE180+Z1Qqwbzo4lgnuuAQwKEWYWAb00pxCe9PlnyMnmSZPW VcvOrw/B51/pQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9508269186; Sat, 10 Jan 2026 13:31:00 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:55 -0700 Message-ID: <20260110202906.187370-24-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: 2WPI7GP6GQRQL57ERAEUROUNAMBRSXJV X-Message-ID-Hash: 2WPI7GP6GQRQL57ERAEUROUNAMBRSXJV 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 23/26] boot: pxe: Add a callback-free PXE API 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 Add functions for a callback-free PXE API: - pxe_parse() - Parse a PXE config file and return an allocated context - pxe_load() - Record file load address and size - pxe_cleanup() - Free menu and destroy context Also rename pxe_do_boot() to pxe_boot() for consistency. This API allows callers to parse PXE files, load files manually without callbacks, and boot the selected label. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/ext_pxe_common.c | 2 +- boot/pxe_utils.c | 45 +++++++++++++++++++++++++++++- include/pxe_utils.h | 64 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 106 insertions(+), 5 deletions(-) diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 2bc76a4d0fb..59d878883bf 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -107,7 +107,7 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, /* if we have already selected a label, just boot it */ if (plat->ctx.label) { plat->ctx.fake_go = bflow->flags & BOOTFLOWF_FAKE_GO; - ret = pxe_do_boot(&plat->ctx); + ret = pxe_boot(&plat->ctx); } else { ret = extlinux_setup(dev, bflow, getfile, allow_abs_path, bootfile, &plat->ctx); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 45f4d365878..5c1d08feebf 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1326,6 +1326,49 @@ static struct pxe_menu *pxe_prepare(struct pxe_context *ctx, return cfg; } +struct pxe_context *pxe_parse(ulong addr, ulong size, const char *bootfile) +{ + struct pxe_context *ctx; + struct abuf buf; + int ret; + + ctx = calloc(1, sizeof(*ctx)); + if (!ctx) + return NULL; + + ret = pxe_setup_ctx(ctx, NULL, NULL, true, bootfile, false, false, + NULL); + if (ret) { + free(ctx); + return NULL; + } + ctx->pxe_file_size = size; + + abuf_init_addr(&buf, addr, size); + ctx->cfg = parse_pxefile(ctx, &buf); + if (!ctx->cfg) { + pxe_destroy_ctx(ctx); + free(ctx); + return NULL; + } + + return ctx; +} + +void pxe_load(struct pxe_file *file, ulong addr, ulong size) +{ + file->addr = addr; + file->size = size; +} + +void pxe_cleanup(struct pxe_context *ctx) +{ + if (ctx->cfg) + pxe_menu_uninit(ctx->cfg); + pxe_destroy_ctx(ctx); + free(ctx); +} + int pxe_process(struct pxe_context *ctx, ulong addr, ulong size, bool prompt) { struct pxe_menu *cfg; @@ -1366,7 +1409,7 @@ int pxe_probe(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) return 0; } -int pxe_do_boot(struct pxe_context *ctx) +int pxe_boot(struct pxe_context *ctx) { int ret; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 6f2ac604d6e..bc9e3f29417 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -428,7 +428,7 @@ int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep, bool use_ipv6); * pxe_probe() - Process a PXE file to find the label to boot * * This fills in the label, etc. fields in @ctx, assuming it funds something to - * boot. Then pxe_do_boot() can be called to boot it. + * boot. Then pxe_boot() can be called to boot it. * * @ctx: PXE context created with pxe_setup_ctx() * @pxefile_addr_r: Address to load file @@ -438,13 +438,13 @@ int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep, bool use_ipv6); int pxe_probe(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt); /** - * pxe_do_boot() - Boot the selected label + * pxe_boot() - Boot the selected label * * This boots the label discovered by pxe_probe() * * Return: Does not return, on success, otherwise returns a -ve error code */ -int pxe_do_boot(struct pxe_context *ctx); +int pxe_boot(struct pxe_context *ctx); /** * pxe_select_label() - Select a label from a parsed menu @@ -539,6 +539,16 @@ void label_destroy(struct pxe_label *label); * to parse it and merge any labels into the target menu. This may add * more entries to cfg->includes if the included file has its own includes. * + * Example usage:: + * + * ctx = pxe_parse(addr, size, bootfile); + * + * // Load and process any includes + * alist_for_each(inc, &ctx->cfg->includes) { + * // read file inc->path to address 'addr', getting 'size' + * pxe_parse_include(ctx, inc, addr, size); + * } + * * @ctx: PXE context * @inc: Include info with path and target menu * @addr: Memory address where file is located @@ -548,4 +558,52 @@ void label_destroy(struct pxe_label *label); int pxe_parse_include(struct pxe_context *ctx, const struct pxe_include *inc, ulong addr, ulong size); +/** + * pxe_parse() - Parse a PXE config file and return an allocated context + * + * This allocates a PXE context, sets it up, and parses the config file at the + * given address. The menu is stored in ctx->cfg and can be used to inspect + * labels or select one for loading. + * + * Use pxe_cleanup() to clean up when done. + * + * Note: This does not process include files. Call pxe_process_includes() + * after this if needed. + * + * @addr: Address where config file is loaded + * @size: Size of config file in bytes + * @bootfile: Path to config file (for relative path resolution) + * Return: Allocated context on success, NULL on error + */ +struct pxe_context *pxe_parse(ulong addr, ulong size, const char *bootfile); + +/** + * pxe_load() - Report that a file has been loaded + * + * After loading a file from a label's files list, call this to record + * the load address and size. This information is used later during boot. + * + * Example:: + * + * alist_for_each(file, &label->files) { + * // choose 'addr', load file->path there, getting 'size' + * pxe_load(file, addr, size); + * } + * + * @file: File that was loaded + * @addr: Address where file was loaded + * @size: Size of loaded file + */ +void pxe_load(struct pxe_file *file, ulong addr, ulong size); + +/** + * pxe_cleanup() - Free PXE menu and destroy context + * + * This combines pxe_menu_uninit() and pxe_destroy_ctx() for convenience + * when cleaning up after using the callback-free API. + * + * @ctx: Context to destroy (ctx->cfg is freed if set) + */ +void pxe_cleanup(struct pxe_context *ctx); + #endif /* __PXE_UTILS_H */ From patchwork Sat Jan 10 20:28:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1470 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=1768077072; bh=q2MEHZ6jV8zF/ypI2IRnLIfNXnUMQ7Tijgnk3aDs60U=; 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=CBe9zG1b5b9Tyg12gVd5dg2TpXHNqXNFZ2WBglk4vnzEWBCl3+yT4iUEskkLUnwJ+ NhquYHpTNHewIGXm9bavLOMmdaSJKQ6ik2RF/6tjSDgQ964AGmDZv10jRpKJbAO2l4 v8G7PKjRrU4kT2Z2mXc1Rp43TT9kjWUis5w9VKM7eDr9YLDTY2ghIN2L+DYIKCaXXv ffjrJT33C3aRd9w9s1QPGdDguSE1s0mDmDW0765+mTtLaFphXrMmCRRCoow3s/fOiy v8jVzncM58fBpDTCHU/a76cIaoXYGDmrsspkiA72JYb86uV59Dg/hu6QZGEFCN2CSc tN2CIJU68CZDw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9D8EF692A6 for ; Sat, 10 Jan 2026 13:31:12 -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 WgSEuo6YZcVs for ; Sat, 10 Jan 2026 13:31:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077072; bh=q2MEHZ6jV8zF/ypI2IRnLIfNXnUMQ7Tijgnk3aDs60U=; 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=CBe9zG1b5b9Tyg12gVd5dg2TpXHNqXNFZ2WBglk4vnzEWBCl3+yT4iUEskkLUnwJ+ NhquYHpTNHewIGXm9bavLOMmdaSJKQ6ik2RF/6tjSDgQ964AGmDZv10jRpKJbAO2l4 v8G7PKjRrU4kT2Z2mXc1Rp43TT9kjWUis5w9VKM7eDr9YLDTY2ghIN2L+DYIKCaXXv ffjrJT33C3aRd9w9s1QPGdDguSE1s0mDmDW0765+mTtLaFphXrMmCRRCoow3s/fOiy v8jVzncM58fBpDTCHU/a76cIaoXYGDmrsspkiA72JYb86uV59Dg/hu6QZGEFCN2CSc tN2CIJU68CZDw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8782F69184 for ; Sat, 10 Jan 2026 13:31:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077071; bh=Q6NSG6eu+bB0kAtJlEq1jc9V9uhGR1IiFS69neTkhk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UnqMq8HuUutw+cnM9NzLCw1nRD6OSPcC9lFzeY1ndxctofpJw9xYry+E3Y/iKzfy3 Xlsjul1zJSVU5bOO6y6S9S4NNJhWM4s90XGqf1lOHbp3qPbcq0gKzSjteu9O5LmQlS RyAixsxgCFAGBVeef9YSOJae76pG7TooAXtdnr8ml9OHP1Op8U6lPG4JOyaFKUhiqR 7V7kN31Qnq8CPbW4h6jqbrwBVFj/lJ+2UPlc93tAkxElYttPZxEuojvujYbWBHPODH tHujHD2Xfj8yLN8paOpk3dpoKgrYbu+QdEogOkzxt1iLv2S5KUGXSnrfe2ghGTHY/+ 43wjJFa7aZntw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51CB66927E; Sat, 10 Jan 2026 13:31:11 -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 yII_hWT1e-ou; Sat, 10 Jan 2026 13:31:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077065; bh=XKYRtgZvzt6uRyL7ei1Ia+1HwEwgkzZuifQy5tx9upY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BHDw7c9vjH8MrFz05h5xxTEHgmnHuz5fWKImsDIVR1XQhRZaeYR2PW+eeLPWaFar9 UMni+ak6v+dNQg0SDXGMf791ctroIYbXPLMWCE30QkGzaHhvFDPvbWUITkHQwAD/lV x/jVZ0pc63umu/4BsSVkSz6GIv30Osi8ElHwtfXNvOZJ3cm59hA2+6CYPtRtwsqI2k j1LzDVAcBzwMCVMUUv7Xd07VcYOFdpRPlLyl6likxfZ2YzlgQtYGrPcelXnrN5Jro+ OyMMeosm0uWr299V60f/0YqTpfM7G9Sqi41ONYW9kM5Kv3nkocFW4qgEihAVrjFrAw FNq/OvMqzVl9w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6C72869291; Sat, 10 Jan 2026 13:31:05 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:56 -0700 Message-ID: <20260110202906.187370-25-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: BTK6EOI2XC76JAW3SFHOUZVG5LJ463QD X-Message-ID-Hash: BTK6EOI2XC76JAW3SFHOUZVG5LJ463QD 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 24/26] test: pxe: Add a test for the callback-free files API 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 Add pxe_test_files_api_norun() to test the new callback-free, file-loading API: 1. Parse config with pxe_parse() to get a menu with labels 2. Verify label->files contains expected files (kernel, initrd, fdt, overlays) with correct types and paths 3. Simulate loading by calling pxe_load() for each file 4. Verify addresses and sizes are recorded correctly Also update existing tests to expect the correct file counts now that kernel, initrd, and FDT are added to the files list during parsing. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 182 +++++++++++++++++++++++++++++-- test/py/tests/test_pxe_parser.py | 11 ++ 2 files changed, 184 insertions(+), 9 deletions(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 56b1dfb4c49..80779b86aad 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -51,24 +51,22 @@ struct pxe_test_info { }; /** - * pxe_test_getfile() - Read a file from the host filesystem + * load_file() - Load a file from the host filesystem * - * This callback is used by the PXE parser to read included files. + * @path: Path to file within the mounted filesystem + * @addr: Address to load file to + * @sizep: Returns file size + * Return: 0 on success, -ve on error */ -static int pxe_test_getfile(struct pxe_context *ctx, const char *file_path, - ulong *addrp, ulong align, - enum bootflow_img_t type, ulong *sizep) +static int load_file(const char *path, ulong addr, ulong *sizep) { loff_t len_read; int ret; - if (!*addrp) - return -ENOTSUPP; - ret = fs_set_blk_dev("host", "0:0", FS_TYPE_ANY); if (ret) return ret; - ret = fs_legacy_read(file_path, *addrp, 0, 0, &len_read); + ret = fs_legacy_read(path, addr, 0, 0, &len_read); if (ret) return ret; *sizep = len_read; @@ -76,6 +74,21 @@ static int pxe_test_getfile(struct pxe_context *ctx, const char *file_path, return 0; } +/** + * pxe_test_getfile() - Read a file from the host filesystem + * + * This callback is used by the PXE parser to read included files. + */ +static int pxe_test_getfile(struct pxe_context *ctx, const char *file_path, + ulong *addrp, ulong align, + enum bootflow_img_t type, ulong *sizep) +{ + if (!*addrp) + return -ENOTSUPP; + + return load_file(file_path, *addrp, sizep); +} + /** * pxe_check_menu() - Check the standard menu output lines * @@ -1323,3 +1336,154 @@ static int pxe_test_fit_embedded_fdt_norun(struct unit_test_state *uts) PXE_TEST_ARGS(pxe_test_fit_embedded_fdt_norun, UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }, { "cfg_path", UT_ARG_STR }); + +/** + * Test callback-free file loading API with pxe_load() + * + * This tests the new callback-free API where the caller: + * 1. Calls pxe_parse() to get a menu with labels containing files lists + * 2. Iterates over label->files and loads each file manually + * 3. Calls pxe_load() to record where each file was loaded + * + * This approach eliminates the need for getfile callbacks during loading. + */ +static int pxe_test_files_api_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(PXE_ARG_FS_IMAGE); + const char *cfg_path = ut_str(PXE_ARG_CFG_PATH); + struct pxe_context *ctx; + struct pxe_label *label; + struct pxe_menu *menu; + const struct pxe_file *file; + struct pxe_file *filep; + ulong addr = PXE_LOAD_ADDR; + ulong file_addr; + ulong size; + char *buf; + uint i; + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Load the config file first */ + ut_assertok(load_file(cfg_path, addr, &size)); + + /* Add null terminator - parser expects null-terminated string */ + buf = map_sysmem(addr, 0); + buf[size] = '\0'; + unmap_sysmem(buf); + + ctx = pxe_parse(addr, size, cfg_path); + ut_assertnonnull(ctx); + menu = ctx->cfg; + + /* Parsing with no getfile callback should produce no output */ + ut_assert_console_end(); + + /* + * Process includes manually - load each include file and parse it. + * Use an index-based loop since parsing may add more includes. + */ + for (i = 0; i < menu->includes.count; i++) { + const struct pxe_include *inc; + + inc = alist_get(&menu->includes, i, struct pxe_include); + ut_assertok(load_file(inc->path, addr, &size)); + + ut_asserteq(1, pxe_parse_include(ctx, inc, addr, size)); + } + + /* Include parsing should also produce no output */ + ut_assert_console_end(); + + /* Get the first label */ + label = list_first_entry(&menu->labels, struct pxe_label, list); + ut_asserteq_str("linux", label->name); + + /* + * Verify the files list contains expected files: + * - kernel (/vmlinuz) + * - initrd (/initrd.img) + * - fdt (/dtb/board.dtb) + * - 2 overlays (/dtb/overlay1.dtbo, /dtb/overlay2.dtbo) + */ + ut_asserteq(5, label->files.count); + + /* Check each file has correct type and path */ + file = alist_get(&label->files, 0, struct pxe_file); + ut_asserteq(PFT_KERNEL, file->type); + ut_asserteq_str("/vmlinuz", file->path); + ut_asserteq(0, file->addr); /* Not loaded yet */ + + file = alist_get(&label->files, 1, struct pxe_file); + ut_asserteq(PFT_INITRD, file->type); + ut_asserteq_str("/initrd.img", file->path); + + file = alist_get(&label->files, 2, struct pxe_file); + ut_asserteq(PFT_FDT, file->type); + ut_asserteq_str("/dtb/board.dtb", file->path); + + file = alist_get(&label->files, 3, struct pxe_file); + ut_asserteq(PFT_FDTOVERLAY, file->type); + ut_asserteq_str("/dtb/overlay1.dtbo", file->path); + + file = alist_get(&label->files, 4, struct pxe_file); + ut_asserteq(PFT_FDTOVERLAY, file->type); + ut_asserteq_str("/dtb/overlay2.dtbo", file->path); + + /* + * Load each file and call pxe_load() to record address/size. + * This demonstrates the callback-free file loading API. + */ + file_addr = PXE_KERNEL_ADDR; + alist_for_each(filep, &label->files) { + ulong size; + + ut_assertok(load_file(filep->path, file_addr, &size)); + pxe_load(filep, file_addr, size); + file_addr += ALIGN(size, SZ_64K); + } + + /* Verify files were loaded with valid addresses and sizes */ + file = alist_get(&label->files, 0, struct pxe_file); + ut_asserteq(PXE_KERNEL_ADDR, file->addr); + ut_assert(file->size > 0); + + /* + * Set up context for boot from the files list. + * In the callback-free API, the caller populates ctx fields. + */ + ctx->kern_addr = alist_get(&label->files, 0, struct pxe_file)->addr; + ctx->initrd_addr = alist_get(&label->files, 1, struct pxe_file)->addr; + ctx->fdt_addr = alist_get(&label->files, 2, struct pxe_file)->addr; + ctx->label = label; + + /* Boot - sandbox simulates this */ + pxe_boot(ctx); + + /* Sandbox cannot boot the kernel, so we get this error */ + ut_assert_nextline("Unrecognized zImage"); + ut_assert_console_end(); + + /* Verify the files are in memory at the correct addresses */ + file = alist_get(&label->files, 0, struct pxe_file); + buf = map_sysmem(file->addr, file->size); + ut_asserteq_mem("kernel", buf, 6); + unmap_sysmem(buf); + + file = alist_get(&label->files, 1, struct pxe_file); + buf = map_sysmem(file->addr, file->size); + ut_asserteq_mem("ramdisk", buf, 7); + unmap_sysmem(buf); + + /* Clean up */ + pxe_cleanup(ctx); + + return 0; +} +PXE_TEST_ARGS(pxe_test_files_api_norun, UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }, + { "cfg_path", UT_ARG_STR }); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index bbcd63d58e2..5dfe9210b11 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -545,3 +545,14 @@ class TestPxeParser: with ubman.log.section('Test PXE FIT embedded FDT'): ubman.run_ut('pxe', 'pxe_test_fit_embedded_fdt', fs_image=fs_img, cfg_path=cfg_path) + + def test_pxe_files_api(self, ubman, pxe_image): + """Test three-phase files API (pxe_parse, pxe_load, pxe_boot) + + This tests the callback-free API where files are collected during + parsing and the caller loads them directly, then calls pxe_boot(). + """ + fs_img, cfg_path = pxe_image + with ubman.log.section('Test PXE files API'): + ubman.run_ut('pxe', 'pxe_test_files_api', + fs_image=fs_img, cfg_path=cfg_path) From patchwork Sat Jan 10 20:28:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1471 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=1768077077; bh=27HNyYizZAqjLl/TBsbJV1I8DVSWQ+pQ4q3fDmtBghg=; 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=mPLtLKCivsmcYzwgLQLQLiXOKLFuk0AuW2WC2++7cC5scVD2WrfHLBu4TgUSSYDar wGjfY39psugYCNwqmjqHjCUFxagb0KCn93iWfEx0+e+tMS/RZ4DFlBSFz4T7UjUIja tBCODhhoMON9+pGPcV7WyZwqYmA87raM6qBSfFPJpCbHwhKNry+kc5BTsJAL4CUJxx lQlgdoVHngp9aLC4hjDyiDwu8BJdqKJFnDSDeL2Ow1S8oatwwn52kuEFCyAneJ1OGz XQLSEXLEU4NFd2krdT8jRm4KC28nDBP1USAx7VMJGVs5M98Wkh6zFTpytRbaQWKF7A T3SDbraySIuzw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 32421692A6 for ; Sat, 10 Jan 2026 13:31:17 -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 H0f9CCjh_JnC for ; Sat, 10 Jan 2026 13:31:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077077; bh=27HNyYizZAqjLl/TBsbJV1I8DVSWQ+pQ4q3fDmtBghg=; 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=mPLtLKCivsmcYzwgLQLQLiXOKLFuk0AuW2WC2++7cC5scVD2WrfHLBu4TgUSSYDar wGjfY39psugYCNwqmjqHjCUFxagb0KCn93iWfEx0+e+tMS/RZ4DFlBSFz4T7UjUIja tBCODhhoMON9+pGPcV7WyZwqYmA87raM6qBSfFPJpCbHwhKNry+kc5BTsJAL4CUJxx lQlgdoVHngp9aLC4hjDyiDwu8BJdqKJFnDSDeL2Ow1S8oatwwn52kuEFCyAneJ1OGz XQLSEXLEU4NFd2krdT8jRm4KC28nDBP1USAx7VMJGVs5M98Wkh6zFTpytRbaQWKF7A T3SDbraySIuzw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 197536927E for ; Sat, 10 Jan 2026 13:31:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077074; bh=DB0ygrfzPGw08JRC03uA+Vpf0YX3z+WBW02066cZlZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUCL4f85ACe7nvC56SgCxd0OKrxqFAig7GABwsOTFky06/M4NTwuqEizxXpbolw71 CRzA43s7Db3IehOzCXbHzObBhtzZ7DpyrIjN2/fLhM5HcRhoiuCHn0+80V1v4u3h/x uncTcqmnoQHuxURy+hOAgE3kDQ998G/SRj/yScEjaq1Jos38v2d3Qmb1YzKloCjO8V DPSMuw0TtzE44cOBDFmpq10Gjgr0Yx5TYj7V8sQupn2wjwTT3KSbnPXdkBDod0WT3Y TXrjMO9jR0YzUoevYY6JI+lsaonGifectJC6qZxNd7YrwXBdyELAy1Swcrqu2/G+6k oRYF/LZaAxVpQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 85E8A69184; Sat, 10 Jan 2026 13:31:14 -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 j_of-skEqM-d; Sat, 10 Jan 2026 13:31:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077070; bh=AmeKnvWmeQkndUVU2sDnm1jTqq1fjOdlY6S3khXziWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kJAevCSr+GEmGmIJCJWfZRawW3vNeqm+ZhS2vjoq90KQGk+0DgPZ6xv8gCl2cT4dd yeXdp16C/8uBhLAXEKRfZjvwl7WN0AJTkGj8g+wb93aalPqKL+dJkZ11Kdhg8yblQW G19d6xK/FuepKvzkEBw/GfIR4hL3hBMM+NhHjZ/uoIClctFcW2BMxIGH6BCD2K35nF zwlcrjc+xf1RymRWBkINVH4JUPyMGILi2g4/nevY1axqfDSKIYdruRV3TbYkptEoJr h9tfjUvjhs/wmNs+9TaWlukQSdKZEnxCY+GtgOPW8OzmKjtvp1H+NBNK1K/KFAl0iK dq7rCpijChusA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2653369186; Sat, 10 Jan 2026 13:31:10 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:57 -0700 Message-ID: <20260110202906.187370-26-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: 2BBZ327P4AOQBCF5UAXPPJJ3Q67VJKX6 X-Message-ID-Hash: 2BBZ327P4AOQBCF5UAXPPJJ3Q67VJKX6 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 25/26] test: pxe: Add memory-leak check to files-API test 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 Add a check for memory leaks in the callback-free files API test. This ensures that pxe_cleanup() properly frees all allocated memory. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 80779b86aad..f4a124eafda 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -12,6 +12,7 @@ * */ +#include #include #include #include @@ -1358,6 +1359,7 @@ static int pxe_test_files_api_norun(struct unit_test_state *uts) struct pxe_file *filep; ulong addr = PXE_LOAD_ADDR; ulong file_addr; + ulong start_mem; ulong size; char *buf; uint i; @@ -1368,6 +1370,9 @@ static int pxe_test_files_api_norun(struct unit_test_state *uts) /* Bind the filesystem image */ ut_assertok(run_commandf("host bind 0 %s", fs_image)); + blkcache_free(); + start_mem = ut_check_delta(0); + /* Load the config file first */ ut_assertok(load_file(cfg_path, addr, &size)); @@ -1479,8 +1484,10 @@ static int pxe_test_files_api_norun(struct unit_test_state *uts) ut_asserteq_mem("ramdisk", buf, 7); unmap_sysmem(buf); - /* Clean up */ + /* Clean up and check for memory leaks */ pxe_cleanup(ctx); + blkcache_free(); + ut_assertok(ut_check_delta(start_mem)); return 0; } From patchwork Sat Jan 10 20:28:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1472 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=1768077081; bh=t0CT+1GNAV29tANtinq3gZ05j1iQHzwOSe8yYgc+BAE=; 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=tSE9vFpDh767cd+XdfBRKtbzqNHT7lqt3LC+O1Fue26p3pk1hkGC1LXZBoMEf0CcA yG1iQJGkhgDZZSi2Cw1uAuypHF6DTsxPModJbHxl0gLLPcKfPy/N8zbyddV5AAauLu mcd/bIvqHRfGQTWU6Flu0rZoeutQ8rOMg/eNUbuotcWdHihMDAZszubsxcTvOy2CCl jUEVCRuC+hiXexmtImU3qcKFrIM3Cv11IY2m6SIPUNtdbgGOQVkA/efDupiH7deVkg TkZosN97XxBQB/RoG/pKBlk1c3cpAgWiExlCpl6fgghjKv2Zj3EdEkJJ6xWYAHdQgZ VeYKzGSQlr1/Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9F003692AD for ; Sat, 10 Jan 2026 13:31:21 -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 i63Sb96ckagH for ; Sat, 10 Jan 2026 13:31:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077081; bh=t0CT+1GNAV29tANtinq3gZ05j1iQHzwOSe8yYgc+BAE=; 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=tSE9vFpDh767cd+XdfBRKtbzqNHT7lqt3LC+O1Fue26p3pk1hkGC1LXZBoMEf0CcA yG1iQJGkhgDZZSi2Cw1uAuypHF6DTsxPModJbHxl0gLLPcKfPy/N8zbyddV5AAauLu mcd/bIvqHRfGQTWU6Flu0rZoeutQ8rOMg/eNUbuotcWdHihMDAZszubsxcTvOy2CCl jUEVCRuC+hiXexmtImU3qcKFrIM3Cv11IY2m6SIPUNtdbgGOQVkA/efDupiH7deVkg TkZosN97XxBQB/RoG/pKBlk1c3cpAgWiExlCpl6fgghjKv2Zj3EdEkJJ6xWYAHdQgZ VeYKzGSQlr1/Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D1DE692A7 for ; Sat, 10 Jan 2026 13:31:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077079; bh=na1HXC1e72/q6SR5n5ymtuz2UjRrVZlER+Dtt/oGKec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2pFbSQVYGSk9P5oO3+mbT44tT3giNmg0/7eBHyS4bVSoX2UlJo6Pj0pId0niM+HC BB6mBI2XG2hVWeYEInu7i8JSrDVHwW8UREqXyKpqIvq31yDNEmdX/rC8LW9d/YXi+T VCC/GcsLa3sElXBTDdak7MBSJPwt6SrV61rb5geRidFoU1R85hwwYDY6EMbjNEhvH/ hufBmb95X6FDHVivGTTYj+Cj+QSaC+2m/y/54hWAu4OyOXa4CXls1fISTbjGN8nIDg R1qCTPcff+XLLzzqEt8SmciWOTQkuQAcv8h71OzQhO1LrJR6setgw3dttSUnhGvuNq Skt3AundFPBKg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 91A18692A6; Sat, 10 Jan 2026 13:31:19 -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 Ll7KADP-gzBf; Sat, 10 Jan 2026 13:31:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077075; bh=1MqgNMrL/PQa7JNb70zOKLe2++o7U7L31HTpXH7kD/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TKz5h5Cl4UMO8Bbhf7lDbubgmF1AZ+ivJP0cYA/Pxx4o9cpAvuMtMy4f5hSr3Efav Jr+HniK/Sj96fc9nSqUISbmF9KQ7BsnpMFGuJyldihw7MgXVbiPZ65iWSdjXgB2lim Kt/nzdbsDhq307BQU6emDbTJC4giFiHtBovG4fqPTOk/bcGej+3TnBNddWrQ9orL4i +SUV0bsu3pTO3XhTtwhgr7sPCk4X4/CzLvImCtyzfJCx9STQb2w4ld/UF4vviArrsU lnKwV3adiHYUeiQbOwChbRhgSSPNgGvZsV4D3B9oIS+xJOwKAdGCSx6/+qFvgY5DdD BKifkANaoAa3A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CC06469186; Sat, 10 Jan 2026 13:31:14 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:58 -0700 Message-ID: <20260110202906.187370-27-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: PLCWWIRJR3PVPARJM57ADV7GGL5W4NJ7 X-Message-ID-Hash: PLCWWIRJR3PVPARJM57ADV7GGL5W4NJ7 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/26] doc: bootstd: Add PXE parser API documentation 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 Add documentation for the PXE/extlinux parser API, covering both the traditional callback-based approach and the new callback-free API. The callback-free API separates parsing, loading, and booting into distinct phases, giving callers complete control over file operations. During parsing, the code collects file information (kernel, initrd, FDT, overlays) into a list that the caller can iterate over to load files manually. The documentation explains the file types, include handling, and provides an example showing typical usage of the callback-free API. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- doc/develop/bootstd/index.rst | 1 + doc/develop/bootstd/pxe_api.rst | 194 ++++++++++++++++++++++++++++++++ include/pxe_utils.h | 2 + 3 files changed, 197 insertions(+) create mode 100644 doc/develop/bootstd/pxe_api.rst diff --git a/doc/develop/bootstd/index.rst b/doc/develop/bootstd/index.rst index 342228064e6..35b7065aaad 100644 --- a/doc/develop/bootstd/index.rst +++ b/doc/develop/bootstd/index.rst @@ -9,6 +9,7 @@ Standard Boot overview extlinux pxelinux + pxe_api qfw android cros diff --git a/doc/develop/bootstd/pxe_api.rst b/doc/develop/bootstd/pxe_api.rst new file mode 100644 index 00000000000..18e4b6d8563 --- /dev/null +++ b/doc/develop/bootstd/pxe_api.rst @@ -0,0 +1,194 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +PXE Parser API +============== + +The PXE parser handles configuration files in the extlinux/syslinux format, +which is widely used for boot menus on both local storage and network-boot +environments. This document describes the internal API for parsing these +configuration files and booting the selected operating system. + +Background +---------- + +The extlinux configuration format provides a simple way to define multiple boot +options, each with its own kernel, initial ramdisk, device tree, and command +line arguments. A typical configuration file looks like this:: + + menu title Boot Menu + timeout 50 + default linux + + label linux + menu label Ubuntu Linux + kernel /vmlinuz + initrd /initrd.img + fdt /dtb/board.dtb + fdtoverlays /dtb/overlay1.dtbo /dtb/overlay2.dtbo + append root=/dev/sda1 quiet + +The parser reads this configuration, presents a menu if appropriate, and boots +the selected label by loading the kernel and associated files into memory. + +Traditional API +--------------- + +The traditional approach uses callback functions to load files as they are +needed during parsing and booting. This works well when the caller has direct +access to the storage device and wants the PXE code to handle all file +operations. + +The entry point is ``pxe_process()``, which parses the configuration file, +handles the menu interaction, and boots the selected label. Before calling +this function, the caller must set up a context using ``pxe_setup_ctx()``, +providing a callback function that knows how to read files from the +appropriate source. + +The callback function receives a filename and a memory address, and is +responsible for loading the file contents to that address. This abstraction +allows the same parsing code to work with local filesystems, network TFTP, +or any other file source. + +When the parser encounters an ``include`` directive, it automatically calls +the callback to load the included file, then parses its contents. This +happens recursively for nested includes, up to a maximum depth of 16 levels. +The caller does not need to handle includes explicitly. + +For cases where the caller wants to inspect the parsed configuration before +booting, ``pxe_probe()`` provides a way to parse and select a label without +immediately booting. The caller can then examine the selected label's +properties and call ``pxe_boot()`` when ready to proceed. + +Callback-free API +----------------- + +Some callers prefer to handle file loading themselves rather than providing +callbacks. This is particularly useful in environments where file access +requires special handling, or where the caller wants complete control over +memory allocation and file placement. + +The callback-free API separates the boot process into distinct phases, giving +the caller full visibility into what files are needed and where they should +be loaded. + +The first phase uses ``pxe_parse()`` to parse the configuration file and +return a context containing a menu structure. The caller must first load the +configuration file into memory at a known address, then pass that address +and size to the parser. The function allocates and initialises the context +internally, so there is no need to call ``pxe_setup_ctx()`` beforehand. + +Note that ``pxe_parse()`` does not process ``include`` directives +automatically, since there is no callback to load files. The caller must +handle includes explicitly after parsing, as described below. + +During parsing, the code collects information about all files referenced by +each label. These are stored in a files list within each label structure, +with each entry recording the file path and type. The types distinguish +between kernels, initial ramdisks, device trees, and device tree overlays, +allowing the caller to handle each appropriately. + +After parsing, the caller can examine the menu structure to see what labels +are available and what files each one requires. For labels that use the +``include`` directive, the caller must load each included file and call +``pxe_parse_include()`` to merge its contents into the menu. The includes +list may grow as included files reference further includes, so the caller +should process includes in a loop until none remain. + +The second phase involves loading the files for the selected label. The +caller iterates over the label's files list, loads each file to an +appropriate memory address, and calls ``pxe_load()`` to record where the +file was placed. This function simply stores the address and size in the +file structure for later use. + +The final phase boots the selected label using ``pxe_boot()``. The caller +sets ``ctx->label`` to point to the selected label, and the function +automatically retrieves the kernel, initial ramdisk, and device tree +addresses from the files list. It then invokes the boot process, which +does not return on success. + +File Types +---------- + +The files list uses an enumeration to distinguish between different file +types. ``PFT_KERNEL`` indicates the kernel image, which may be a raw binary, +a compressed image, or a FIT image containing multiple components. +``PFT_INITRD`` marks the initial ramdisk, which the kernel uses as a +temporary root filesystem during early boot. ``PFT_FDT`` identifies the +flattened device tree that describes the hardware to the kernel. Finally, +``PFT_FDTOVERLAY`` marks device tree overlay files that modify the base +device tree, typically used to enable optional hardware or adjust +configuration. + +The caller can use these types to determine appropriate load addresses for +each file, or to apply special handling such as decompression or +verification. + +Include Handling +---------------- + +Configuration files may use the ``include`` directive to incorporate +additional configuration from other files. When using the traditional API +with callbacks, includes are processed automatically during parsing. + +With the callback-free API, includes require explicit handling. After the +initial parse, the menu's includes list contains entries for each include +directive encountered. Each entry records the path to the included file +and the nesting level. + +The caller loads each included file, adds a null terminator to the buffer +since the parser expects null-terminated strings, and calls +``pxe_parse_include()`` to parse and merge the contents. This may add more +entries to the includes list if the included file itself contains include +directives. Processing continues until all includes have been handled. + +The parser enforces a maximum nesting depth to prevent infinite recursion +from circular includes. + +Example Usage +------------- + +A typical use of the callback-free API follows this pattern:: + + struct pxe_context *ctx; + struct pxe_menu *menu; + struct pxe_label *label; + struct pxe_file *file; + ulong addr = CONFIG_SYS_LOAD_ADDR; + ulong file_addr; + ulong size; + + /* Load and parse the configuration file */ + size = load_config_file("/extlinux/extlinux.conf", addr); + ctx = pxe_parse(addr, size, "/extlinux/extlinux.conf"); + menu = ctx->cfg; + + /* Process any include directives */ + for (i = 0; i < menu->includes.count; i++) { + const struct pxe_include *inc; + + inc = alist_get(&menu->includes, i, struct pxe_include); + size = load_file(inc->path, addr); + pxe_parse_include(ctx, inc, addr, size); + } + + /* Select a label (here we just take the first one) */ + label = list_first_entry(&menu->labels, struct pxe_label, list); + + /* Load all files for this label */ + file_addr = KERNEL_LOAD_ADDR; + alist_for_each(file, &label->files) { + size = load_file(file->path, file_addr); + pxe_load(file, file_addr, size); + file_addr += ALIGN(size, SZ_64K); + } + + /* Boot - pxe_boot() gets addresses from the files list */ + ctx->label = label; + pxe_boot(ctx); + + /* Clean up (only reached if boot fails) */ + pxe_cleanup(ctx); + +This approach gives the caller complete control over file loading while +still benefiting from the parser's understanding of the configuration +format. diff --git a/include/pxe_utils.h b/include/pxe_utils.h index bc9e3f29417..48d36bdd14c 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -23,6 +23,8 @@ * pxe, and does a tftp download of a file listed as an include file in the * middle of the parsing operation. That could be handled by refactoring it to * take a 'include file getter' function. + * + * See doc/develop/bootstd/pxe_api.rst for API documentation. */ /**