From patchwork Fri Jan 9 23:11:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1397 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=1768000341; bh=dbGYkRZ2mYVou8/XFb3RE9qbBECAph5Nh8akNkbIfwY=; 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=gHLlGKBEVCgNh/dICUsVCkmOXLnc8rxyOheGnF4gl24tDLfWu43n2EVi8VNw7a+1/ INzOfP0ZCP/tzV3oezVdpRPNNREAO1MKW5xUHPkCXtYM3G3h91kBA+sCoWscVWP1xz s1L+VJVWozMhhXbL97ojxePb470Rw3Jnb8TsSKFEVgsQjtHFymrC0rv/6IuX/IWMlI W9wD+qFmqDcHcHZLtfB2RI+50EB12na3kp/2fXoaENwX55kVtonbACcjhPgM5GWu+O Qxajw8MKSDCLN3kHnbzEovA6/nk9kVBY77cPuN2csKpoq0zQen4WAPqqUrs3JMigoF zPGEgXGuXw7pw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A142869218 for ; Fri, 9 Jan 2026 16:12: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 jCKjaNA72iEO for ; Fri, 9 Jan 2026 16:12:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000341; bh=dbGYkRZ2mYVou8/XFb3RE9qbBECAph5Nh8akNkbIfwY=; 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=gHLlGKBEVCgNh/dICUsVCkmOXLnc8rxyOheGnF4gl24tDLfWu43n2EVi8VNw7a+1/ INzOfP0ZCP/tzV3oezVdpRPNNREAO1MKW5xUHPkCXtYM3G3h91kBA+sCoWscVWP1xz s1L+VJVWozMhhXbL97ojxePb470Rw3Jnb8TsSKFEVgsQjtHFymrC0rv/6IuX/IWMlI W9wD+qFmqDcHcHZLtfB2RI+50EB12na3kp/2fXoaENwX55kVtonbACcjhPgM5GWu+O Qxajw8MKSDCLN3kHnbzEovA6/nk9kVBY77cPuN2csKpoq0zQen4WAPqqUrs3JMigoF zPGEgXGuXw7pw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8EFA669235 for ; Fri, 9 Jan 2026 16:12:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000339; bh=Z0hkHXl07MsQoOZfJWYaj+l/zX1cjHjALlLcuL7pCPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SbCjU7udUYUQl47cv7YjWlMGAfZrZocCLprVolimODWVlDsIYNkUogzPczmfthhNQ YCw1ufNqzkRliDqTOZRpOe/qyC4IR3atre98JEYWZbmvPlYKjipoOAqIiITOHdNvlR z0ocj9xUynIdMFWyYnaILkGwJkAOtHeiTOdxfDZZZAXXIMgJ9ko0MZ6CcRjBH2iCDg g9orQgMO5y6L5fOPGHU158SHjB0T4RGyGVOhAK1ppwSdCWBVmVW8Zy2ionWNHkCNvu i5z5lcYXKdYa4CxlzTBDZa+kRto4rGi8zjseE1t66Y+7mIocnpvYB31RIaMU8knzRq SuOcJkBPND3rA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 74E2969218; Fri, 9 Jan 2026 16:12: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 pAIvCJZg4qqr; Fri, 9 Jan 2026 16:12:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000335; bh=rZZ7ARcfqdml00vsFSJxRySTn0o0at8ixvyJVsI1Yww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ne+w0TH2YqDJC4CspXrP9n66LOLb8phho2MbL2E2zBaJ2nxyWp39Gr/psTg0Wpxet FkOW83vNEUfodW9Y+p2QJz4P5BJnX6EbUw7JnK08z8A8vlQGBvzeEqpvz41qgZYjG4 A9+cQoIsuFvWWjw90S6unW3BEPRkU3epGEgxE82krYVquw0aW+4XKcp/5AUhp7mJ2S mWiahkBn19zeOd7v4mmzJWJSTbWQUIS24U4lPGGKLXaOsfxhGPQjh6043kq4RUkyYy xPUWoXuCP6gALgMmbK8yvCVcIsKUyekfMNrm9uhzVK5AG1Y7RyA9O4CExiCL77Ts2Y uRNss+DX6VVpA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1E32C69206; Fri, 9 Jan 2026 16:12:15 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:10 -0700 Message-ID: <20260109231151.4056804-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 74ZPTSSFCAXI5BE3MWHRAOXHDT2WW3CH X-Message-ID-Hash: 74ZPTSSFCAXI5BE3MWHRAOXHDT2WW3CH 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/32] test: pxe: Preserve filesystem images when persist is enabled 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 Skip cleanup of filesystem images in the pxe_fdtdir_image and pxe_error_image fixtures when the persist option is set. This allows inspection of the test files after a test run for debugging purposes. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/py/tests/test_pxe_parser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index de01f219244..d52bf3e6b50 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -325,7 +325,8 @@ def pxe_fdtdir_image(u_boot_config): yield fsh.fs_img, cfg_path - fsh.cleanup() + if not u_boot_config.persist: + fsh.cleanup() @pytest.fixture @@ -385,7 +386,8 @@ def pxe_error_image(u_boot_config): yield fsh.fs_img, cfg_path - fsh.cleanup() + if not u_boot_config.persist: + fsh.cleanup() @pytest.mark.boardspec('sandbox') From patchwork Fri Jan 9 23:11:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1398 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=1768000345; bh=t1yTrl8lKiOEMKTPBdTiw91e3WBhQeTwWWbq5+h+SUE=; 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=CiSbJlhTLA3bqhahzeOpDG4thQ4ycQ69CkaEDDACRsQILGDblnS05Li0KckrPZLgp Sv+div0PBSOoG4LPFg7u+7K1kAWhz5b4bz2QP1hS9boB1Z/n3H+bw0srQsozhVsoOX li8nv+jYj73qX7bmAJzHMlTDAQVkoF5n3MFDyaE0S3dsEsCG9nNFizy0hC6iBibhUf HqPAydrxj5d5ggIh8m9vvL4vtQmVlPfFkBu3JENYt9yaD4TVk06pk2YC7foYbZKbcN 5fey/AUeH2saThu5sswOtRae8JimWPYx49gpTmTjq1GZxty3lQ1QrCtFvgEqrLvVhK DZYVT3ecxN7Ug== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 839436923A for ; Fri, 9 Jan 2026 16:12: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 10024) with ESMTP id k784p2kptuhS for ; Fri, 9 Jan 2026 16:12:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000345; bh=t1yTrl8lKiOEMKTPBdTiw91e3WBhQeTwWWbq5+h+SUE=; 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=CiSbJlhTLA3bqhahzeOpDG4thQ4ycQ69CkaEDDACRsQILGDblnS05Li0KckrPZLgp Sv+div0PBSOoG4LPFg7u+7K1kAWhz5b4bz2QP1hS9boB1Z/n3H+bw0srQsozhVsoOX li8nv+jYj73qX7bmAJzHMlTDAQVkoF5n3MFDyaE0S3dsEsCG9nNFizy0hC6iBibhUf HqPAydrxj5d5ggIh8m9vvL4vtQmVlPfFkBu3JENYt9yaD4TVk06pk2YC7foYbZKbcN 5fey/AUeH2saThu5sswOtRae8JimWPYx49gpTmTjq1GZxty3lQ1QrCtFvgEqrLvVhK DZYVT3ecxN7Ug== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7247669238 for ; Fri, 9 Jan 2026 16:12:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000344; bh=RU6j31AyQ8uf4JTCrq672sDVx49OA9D+rhgclHviZqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MnHPgmSO+7429d4/CEaFOv8PimMcj3LQCEGGZNm5UTBK3q7XJ9wp8NiH84cqS4g9k J1Fz4+HnfacfqFLj098f2k4eeXlnmuIwASkKi7cMOwzIOtSg4qQzFd9WfERcVyggpZ 1yJPonPYmyl6a3iqdN2pJ2tHOhneZEU5MCpAiuUUnlxpQM2N0iPRnrQ6ju/WHEryBO CLL7GyygVvn/37oNWJCSOIu05CDHHRDyBb5dMuVAzjiBC8iUgscClV1LvVLwzq5qmd GpO/GV9Ighpqiv2yz7248dk3aE4yCp/IzAug+h0JTp+kje+w5MO5zbD/JtFVXox+Au JVCnsaGtbN94g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1D36069218; Fri, 9 Jan 2026 16:12: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 eEgwJysmv7qp; Fri, 9 Jan 2026 16:12:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000340; bh=wC8RGu1n21cTniyJhzI4c3CCtgCQ1R9FrRrA9IitkXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E80r2QWRCwEQ80r10orn9rRUD3H6OewUwRsZdp5+FzIxVbx3yfCM66O7JeSoNLjkT etYR69Q6iw2QayCXVGgbeBM3lgQ7y9yKNYkZ9Cs5XlacAGAjlYLSyA5Mm45yDBW/DA /fXHZSs5J/SvHxR1NIGk9ntMaEO0unkSksPT5Rhday3A6Oau2YyqxfjiNL9SLzrZFr +KbQM8qVm6muOrT9pr8hfoA0ZD0hEJdEoecZ3sW469eqt1IToOdkWGEHJYTZr5d7vP e0ZtHjrEng3Pbwl4/Xz5YiGrcx1o34DP/YzhEjHCugYOQP81TiByEIWkmWLyy+CiHw hnHcoZ+xzpB2g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B667369206; Fri, 9 Jan 2026 16:12:19 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:11 -0700 Message-ID: <20260109231151.4056804-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: THNLUST4CQDHBFUMKSUBXD55VPL5F7HD X-Message-ID-Hash: THNLUST4CQDHBFUMKSUBXD55VPL5F7HD 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/32] sandbox: bootz: Fix incorrect pointer passed to unmap_sysmem() 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 bootz_setup() function maps the kernel image address to get a host pointer, but then incorrectly passes the original physical address to unmap_sysmem() instead of the mapped pointer. This causes a warning on sandbox: unmap_physmem() Address not mapped: 0000000002000000 Fix this by passing the mapped pointer (zimage) to unmap_sysmem() instead of the raw physical address cast to a pointer. Update the PXE tests to remove expectations for this warning message. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- arch/sandbox/lib/bootm.c | 2 +- test/boot/pxe.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c index 8ed923750f4..c1d970d021d 100644 --- a/arch/sandbox/lib/bootm.c +++ b/arch/sandbox/lib/bootm.c @@ -45,7 +45,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end) ret = 1; } - unmap_sysmem((void *)image); + unmap_sysmem(zimage); return ret; } diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 9398cf5757f..0da28be8576 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -299,7 +299,6 @@ static int pxe_test_sysboot_norun(struct unit_test_state *uts) /* Boot fails on sandbox */ ut_assert_nextline("Unrecognized zImage"); - ut_assert_nextlinen(" unmap_physmem"); /* Verify files were loaded at the correct addresses */ kernel = map_sysmem(PXE_KERNEL_ADDR, 0); @@ -376,7 +375,6 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) /* Boot fails but we verified the path construction */ ut_assert_nextline("Unrecognized zImage"); - ut_assert_nextlinen(" unmap_physmem"); /* Verify FDT was loaded correctly */ fdt = map_sysmem(PXE_FDT_ADDR, 0); @@ -405,7 +403,6 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) /* Boot fails but we verified the path construction */ ut_assert_nextline("Unrecognized zImage"); - ut_assert_nextlinen(" unmap_physmem"); /* Verify FDT was loaded */ fdt = map_sysmem(PXE_FDT_ADDR, 0); @@ -483,7 +480,6 @@ static int pxe_test_errors_norun(struct unit_test_state *uts) * that label loading continued despite missing fdtdir FDT */ ut_assert_nextline("Unrecognized zImage"); - ut_assert_nextlinen(" unmap_physmem"); /* Clean up env vars */ env_set("fdtfile", NULL); From patchwork Fri Jan 9 23:11:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1399 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=1768000351; bh=mXm05bZJekIKC42WzCSQGYIAac0NUxPBQ4JEWIjFvz4=; 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=H2v9jjBdTohJyfLfMt+EFvsHUE/PoOHwkYlM/RJjS1SfFo+LSbrKKi0RVgWNzrC7W 912LJC7bukr6Cylkr5u5HfImWREnXX7e4IDIpeT4NfzQbhOrkvDSAcsi4XMVOXL5lE 1X4XqX5WzPEMOtC6Jk8yq6ONOFakjAXMNVV1w+6RV7cmu9Qtceqyml+8l9HYemTCGq ducN08+ttP9Kw276uGpsIfW50gTmhNH4bUkk/JK9h9OOPIGzyOFS62IrcMpHIqH0CO QoyzKABwSeAeqVaHYvlOxEkck58MkYt/2gLo5uuGST72Ch4JTf+DUd5xLk9jUzh5Ch 32+v8pyYRdoyQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0460F69218 for ; Fri, 9 Jan 2026 16:12: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 9N_EF_3TIU_s for ; Fri, 9 Jan 2026 16:12:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000350; bh=mXm05bZJekIKC42WzCSQGYIAac0NUxPBQ4JEWIjFvz4=; 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=uIGD9tXS7FnTrsbsKQIL0jp0rRvskmrh1xrPPHPAKlSvj1cbw4cBbXU4xd8mviIRq QwhRNV6wLA9L9kJsHDL4ZXidE8sljK6FRKJycPNNnVeTP4auV93Qf1z5ehcA6ePu7T xWZ+8vUnIHgP6VPRg4o05RRHSDPP5b9SKk8nwXAPCa7pFR3NZfI5ujbXUzTra6M/DP LjkcxnuxV/93bv04UmyN932Yh9ELYIq2ayA9G7KxnEJv7QcilOVr5h3ravslaoXWvR To/+nHXAQBsKkmdBBHVygiWkO6zTEQMM1tjTcegHIGckMfnLYn8nikwlQ3e7HFwQdE 0KoGF+JsS5IHQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E643E69235 for ; Fri, 9 Jan 2026 16:12:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000348; bh=VX/rvkPZkSHJzd+tEBqdZmWAgOvqkXMM6fJPyfo027A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=liVyJywgounVVRBxpXAuPLyZL9XDV6YhL2YUjJUntDd3RecXfr4hlKbpkqf5XPxtV 2N7wbTXKsiN933dzBBXcDikrgk8AW0PmV70zMvK+CXekmcubxQn2uIr1mZ9Y4xrAb6 hI0A/Q3QhMP9oqfZ1gOuKrHYf+DvnYsB7c45wzUY1ixrRAFCGu8ci7TmTgTrDXhWyb pqlsTMDHQC9bwpezu+wSPRhyb0+qMxD+9SXEskbDIUM0ONZknrWozMwaZ+nLz3ef/g ArKdzWWjq4k8ZXtqGR+i48vMfomQq0AtZ6dIFPeT6LHHmjAK79cWM1VK2+ddTs76LM IVNN9VrtCp3sg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C97FE69218; Fri, 9 Jan 2026 16:12:28 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 7-DDa0kLLoQm; Fri, 9 Jan 2026 16:12:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000344; bh=RsHSMsxYU8yfyCEecbd7pzvs05vCxXFR/vEkn2LaY5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IlHCP6XmZvuc86aEk7zsEXB7h7GKGLNc/b/oW4b5po8s3dKquzbqYQdUYwdI9IFeu YONtBmjxf+RuiLIVvyBD4t+aZoBQFnkgYPgNEMg4clz0mJjefft1EoU/2xGPGhNjrr r1axyxhGJ0nOp9QTsxtTqo0QGfj6E1O18syKsJzc1Zpo+gyKrC3cTbXU12ASbUIcRO eyEJgSkp0gYUA5qxfYYHze3EBdwk5r6uwHt6ZzjdgJPQze8r0F7fwzte8z2PF+Jf1R FXDJTU4tly3xPH0s2Q4UOwUiFjv10iT+QR0lrAERBrwa6+oh0vwuo7yv+BnffIRbC/ oaxsq5GdCcknQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 642C969206; Fri, 9 Jan 2026 16:12:24 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:12 -0700 Message-ID: <20260109231151.4056804-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ACXPC6Y3XPWEVDB2E5U6TCQIQV2QDS2N X-Message-ID-Hash: ACXPC6Y3XPWEVDB2E5U6TCQIQV2QDS2N 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/32] test: pxe: Add helper to check menu output lines 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_check_menu() helper function that verifies all console output lines from loading and displaying the PXE menu. This includes config file retrieval, include files, background image attempt, menu title and all menu items. Update pxe_test_sysboot_norun() to use the new helper instead of ut_assert_skip_to_line(), providing more thorough output verification. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 175 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 142 insertions(+), 33 deletions(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 0da28be8576..f12add77db6 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -76,6 +76,87 @@ static int pxe_test_getfile(struct pxe_context *ctx, const char *file_path, return 0; } +/** + * pxe_check_menu() - Check the standard menu output lines + * + * This helper checks all the console output lines from loading and displaying + * the PXE menu, including config file retrieval, include files, background + * image attempt, and the menu itself. + * + * @uts: Unit test state + * @say_msg: Expected 'say' message (shown before menu), or NULL if none + * @error_msg: Expected error message after background image, or NULL if none + * Return: 0 if OK, -ve on error + */ +static int pxe_check_menu(struct unit_test_state *uts, const char *say_msg, + const char *error_msg) +{ + int i; + + /* Config file retrieval */ + ut_assert_nextline("Retrieving file: /extlinux/extlinux.conf"); + + /* Say message appears before includes are processed */ + if (say_msg) + ut_assert_nextline(say_msg); + + /* Include file retrievals */ + ut_assert_nextline("Retrieving file: /extlinux/extra.conf"); + for (i = 3; i <= 16; i++) + ut_assert_nextline("Retrieving file: /extlinux/nest%d.conf", i); + + /* Background image attempt */ + ut_assert_nextline("Retrieving file: /boot/background.bmp"); + ut_assert_nextline("There is no valid bmp file at the given address"); + + /* Optional error message before menu */ + if (error_msg) + ut_assert_nextline(error_msg); + + /* Menu title and items */ + ut_assert_nextline("Test Boot Menu"); + ut_assert_nextline("1:\tBoot Linux"); + ut_assert_nextline("2:\tRescue Mode"); + ut_assert_nextline("3:\tLocal Boot"); + ut_assert_nextline("4:\tFIT Boot"); + ut_assert_nextline("5:\tIncluded Label"); + for (i = 6; i <= 19; i++) + ut_assert_nextline("%d:\tLevel %d Label", i, i - 3); + + return 0; +} + +/** + * pxe_check_fdtdir() - Check fdtdir test menu and boot output + * + * Helper for pxe_test_fdtdir_norun() that checks the menu output and boot + * file retrieval messages for the fdtdir test configuration. + * + * @uts: Unit test state + * @dtb_name: Expected DTB filename (e.g., "test-board.dtb") + * Return: 0 if OK, -ve on error + */ +static int pxe_check_fdtdir(struct unit_test_state *uts, const char *dtb_name) +{ + /* Menu output */ + ut_assert_nextline("Retrieving file: /extlinux/extlinux.conf"); + ut_assert_nextline("Test Boot Menu"); + ut_assert_nextline("1:\tTest fdtfile env var"); + ut_assert_nextline("2:\tTest soc/board construction"); + ut_assert_nextline("Enter choice: 1:\tTest fdtfile env var"); + + /* Boot file retrieval */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("append: console=ttyS0"); + ut_assert_nextline("Retrieving file: /dtb/%s", dtb_name); + ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); + + /* Boot fails on sandbox */ + ut_assert_nextline("Unrecognized zImage"); + + return 0; +} + /** * Test parsing an extlinux.conf file * @@ -124,6 +205,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assert_nextline("Retrieving file: /extlinux/extra.conf"); for (i = 3; i <= 16; i++) ut_assert_nextline("Retrieving file: /extlinux/nest%d.conf", i); + ut_assert_console_end(); /* Verify menu properties */ ut_asserteq_str("Test Boot Menu", cfg->title); @@ -286,8 +368,9 @@ static int pxe_test_sysboot_norun(struct unit_test_state *uts) ut_assertok(run_commandf("sysboot host 0:0 any %x %s", PXE_LOAD_ADDR, cfg_path)); - /* Skip menu output and find the first label boot attempt */ - ut_assert_skip_to_line("Enter choice: 1:\tBoot Linux"); + /* Check menu output */ + ut_assertok(pxe_check_menu(uts, "Booting default Linux kernel", NULL)); + ut_assert_nextline("Enter choice: 1:\tBoot Linux"); /* Verify files were loaded in order */ ut_assert_nextline("Retrieving file: /vmlinuz"); @@ -299,6 +382,7 @@ static int pxe_test_sysboot_norun(struct unit_test_state *uts) /* Boot fails on sandbox */ ut_assert_nextline("Unrecognized zImage"); + ut_assert_console_end(); /* Verify files were loaded at the correct addresses */ kernel = map_sysmem(PXE_KERNEL_ADDR, 0); @@ -363,18 +447,7 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) ut_assertok(run_commandf("sysboot host 0:0 any %x %s", PXE_LOAD_ADDR, cfg_path)); - - /* Skip to the boot attempt - first label is fdtfile-test */ - ut_assert_skip_to_line("Enter choice: 1:\tTest fdtfile env var"); - - /* Verify fdtdir used fdtfile env var to construct path */ - ut_assert_nextline("Retrieving file: /vmlinuz"); - ut_assert_nextline("append: console=ttyS0"); - ut_assert_nextline("Retrieving file: /dtb/test-board.dtb"); - ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); - - /* Boot fails but we verified the path construction */ - ut_assert_nextline("Unrecognized zImage"); + ut_assertok(pxe_check_fdtdir(uts, "test-board.dtb")); /* Verify FDT was loaded correctly */ fdt = map_sysmem(PXE_FDT_ADDR, 0); @@ -391,18 +464,8 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) ut_assertok(run_commandf("sysboot host 0:0 any %x %s", PXE_LOAD_ADDR, cfg_path)); - - /* Still boots default label, but now uses soc-board path construction */ - ut_assert_skip_to_line("Enter choice: 1:\tTest fdtfile env var"); - - /* Verify fdtdir constructed path from soc-board */ - ut_assert_nextline("Retrieving file: /vmlinuz"); - ut_assert_nextline("append: console=ttyS0"); - ut_assert_nextline("Retrieving file: /dtb/tegra-jetson.dtb"); - ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); - - /* Boot fails but we verified the path construction */ - ut_assert_nextline("Unrecognized zImage"); + ut_assertok(pxe_check_fdtdir(uts, "tegra-jetson.dtb")); + ut_assert_console_end(); /* Verify FDT was loaded */ fdt = map_sysmem(PXE_FDT_ADDR, 0); @@ -455,12 +518,19 @@ static int pxe_test_errors_norun(struct unit_test_state *uts) ut_assertok(run_commandf("sysboot host 0:0 any %x %s", PXE_LOAD_ADDR, cfg_path)); + /* Check menu output */ + ut_assert_nextline("Retrieving file: /extlinux/extlinux.conf"); + ut_assert_nextline("Test Boot Menu"); + ut_assert_nextline("1:\tMissing explicit FDT"); + ut_assert_nextline("2:\tMissing fdtdir FDT"); + ut_assert_nextline("3:\tMissing overlay"); + ut_assert_nextline("Enter choice: 1:\tMissing explicit FDT"); + /* * Test 1: Explicit FDT file not found * First label (missing-fdt) has fdt=/dtb/nonexistent.dtb * Should fail and move to next label */ - ut_assert_skip_to_line("Enter choice: 1:\tMissing explicit FDT"); ut_assert_nextline("Retrieving file: /vmlinuz"); ut_assert_nextline("Retrieving file: /dtb/nonexistent.dtb"); ut_assert_nextline("Skipping missing-fdt for failure retrieving FDT"); @@ -480,6 +550,7 @@ static int pxe_test_errors_norun(struct unit_test_state *uts) * that label loading continued despite missing fdtdir FDT */ ut_assert_nextline("Unrecognized zImage"); + ut_assert_console_end(); /* Clean up env vars */ env_set("fdtfile", NULL); @@ -632,8 +703,12 @@ static int pxe_test_ipappend_norun(struct unit_test_state *uts) ut_assertok(run_commandf("sysboot host 0:0 any %x %s", PXE_LOAD_ADDR, cfg_path)); - /* Skip to the rescue label boot */ - ut_assert_skip_to_line("Retrieving file: /vmlinuz-rescue"); + /* Check menu output */ + ut_assertok(pxe_check_menu(uts, "Booting default Linux kernel", NULL)); + ut_assert_nextline("Enter choice: 2:\tRescue Mode"); + + /* Rescue label boot attempt */ + ut_assert_nextline("Retrieving file: /vmlinuz-rescue"); /* * Verify ipappend output - should have: @@ -644,6 +719,15 @@ static int pxe_test_ipappend_norun(struct unit_test_state *uts) ut_assert_nextlinen("append: single ip=192.168.1.10:192.168.1.1:" "192.168.1.254:255.255.255.0 BOOTIF=01-"); + /* + * Rescue label has fdtdir=/dtb/ but no fdtfile is set, so it tries + * to load /dtb/.dtb which fails. Boot still proceeds without FDT. + */ + ut_assert_nextline("Retrieving file: /dtb/.dtb"); + ut_assert_nextline("Skipping fdtdir /dtb/ for failure retrieving dts"); + ut_assert_nextline("Unrecognized zImage"); + ut_assert_console_end(); + /* Clean up */ env_set("ipaddr", NULL); env_set("serverip", NULL); @@ -729,6 +813,7 @@ static int pxe_test_label_override_norun(struct unit_test_state *uts) ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); ut_assertok(env_set_hex("ramdisk_addr_r", PXE_INITRD_ADDR)); ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + ut_assertok(env_set_hex("fdtoverlay_addr_r", PXE_OVERLAY_ADDR)); ut_assertok(env_set("bootfile", cfg_path)); ut_assertok(env_set("pxe_timeout", "1")); @@ -737,16 +822,40 @@ static int pxe_test_label_override_norun(struct unit_test_state *uts) ut_assertok(run_commandf("sysboot host 0:0 any %x %s", PXE_LOAD_ADDR, cfg_path)); + /* Check menu output - say message is from default label */ + ut_assertok(pxe_check_menu(uts, "Booting default Linux kernel", NULL)); + /* Should boot 'local' label instead of default 'linux' */ - ut_assert_skip_to_line("3:\tLocal Boot"); - ut_assert_skip_to_line("missing environment variable: localcmd"); + ut_assert_nextline("Enter choice: 3:\tLocal Boot"); + ut_assert_nextline("missing environment variable: localcmd"); + + /* + * Localboot fails, so try default 'linux' label instead. + * Boot is minimal - just kernel/initrd, no FDT. + */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("Retrieving file: /initrd.img"); + ut_assert_nextline("Unrecognized zImage"); - /* Test 2: Invalid override - should print error */ + /* Test 2: Invalid override - should print error before menu */ ut_assertok(env_set("pxe_label_override", "nonexistent")); ut_assertok(run_commandf("sysboot host 0:0 any %x %s", PXE_LOAD_ADDR, cfg_path)); - ut_assert_skip_to_line("Missing override pxe label: nonexistent"); + /* Check menu with error message before it */ + ut_assertok(pxe_check_menu(uts, "Booting default Linux kernel", + "Missing override pxe label: nonexistent")); + ut_assert_nextline("Enter choice: 1:\tBoot Linux"); + + /* Default label boot attempt */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("Retrieving file: /initrd.img"); + ut_assert_nextline("append: root=/dev/sda1 quiet"); + ut_assert_nextline("Retrieving file: /dtb/board.dtb"); + ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); + ut_assert_nextline("Retrieving file: /dtb/overlay2.dtbo"); + ut_assert_nextline("Unrecognized zImage"); + ut_assert_console_end(); /* Clean up */ ut_assertok(env_set("pxe_label_override", NULL)); From patchwork Fri Jan 9 23:11:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1400 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=1768000354; bh=VM5Rd9GD0kBTumslDVptv9baUoSbBPhKlo3EBrOFsb4=; 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=iqa7LySEGpM7iCOtkGHtOpNTzF/LTd/TVh7MjF18eCS1YoSBF1Y2O1nv6bV8BhRXC MU+mSx6lz8ShBPiBU1X/ZAL9kjNsk+yA1tZFiMd6BuGdjk1tvj55Dfd33orQSXVxIa CgPvTX8txAWJSUOG8+e05cl+vdmoVU47owfXzKv/8jYznuf2S2GhBfH/D6GDxEBZw8 t//L79/zh24EEiVKRlxuj1DYU5Qu8XauqUxf7/EjOI7DqwqIU7Li/binBpiCjr/E7t RFSnr0plW40ekjARmYdCd7rBihhDM5Y0q1fuNBLNtLZd9Ko7UzfmfC0D6SvWil1gH9 7ZQDdysbgpA3A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7A98E6923D for ; Fri, 9 Jan 2026 16:12: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 JvDwLHmKoiOS for ; Fri, 9 Jan 2026 16:12:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000354; bh=VM5Rd9GD0kBTumslDVptv9baUoSbBPhKlo3EBrOFsb4=; 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=iqa7LySEGpM7iCOtkGHtOpNTzF/LTd/TVh7MjF18eCS1YoSBF1Y2O1nv6bV8BhRXC MU+mSx6lz8ShBPiBU1X/ZAL9kjNsk+yA1tZFiMd6BuGdjk1tvj55Dfd33orQSXVxIa CgPvTX8txAWJSUOG8+e05cl+vdmoVU47owfXzKv/8jYznuf2S2GhBfH/D6GDxEBZw8 t//L79/zh24EEiVKRlxuj1DYU5Qu8XauqUxf7/EjOI7DqwqIU7Li/binBpiCjr/E7t RFSnr0plW40ekjARmYdCd7rBihhDM5Y0q1fuNBLNtLZd9Ko7UzfmfC0D6SvWil1gH9 7ZQDdysbgpA3A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 651FE69239 for ; Fri, 9 Jan 2026 16:12:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000353; bh=tPEjfvbEW6KHjmNTtmtpuqeQp9r0QY/Aibv+0TWnXlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YntkLXRZ/ry4KsQ861tLztP1k1UqPQOOiasVuCfphQRVifbqNBuchhkEfCAStZlLa 2HZrhEngaa2eMY81MOUbYSRZRaNCqxzONw4lGMcNY4piMdMdBmGWTB1QF/R2bKoRjW WxgAf98P19UR5LTx8Ho8ryC8+VjAc5MRRuPH3hd6LcUoj1nnvrXXs25bzmv5GlDnmr p+PYWB3A1ct4z+urXx6dtHOPQQIFu+5J2WYR8iXNUVKBwb1/IWQFBfstuxsu0/yyXe 0hlLjbS22UW81OOSwCvc5LoZkYq7CaOcgBiWEETH4UxgOwxajdebQmlGZUgGz08FYv 0tz2N8EFWt84w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C00C69218; Fri, 9 Jan 2026 16:12: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 IqPWV-yJ5qsO; Fri, 9 Jan 2026 16:12:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000349; bh=ytAau9Po52p6F9X9t0XW1CLo9nZD4OSpDBLtk7af0RI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jKKz8XC0FNcMFzrQJrC+J28acHtLbBl70C3Pl8V0geUxBCSJ94IXw0pHNRjBR6RFd AlfX1KZVeVtTC1+yfV5uW1CydgxOwgLC2/Ptkia9M2uGk/5nX05AKdQ3RWEKtogRh7 WPnCuzN7xnzDBTd/5aKw+qVtklyatRkZ2XSQF23B2mEDaN/PzNXMRDLn7mYtB05INB 1B45t9egABQ22BH+F6XNLiUz+9L8vSzMcA2ddDim6GrfaOacqWrtt5EzSbEgoUI9wa 8ybWpdMqQbf3dS2aq9zh9+OwcbWNA5U6kjtEh+T0uoOxX+ig0PIFFXuEhccCvKprVu EapGOuDSk8+Xw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1EB0C69206; Fri, 9 Jan 2026 16:12:29 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:13 -0700 Message-ID: <20260109231151.4056804-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BPQKEZMWBKTVPCQ22BM6WDZWK5TVIXFZ X-Message-ID-Hash: BPQKEZMWBKTVPCQ22BM6WDZWK5TVIXFZ 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/32] test: pxe: Test devicetree alias keywords 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 Test the alias keywords for device tree options: - devicetree (alias for fdt) - devicetreedir (alias for fdtdir) - devicetree-overlay (alias for fdtoverlays) These use the same parsing code as their primary keywords, but verifying they work correctly ensures compatibility with configs that use either form. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/py/tests/test_pxe_parser.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index d52bf3e6b50..61ff6d11e3e 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -84,8 +84,11 @@ def create_extlinux_conf(srcdir, labels, menu_opts=None): - initrd: Initrd path (optional) - append: Kernel arguments (optional) - fdt: Device tree path (optional) + - devicetree: Device tree path (alias for fdt) - fdtdir: Device tree directory (optional) + - devicetreedir: Device tree directory (alias for fdtdir) - fdtoverlays: Device tree overlays (optional) + - devicetree-overlay: Device tree overlays (alias) - localboot: Local boot flag (optional) - ipappend: IP append flags (optional) - fit: FIT config path (optional) @@ -145,10 +148,16 @@ def create_extlinux_conf(srcdir, labels, menu_opts=None): fd.write(f" append {label['append']}\n") if 'fdt' in label: fd.write(f" fdt {label['fdt']}\n") + if 'devicetree' in label: + fd.write(f" devicetree {label['devicetree']}\n") if 'fdtdir' in label: fd.write(f" fdtdir {label['fdtdir']}\n") + if 'devicetreedir' in label: + fd.write(f" devicetreedir {label['devicetreedir']}\n") if 'fdtoverlays' in label: fd.write(f" fdtoverlays {label['fdtoverlays']}\n") + if 'devicetree-overlay' in label: + fd.write(f" devicetree-overlay {label['devicetree-overlay']}\n") if 'localboot' in label: fd.write(f" localboot {label['localboot']}\n") if 'ipappend' in label: @@ -181,8 +190,9 @@ def pxe_image(u_boot_config): 'kernel': '/vmlinuz', 'initrd': '/initrd.img', 'append': 'root=/dev/sda1 quiet', - 'fdt': '/dtb/board.dtb', - 'fdtoverlays': '/dtb/overlay1.dtbo /dtb/overlay2.dtbo', + # Use aliases to test devicetree/devicetree-overlay keywords + 'devicetree': '/dtb/board.dtb', + 'devicetree-overlay': '/dtb/overlay1.dtbo /dtb/overlay2.dtbo', 'kaslrseed': True, 'say': 'Booting default Linux kernel', 'default': True, @@ -192,7 +202,7 @@ def pxe_image(u_boot_config): 'menu': 'Rescue Mode', 'linux': '/vmlinuz-rescue', # test 'linux' keyword 'append': 'single', - 'fdtdir': '/dtb/', + 'devicetreedir': '/dtb/', # test alias for fdtdir 'ipappend': '3', }, { From patchwork Fri Jan 9 23:11:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1401 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=1768000360; bh=gWNFy/A/EZnvYXNVs9xMAApof8N5HU1/SW45Q1HFI8E=; 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=W0IhmI4OwcqIqderD4dkjJ8HI6QCcgfRwgneyOrEihLCOEAzjPcuzbeIu7DljsEWc 5NWlBWe+viJ8QrZOfq7Gb3U73uXnlgT0Ok262QX0241gsoOK9YoFZerAf4WezhdGtZ ktWKFCpIk26U1itbUu+RQ7uRcNxH4XXJr08ptNhFhr1a3o/kxIfRGHbl36K7J81+sQ lPNvDD5i0Ka8nxceCUB7tkEw/DdIn2WHqCohk75RrPclQLGT4fUFQYUhNVF9XJ/ZCJ mdMdsCHUNBD5Qxi6cmzxn5P8OQfWqzMA+sWEr3JxEeoPld8JHSu3ZPlJdZ0FUrANeE ftAcChQwsBBgg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5323E6923E for ; Fri, 9 Jan 2026 16:12:40 -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 YilnbRi9TRiD for ; Fri, 9 Jan 2026 16:12:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000360; bh=gWNFy/A/EZnvYXNVs9xMAApof8N5HU1/SW45Q1HFI8E=; 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=W0IhmI4OwcqIqderD4dkjJ8HI6QCcgfRwgneyOrEihLCOEAzjPcuzbeIu7DljsEWc 5NWlBWe+viJ8QrZOfq7Gb3U73uXnlgT0Ok262QX0241gsoOK9YoFZerAf4WezhdGtZ ktWKFCpIk26U1itbUu+RQ7uRcNxH4XXJr08ptNhFhr1a3o/kxIfRGHbl36K7J81+sQ lPNvDD5i0Ka8nxceCUB7tkEw/DdIn2WHqCohk75RrPclQLGT4fUFQYUhNVF9XJ/ZCJ mdMdsCHUNBD5Qxi6cmzxn5P8OQfWqzMA+sWEr3JxEeoPld8JHSu3ZPlJdZ0FUrANeE ftAcChQwsBBgg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3F48C69235 for ; Fri, 9 Jan 2026 16:12:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000358; bh=NfmgekX5dJe0aSVnMWlRILK9g7vLW7HTvkixc4A/kFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pN9lv12dhM7NjsA3H1XYHSAA1rYFnsug3XFNasTV+0zsiTqQYBNzATLviHjIAwLZ8 psf7Lr08OR2wlmY2nkC0AXWDQDH6/nwkxQtprvUY/RgOvtiKfsJe91XdX6eSxqcxuz qFssIIYPf81AsyOoR6+tCJu+1velOWlyeT42if3QYF8O8AgXV3l+xdSv1GOmsNhUgU tSVVV3uTWJyG4F+UiBWRJwXRF0rqGyM/Lhfhj2/PpZIgZ9dWMkhNNl2aOa8lgYkjrW LEc1yucj5CtZLmvYPgWFEqcu5cg1GfR6nwSiWtHgMuL3L2Gl9KFq2/7j337wSerbVE 9vnZ/NCtxj0og== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 441C369218; Fri, 9 Jan 2026 16:12:38 -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 inq-ow_LOpQ6; Fri, 9 Jan 2026 16:12:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000354; bh=ou34P1jUfnyICKjvBEnEdYzGm1X5WPlCxJM/g++taD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qk/JLf4jTB7LITOWBM8iFlu3nHkB5d8QDjU1witZtNK4qX1fb2MxGHaaglKc8nNes qGYfgl2AYJk8wiIWQJVxbRTRDljs+5ZpxSBDf5gLEgtEHJjNafilEOI/SfxmqBsUF/ KZX6Y6EI++WVsEDne6qI9ejUmc1B5pP6ItFEH4/62R7qUiUuCkduUpmZYAVT4u+IFm pMstckh6Q/lz2+AZeRoYzqpMdCbBJ4IODIuMlvoM0nA1B5nBwA6zaJZ66BpCde+Jn2 mt2g6KtiO6mdIQYM3+F3FmA5joeaTDfKhXlUxCSjQLDcD2mAQ1JVLH/6EG4hB+FYzK yetCajw6ZO+Fw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C0E2569206; Fri, 9 Jan 2026 16:12:33 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:14 -0700 Message-ID: <20260109231151.4056804-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZAMM5OEQYUJUHHXELAX4RZNWBQN27HEE X-Message-ID-Hash: ZAMM5OEQYUJUHHXELAX4RZNWBQN27HEE 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/32] boot: pxe: Add separate APIs for label selection and 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 The extlinux.conf parser is currently tightly coupled with the boot logic. While a no_boot flag exists in pxe_context to defer booting, files are still loaded before the flag is checked. This makes it difficult to simply parse a config and inspect the available labels without performing file operations. Add two new public APIs to enable finer-grained control: - pxe_select_label(): Select a label from a parsed menu using the menu system, without loading any files. Returns the selected pxe_label pointer. - pxe_load_label(): Load kernel/initrd/FDT for a specific label into memory, saving addresses and sizes in the pxe_context. These allow callers to: 1. Parse a config with parse_pxefile() 2. Inspect labels without loading (iterate cfg->labels) 3. Optionally select a label with pxe_select_label() 4. Optionally load files with pxe_load_label() 5. Optionally boot with pxe_do_boot() The existing high-level APIs (pxe_process(), pxe_probe() and pxe_do_boot()) continue to work unchanged for backward compatibility. The only functional change is that the kernel command-line is processed after all files are loaded, so update the tests to handle this. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 252 ++++++++++++++++++++++++++------------------ include/pxe_utils.h | 29 +++++ test/boot/pxe.c | 23 ++-- 3 files changed, 193 insertions(+), 111 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 9034c3d86e7..384293d9f8a 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -678,63 +678,34 @@ static int generate_localboot(struct pxe_label *label) return 0; } -/** - * label_boot() - Boot according to the contents of a pxe_label - * - * If we can't boot for any reason, we return. A successful boot never - * returns. - * - * The kernel will be stored in the location given by the 'kernel_addr_r' - * environment variable. - * - * If the label specifies an initrd file, it will be stored in the location - * given by the 'ramdisk_addr_r' environment variable. - * - * If the label specifies an 'append' line, its contents will overwrite that - * of the 'bootargs' environment variable. - * - * @ctx: PXE context - * @label: Label to process - * Returns does not return on success, otherwise returns 0 if a localboot - * label was processed, or 1 on error - */ -static int label_boot(struct pxe_context *ctx, struct pxe_label *label) +int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) { - char *kern_addr_str; + char fit_addr[200]; + const char *conf_fdt_str; ulong kern_addr = 0; ulong initrd_addr = 0; ulong initrd_size = 0; - char initrd_str[28] = ""; - char mac_str[29] = ""; - char ip_str[68] = ""; - char fit_addr[200]; - const char *conf_fdt_str; - ulong conf_fdt = 0; ulong kern_size; + ulong conf_fdt = 0; + char initrd_str[28] = ""; int ret; - label_print(label); - - label->attempted = 1; - if (label->localboot) { if (label->localboot_val >= 0) { - ret = label_localboot(label); - - if (IS_ENABLED(CONFIG_BOOTMETH_EXTLINUX_LOCALBOOT) && - ret == -ENOENT) + if (IS_ENABLED(CONFIG_BOOTMETH_EXTLINUX_LOCALBOOT)) { ret = generate_localboot(label); - if (ret) - return ret; - } else { - return 0; + if (ret) + return ret; + } } + /* negative localboot_val means skip loading */ + if (!label->kernel) + return 0; } if (!label->kernel) { - printf("No kernel given, skipping %s\n", - label->name); - return 1; + printf("No kernel given, skipping %s\n", label->name); + return -ENOENT; } if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r", SZ_2M, @@ -742,20 +713,18 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) &kern_addr, &kern_size) < 0) { printf("Skipping %s for failure retrieving kernel\n", label->name); - return 1; + return -EIO; } /* for FIT, append the configuration identifier */ snprintf(fit_addr, sizeof(fit_addr), "%lx%s", kern_addr, label->config ? label->config : ""); - kern_addr_str = fit_addr; /* For FIT, the label can be identical to kernel one */ if (label->initrd && !strcmp(label->kernel_label, label->initrd)) { initrd_addr = kern_addr; } else if (label->initrd) { ulong size; - int ret; ret = get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r", SZ_2M, @@ -764,12 +733,106 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) if (ret < 0) { printf("Skipping %s for failure retrieving initrd\n", label->name); - return 1; + return -EIO; } initrd_size = size; size = snprintf(initrd_str, sizeof(initrd_str), "%lx:%lx", initrd_addr, size); if (size >= sizeof(initrd_str)) + return -ENOSPC; + } + + conf_fdt_str = env_get("fdt_addr_r"); + ret = label_process_fdt(ctx, label, fit_addr, &conf_fdt_str); + if (ret) + return ret; + + if (!conf_fdt_str) + conf_fdt_str = pxe_get_fdt_fallback(label, kern_addr); + if (conf_fdt_str) + conf_fdt = hextoul(conf_fdt_str, NULL); + log_debug("conf_fdt %lx\n", conf_fdt); + + if (ctx->bflow && conf_fdt_str) + ctx->bflow->fdt_addr = conf_fdt; + + /* Save the loaded info to context */ + ctx->label = label; + ctx->kern_addr_str = strdup(fit_addr); + ctx->kern_addr = kern_addr; + ctx->kern_size = kern_size; + if (initrd_addr) { + ctx->initrd_addr = initrd_addr; + ctx->initrd_size = initrd_size; + ctx->initrd_str = strdup(initrd_str); + } + ctx->conf_fdt_str = strdup(conf_fdt_str); + ctx->conf_fdt = conf_fdt; + + log_debug("Loaded label '%s':\n", label->name); + log_debug("- kern_addr_str '%s' conf_fdt_str '%s' conf_fdt %lx\n", + ctx->kern_addr_str, ctx->conf_fdt_str, conf_fdt); + if (initrd_addr) { + log_debug("- initrd addr %lx filesize %lx str '%s'\n", + ctx->initrd_addr, ctx->initrd_size, ctx->initrd_str); + } + if (!ctx->kern_addr_str || (conf_fdt_str && !ctx->conf_fdt_str) || + (initrd_addr && !ctx->initrd_str)) { + printf("malloc fail (saving label)\n"); + return -ENOMEM; + } + + return 0; +} + +/** + * label_boot() - Boot according to the contents of a pxe_label + * + * If we can't boot for any reason, we return. A successful boot never + * returns. + * + * The kernel will be stored in the location given by the 'kernel_addr_r' + * environment variable. + * + * If the label specifies an initrd file, it will be stored in the location + * given by the 'ramdisk_addr_r' environment variable. + * + * If the label specifies an 'append' line, its contents will overwrite that + * of the 'bootargs' environment variable. + * + * @ctx: PXE context + * @label: Label to process + * Returns does not return on success, otherwise returns 0 if a localboot + * label was processed, or 1 on error + */ +static int label_boot(struct pxe_context *ctx, struct pxe_label *label) +{ + char mac_str[29] = ""; + char ip_str[68] = ""; + int ret; + + label_print(label); + + label->attempted = 1; + + if (label->localboot) { + if (label->localboot_val >= 0) { + ret = label_localboot(label); + + if (IS_ENABLED(CONFIG_BOOTMETH_EXTLINUX_LOCALBOOT) && + ret == -ENOENT) + ret = generate_localboot(label); + if (ret) + return ret; + } else { + return 0; + } + } + + /* Load files if not already loaded */ + if (!ctx->label) { + ret = pxe_load_label(ctx, label); + if (ret) return 1; } @@ -815,51 +878,13 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) printf("append: %s\n", finalbootargs); } - conf_fdt_str = env_get("fdt_addr_r"); - ret = label_process_fdt(ctx, label, kern_addr_str, &conf_fdt_str); - if (ret) - return ret; - - if (!conf_fdt_str) - conf_fdt_str = pxe_get_fdt_fallback(label, kern_addr); - if (conf_fdt_str) - conf_fdt = hextoul(conf_fdt_str, NULL); - log_debug("conf_fdt %lx\n", conf_fdt); - - if (ctx->bflow && conf_fdt_str) - ctx->bflow->fdt_addr = conf_fdt; - - if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && ctx->no_boot) { - ctx->label = label; - ctx->kern_addr_str = strdup(kern_addr_str); - ctx->kern_addr = kern_addr; - ctx->kern_size = kern_size; - if (initrd_addr) { - ctx->initrd_addr = initrd_addr; - ctx->initrd_size = initrd_size; - ctx->initrd_str = strdup(initrd_str); - } - ctx->conf_fdt_str = strdup(conf_fdt_str); - ctx->conf_fdt = conf_fdt; - log_debug("Saving label '%s':\n", label->name); - log_debug("- kern_addr_str '%s' conf_fdt_str '%s' conf_fdt %lx\n", - ctx->kern_addr_str, ctx->conf_fdt_str, conf_fdt); - if (initrd_addr) { - log_debug("- initrd addr %lx filesize %lx str '%s'\n", - ctx->initrd_addr, ctx->initrd_size, - ctx->initrd_str); - } - if (!ctx->kern_addr_str || (conf_fdt_str && !ctx->conf_fdt_str) || - (initrd_addr && !ctx->initrd_str)) { - printf("malloc fail (saving label)\n"); - return 1; - } + if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && ctx->no_boot) return 0; - } - label_run_boot(ctx, label, kern_addr_str, kern_addr, kern_size, - initrd_addr, initrd_size, initrd_str, conf_fdt_str, - conf_fdt); + label_run_boot(ctx, label, ctx->kern_addr_str, ctx->kern_addr, + ctx->kern_size, ctx->initrd_addr, ctx->initrd_size, + ctx->initrd_str, ctx->conf_fdt_str, ctx->conf_fdt); + /* ignore the error value since we are going to fail anyway */ /* * Sandbox cannot boot a real kernel, so stop after the first attempt. @@ -1017,12 +1042,44 @@ static void boot_unattempted_labels(struct pxe_context *ctx, } } -void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) +int pxe_select_label(struct pxe_menu *cfg, bool prompt, + struct pxe_label **labelp) { void *choice; struct menu *m; int err; + if (prompt) + cfg->prompt = 1; + + m = pxe_menu_to_menu(cfg); + if (!m) + return -ENOMEM; + + err = menu_get_choice(m, &choice); + menu_destroy(m); + + /* + * err == 1 means we got a choice back from menu_get_choice. + * + * err == -ENOENT if the menu was setup to select the default but no + * default was set. + * + * otherwise, the user interrupted or there was some other error. + */ + if (err == 1) { + *labelp = choice; + return 0; + } + + return err == -ENOENT ? -ENOENT : -ECANCELED; +} + +void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) +{ + struct pxe_label *label; + int err; + if (IS_ENABLED(CONFIG_CMD_BMP)) { /* display BMP if available */ if (cfg->bmp) { @@ -1044,15 +1101,10 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) } } - m = pxe_menu_to_menu(cfg); - if (!m) - return; - - err = menu_get_choice(m, &choice); - menu_destroy(m); + err = pxe_select_label(cfg, false, &label); /* - * err == 1 means we got a choice back from menu_get_choice. + * err == 0 means we got a choice back. * * err == -ENOENT if the menu was setup to select the default but no * default was set. in that case, we should continue trying to boot @@ -1062,8 +1114,8 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) * we give up. */ - if (err == 1) { - err = label_boot(ctx, choice); + if (!err) { + err = label_boot(ctx, label); log_debug("label_boot() returns %d\n", err); if (!err) return; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 9629f051a91..ef664f075a0 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -358,6 +358,35 @@ int pxe_probe(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt); */ int pxe_do_boot(struct pxe_context *ctx); +/** + * pxe_select_label() - Select a label from a parsed menu + * + * Uses the menu system to get the user's choice or the default. + * Does NOT load any files or attempt to boot. + * + * @cfg: Parsed PXE menu + * @prompt: Force user prompt regardless of timeout + * @labelp: Returns selected label (not a copy, points into cfg) + * Return: 0 on success, -ENOMEM if out of memory, -ENOENT if no default set, + * -ECANCELED if user cancelled + */ +int pxe_select_label(struct pxe_menu *cfg, bool prompt, + struct pxe_label **labelp); + +/** + * pxe_load_label() - Load kernel/initrd/FDT for a label + * + * Loads the files specified in the label into memory and saves the + * addresses and sizes in @ctx. Call this only when ready to boot or + * inspect loaded files. + * + * @ctx: PXE context with getfile callback + * @label: Label whose files to load + * Return: 0 on success, -ENOENT if no kernel specified, -EIO if file + * retrieval failed, -ENOMEM if out of memory + */ +int pxe_load_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. diff --git a/test/boot/pxe.c b/test/boot/pxe.c index f12add77db6..db1cf48d7a5 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -145,11 +145,11 @@ static int pxe_check_fdtdir(struct unit_test_state *uts, const char *dtb_name) ut_assert_nextline("2:\tTest soc/board construction"); ut_assert_nextline("Enter choice: 1:\tTest fdtfile env var"); - /* Boot file retrieval */ + /* Boot file retrieval - FDT/overlays loaded before append is printed */ ut_assert_nextline("Retrieving file: /vmlinuz"); - ut_assert_nextline("append: console=ttyS0"); ut_assert_nextline("Retrieving file: /dtb/%s", dtb_name); ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); + ut_assert_nextline("append: console=ttyS0"); /* Boot fails on sandbox */ ut_assert_nextline("Unrecognized zImage"); @@ -375,10 +375,10 @@ static int pxe_test_sysboot_norun(struct unit_test_state *uts) /* Verify files were loaded in order */ ut_assert_nextline("Retrieving file: /vmlinuz"); ut_assert_nextline("Retrieving file: /initrd.img"); - ut_assert_nextline("append: root=/dev/sda1 quiet"); ut_assert_nextline("Retrieving file: /dtb/board.dtb"); ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); ut_assert_nextline("Retrieving file: /dtb/overlay2.dtbo"); + ut_assert_nextline("append: root=/dev/sda1 quiet"); /* Boot fails on sandbox */ ut_assert_nextline("Unrecognized zImage"); @@ -710,6 +710,13 @@ static int pxe_test_ipappend_norun(struct unit_test_state *uts) /* Rescue label boot attempt */ ut_assert_nextline("Retrieving file: /vmlinuz-rescue"); + /* + * Rescue label has fdtdir=/dtb/ but no fdtfile is set, so it tries + * to load /dtb/.dtb which fails. FDT is loaded before append. + */ + ut_assert_nextline("Retrieving file: /dtb/.dtb"); + ut_assert_nextline("Skipping fdtdir /dtb/ for failure retrieving dts"); + /* * Verify ipappend output - should have: * - original append: "single" @@ -719,12 +726,6 @@ static int pxe_test_ipappend_norun(struct unit_test_state *uts) ut_assert_nextlinen("append: single ip=192.168.1.10:192.168.1.1:" "192.168.1.254:255.255.255.0 BOOTIF=01-"); - /* - * Rescue label has fdtdir=/dtb/ but no fdtfile is set, so it tries - * to load /dtb/.dtb which fails. Boot still proceeds without FDT. - */ - ut_assert_nextline("Retrieving file: /dtb/.dtb"); - ut_assert_nextline("Skipping fdtdir /dtb/ for failure retrieving dts"); ut_assert_nextline("Unrecognized zImage"); ut_assert_console_end(); @@ -847,13 +848,13 @@ static int pxe_test_label_override_norun(struct unit_test_state *uts) "Missing override pxe label: nonexistent")); ut_assert_nextline("Enter choice: 1:\tBoot Linux"); - /* Default label boot attempt */ + /* Default label boot attempt - FDT/overlays loaded before append */ ut_assert_nextline("Retrieving file: /vmlinuz"); ut_assert_nextline("Retrieving file: /initrd.img"); - ut_assert_nextline("append: root=/dev/sda1 quiet"); ut_assert_nextline("Retrieving file: /dtb/board.dtb"); ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); ut_assert_nextline("Retrieving file: /dtb/overlay2.dtbo"); + ut_assert_nextline("append: root=/dev/sda1 quiet"); ut_assert_nextline("Unrecognized zImage"); ut_assert_console_end(); From patchwork Fri Jan 9 23:11:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1402 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=1768000364; bh=Y3jKJOfgkBtcoq7461/ZZa36NWQUSLWsC+tgYqvIjd4=; 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=pIkYKXcuuT/E6FFqj9Al4YwTmKGQU/RQVDlInzc+d0U7gtGcawxbaFy4GSKycJHE4 cQ1h5csvCzku/wgHwO85aI17orxgnJVxmRV7mJrYRcuvJeYGW8ZkQN4+LSttFsl8sp l8Vlp1zszXQBh7XOLodhJGNDOQYZJdh+aPHlZz+pFKH+ehB/FBwzQ6eXhJWnYOC1Xi EC32LxX/bK1NuipzT8a5JOlWrN4X7XCjj4sPeAFHALadC7udvyK5o3gQ4wJN/dS+m+ TulPqsfg+I2jHjdzw6y/dajFKRAyqbn8ED+jAVWk7vS4DILC8wA/9+SsJXBWbjSz9Q XTQUhpTmBVuWw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D781869218 for ; Fri, 9 Jan 2026 16:12: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 10024) with ESMTP id 7iZWmeJ9dQ5k for ; Fri, 9 Jan 2026 16:12:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000364; bh=Y3jKJOfgkBtcoq7461/ZZa36NWQUSLWsC+tgYqvIjd4=; 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=pIkYKXcuuT/E6FFqj9Al4YwTmKGQU/RQVDlInzc+d0U7gtGcawxbaFy4GSKycJHE4 cQ1h5csvCzku/wgHwO85aI17orxgnJVxmRV7mJrYRcuvJeYGW8ZkQN4+LSttFsl8sp l8Vlp1zszXQBh7XOLodhJGNDOQYZJdh+aPHlZz+pFKH+ehB/FBwzQ6eXhJWnYOC1Xi EC32LxX/bK1NuipzT8a5JOlWrN4X7XCjj4sPeAFHALadC7udvyK5o3gQ4wJN/dS+m+ TulPqsfg+I2jHjdzw6y/dajFKRAyqbn8ED+jAVWk7vS4DILC8wA/9+SsJXBWbjSz9Q XTQUhpTmBVuWw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C333569240 for ; Fri, 9 Jan 2026 16:12:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000362; bh=l0qpEcDMby30KdMdfz10U18ak5q8ycSzkCYU/VTd3q0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WD6fG0hdxYrgz5wsWoFzJBjMNyKFDxQ/jvRV2BGcA24X/hZmtTK0gmOaDzmyiUEH/ 5uwEbywjKW5V1zNgslGIX8veB4xZ80aZY6DXkkMVWd9j+uQF4EotVCVboVxWMm2Km6 fVEDyAtzbAFPD1pvSvJWJ1PH+NuaCsRamFWyAUDDdoUVXv9f9xfhjj31URu5sASk3q OY/cgv/aKpU765CBjnmThxv1EMtaKmhLDjqNxz8byfWFCD9Di1usJsrhh4VlMDI1Fc iHPflInMYAVcwYfsY+gJK21Mab7B4fz61vd+gXs+i4T3Aa5RPs9PT0oQ2rIQTCXoqo rOeQgDLo/pavg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E589C69235; Fri, 9 Jan 2026 16:12: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 10026) with ESMTP id P2HACfXKWwG3; Fri, 9 Jan 2026 16:12:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000358; bh=zU608lj3XabyZY8jiCwDr+3KQbKtRX8AiDuXCeK0AYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FeO+K0dpG06TaPQlGSW1P9QjaPItiyjt0VxghR7KWcDqFWnfwUvxP6ADe1ia0Zfr2 Nei7jreiJWTKYyG92QTB/pIm0r2Y3nuc3Ghws0+nZQOlqBMNGWEDFN0HUfuhnN0gXA A7hoHfLP1q40F0rRFdSleu+Zj/8eM5IlkTPc9cRkg2X5IcxutLxYjMLhktcHzsknyb WlNuvjPDP15pdVr8g4D6UGLptpeHaNk89Xuxs1ONZCDEoqYzGsz4H5ll0rOGRiMDXx xShWVBxw3zg7X24MaNUhOBGYAd9X9VRMbPB0hKHa3Rf9lHZ+FwvyAou8T08n4aQiyU Yh8l5WVflsBWQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 80D6B69206; Fri, 9 Jan 2026 16:12:38 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:15 -0700 Message-ID: <20260109231151.4056804-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QLTI3E5DLOOU7GKRBNEUBKBIJ5PH3UVO X-Message-ID-Hash: QLTI3E5DLOOU7GKRBNEUBKBIJ5PH3UVO 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/32] boot: pxe: Update tests to use the new 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 Update pxe_test_fdtdir_norun() and pxe_test_errors_norun() to use the new API calls, to avoid having to go through the syslinux command. This will make it easier to build on the tests over time. We still have the other tests to check syslinux. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 217 ++++++++++++++++++++++++++++++------------------ 1 file changed, 134 insertions(+), 83 deletions(-) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index db1cf48d7a5..2ee2ad24a7d 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -126,37 +126,6 @@ static int pxe_check_menu(struct unit_test_state *uts, const char *say_msg, return 0; } -/** - * pxe_check_fdtdir() - Check fdtdir test menu and boot output - * - * Helper for pxe_test_fdtdir_norun() that checks the menu output and boot - * file retrieval messages for the fdtdir test configuration. - * - * @uts: Unit test state - * @dtb_name: Expected DTB filename (e.g., "test-board.dtb") - * Return: 0 if OK, -ve on error - */ -static int pxe_check_fdtdir(struct unit_test_state *uts, const char *dtb_name) -{ - /* Menu output */ - ut_assert_nextline("Retrieving file: /extlinux/extlinux.conf"); - ut_assert_nextline("Test Boot Menu"); - ut_assert_nextline("1:\tTest fdtfile env var"); - ut_assert_nextline("2:\tTest soc/board construction"); - ut_assert_nextline("Enter choice: 1:\tTest fdtfile env var"); - - /* Boot file retrieval - FDT/overlays loaded before append is printed */ - ut_assert_nextline("Retrieving file: /vmlinuz"); - ut_assert_nextline("Retrieving file: /dtb/%s", dtb_name); - ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); - ut_assert_nextline("append: console=ttyS0"); - - /* Boot fails on sandbox */ - ut_assert_nextline("Unrecognized zImage"); - - return 0; -} - /** * Test parsing an extlinux.conf file * @@ -413,10 +382,9 @@ PXE_TEST_ARGS(pxe_test_sysboot_norun, UTF_CONSOLE | UTF_MANUAL, { "cfg_path", UT_ARG_STR }); /** - * Test fdtdir path resolution via sysboot + * Test fdtdir path resolution * - * This test verifies fdtdir path construction by running sysboot and - * checking console output: + * This test verifies: * 1. fdtdir with fdtfile env var - uses fdtfile value directly * 2. fdtdir with soc/board env vars - constructs {soc}-{board}.dtb * 3. fdtdir without trailing slash - slash is inserted @@ -425,57 +393,97 @@ static int pxe_test_fdtdir_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_test_info info; + struct pxe_context ctx; + struct pxe_label *label; + struct pxe_menu *cfg; + ulong addr = PXE_LOAD_ADDR; void *fdt; ut_assertnonnull(fs_image); ut_assertnonnull(cfg_path); + info.uts = uts; + /* Bind the filesystem image */ ut_assertok(run_commandf("host bind 0 %s", fs_image)); + /* Set up the PXE context */ + ut_assertok(pxe_setup_ctx(&ctx, pxe_test_getfile, &info, true, cfg_path, + false, false, NULL)); + + /* Read and parse the config file */ + ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); + + cfg = parse_pxefile(&ctx, addr); + ut_assertnonnull(cfg); + + /* Consume parsing output */ + ut_assert_nextline("Retrieving file: %s", cfg_path); + ut_assert_console_end(); + /* * Test 1: fdtdir with fdtfile env var - * The first label uses fdtdir=/dtb/ and we set fdtfile=test-board.dtb - * so it should retrieve /dtb/test-board.dtb + * Set fdtfile=test-board.dtb, load should find /dtb/test-board.dtb */ - ut_assertok(env_set_hex("pxefile_addr_r", PXE_LOAD_ADDR)); + ut_assertok(env_set("fdtfile", "test-board.dtb")); ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); ut_assertok(env_set_hex("fdtoverlay_addr_r", PXE_OVERLAY_ADDR)); - ut_assertok(env_set("fdtfile", "test-board.dtb")); - ut_assertok(env_set("bootfile", cfg_path)); - ut_assertok(run_commandf("sysboot host 0:0 any %x %s", - PXE_LOAD_ADDR, cfg_path)); - ut_assertok(pxe_check_fdtdir(uts, "test-board.dtb")); + /* Get first label (fdtfile-test) and load its files */ + label = list_first_entry(&cfg->labels, struct pxe_label, list); + ut_asserteq_str("fdtfile-test", label->name); + ut_asserteq_str("/dtb/", label->fdtdir); + ut_assertnull(label->fdt); + + ut_assertok(pxe_load_label(&ctx, label)); - /* Verify FDT was loaded correctly */ + /* Verify FDT was loaded */ + ut_asserteq(PXE_FDT_ADDR, ctx.conf_fdt); fdt = map_sysmem(PXE_FDT_ADDR, 0); ut_assertok(fdt_check_header(fdt)); + /* Check console output shows the constructed path */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("Retrieving file: /dtb/test-board.dtb"); + ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); + ut_assert_console_end(); + /* * Test 2: fdtdir with soc/board env vars (no fdtfile) - * Clear fdtfile and set soc/board - the default label (fdtfile-test) - * will now construct the path from soc-board: /dtb/tegra-jetson.dtb + * Set soc=tegra, board=jetson -> /dtb/tegra-jetson.dtb */ ut_assertok(env_set("fdtfile", NULL)); /* Clear fdtfile */ ut_assertok(env_set("soc", "tegra")); ut_assertok(env_set("board", "jetson")); + ctx.conf_fdt = 0; /* Reset for next load */ - ut_assertok(run_commandf("sysboot host 0:0 any %x %s", - PXE_LOAD_ADDR, cfg_path)); - ut_assertok(pxe_check_fdtdir(uts, "tegra-jetson.dtb")); - ut_assert_console_end(); + /* Get second label (socboard-test) */ + label = list_entry(label->list.next, struct pxe_label, list); + ut_asserteq_str("socboard-test", label->name); + ut_asserteq_str("/dtb", label->fdtdir); /* No trailing slash */ - /* Verify FDT was loaded */ + ut_assertok(pxe_load_label(&ctx, label)); + + /* Verify FDT was loaded (slash was inserted) */ + ut_asserteq(PXE_FDT_ADDR, ctx.conf_fdt); fdt = map_sysmem(PXE_FDT_ADDR, 0); - ut_asserteq(FDT_MAGIC, fdt_magic(fdt)); + ut_assertok(fdt_check_header(fdt)); + + /* Check console output shows soc-board construction with slash */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("Retrieving file: /dtb/tegra-jetson.dtb"); + ut_assert_console_end(); /* Clean up env vars */ env_set("fdtfile", NULL); env_set("soc", NULL); env_set("board", NULL); + destroy_pxe_menu(cfg); + pxe_destroy_ctx(&ctx); + return 0; } PXE_TEST_ARGS(pxe_test_fdtdir_norun, UTF_CONSOLE | UTF_MANUAL, @@ -483,77 +491,117 @@ PXE_TEST_ARGS(pxe_test_fdtdir_norun, UTF_CONSOLE | UTF_MANUAL, { "cfg_path", UT_ARG_STR }); /** - * Test error handling for missing FDT files via sysboot + * Test error handling for missing FDT and overlay files * - * This test verifies error handling by running sysboot and checking - * console output: - * 1. Explicit FDT not found - label fails with error, tries next label - * 2. fdtdir FDT not found - warns but continues to boot attempt + * This test verifies: + * 1. Explicit FDT not found - label should fail with error + * 2. fdtdir FDT not found - should warn but continue (return success) + * 3. Missing overlay - should warn but continue loading other overlays */ static int pxe_test_errors_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_test_info info; + struct pxe_context ctx; + struct pxe_label *label; + struct pxe_menu *cfg; + ulong addr = PXE_LOAD_ADDR; + void *fdt; ut_assertnonnull(fs_image); ut_assertnonnull(cfg_path); + info.uts = uts; + /* Bind the filesystem image */ ut_assertok(run_commandf("host bind 0 %s", fs_image)); + /* Set up the PXE context */ + ut_assertok(pxe_setup_ctx(&ctx, pxe_test_getfile, &info, true, cfg_path, + false, false, NULL)); + + /* Read and parse the config file */ + ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); + + cfg = parse_pxefile(&ctx, addr); + ut_assertnonnull(cfg); + + /* Consume parsing output */ + ut_assert_nextline("Retrieving file: %s", cfg_path); + ut_assert_console_end(); + /* Set up environment for loading */ - ut_assertok(env_set_hex("pxefile_addr_r", PXE_LOAD_ADDR)); ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); ut_assertok(env_set_hex("fdtoverlay_addr_r", PXE_OVERLAY_ADDR)); ut_assertok(env_set("fdtfile", "missing.dtb")); /* For fdtdir test */ - ut_assertok(env_set("bootfile", cfg_path)); /* - * Run sysboot - it will try labels in sequence: - * 1. missing-fdt: fails because explicit FDT doesn't exist - * 2. missing-fdtdir: warns about missing FDT but attempts boot - * 3. missing-overlay: loads FDT, warns about missing overlay, boots + * Test 1: Explicit FDT file not found + * Label has fdt=/dtb/nonexistent.dtb - should fail with -ENOENT */ - ut_assertok(run_commandf("sysboot host 0:0 any %x %s", - PXE_LOAD_ADDR, cfg_path)); + label = list_first_entry(&cfg->labels, struct pxe_label, list); + ut_asserteq_str("missing-fdt", label->name); + ut_asserteq_str("/dtb/nonexistent.dtb", label->fdt); - /* Check menu output */ - ut_assert_nextline("Retrieving file: /extlinux/extlinux.conf"); - ut_assert_nextline("Test Boot Menu"); - ut_assert_nextline("1:\tMissing explicit FDT"); - ut_assert_nextline("2:\tMissing fdtdir FDT"); - ut_assert_nextline("3:\tMissing overlay"); - ut_assert_nextline("Enter choice: 1:\tMissing explicit FDT"); + ut_asserteq(-ENOENT, pxe_load_label(&ctx, label)); - /* - * Test 1: Explicit FDT file not found - * First label (missing-fdt) has fdt=/dtb/nonexistent.dtb - * Should fail and move to next label - */ + /* Check error message */ ut_assert_nextline("Retrieving file: /vmlinuz"); ut_assert_nextline("Retrieving file: /dtb/nonexistent.dtb"); ut_assert_nextline("Skipping missing-fdt for failure retrieving FDT"); + ut_assert_console_end(); /* * Test 2: fdtdir with missing FDT file - * Second label (missing-fdtdir) has fdtdir=/dtb/ but fdtfile=missing.dtb - * Should warn but continue to boot attempt + * Label has fdtdir=/dtb/ but fdtfile=missing.dtb doesn't exist + * Should warn but return success (label continues without FDT) */ - ut_assert_nextline("2:\tMissing fdtdir FDT"); + ctx.conf_fdt = 0; + label = list_entry(label->list.next, struct pxe_label, list); + ut_asserteq_str("missing-fdtdir", label->name); + ut_asserteq_str("/dtb/", label->fdtdir); + ut_assertnull(label->fdt); + + ut_assertok(pxe_load_label(&ctx, label)); + + /* Check warning message */ ut_assert_nextline("Retrieving file: /vmlinuz"); ut_assert_nextline("Retrieving file: /dtb/missing.dtb"); ut_assert_nextline("Skipping fdtdir /dtb/ for failure retrieving dts"); + ut_assert_console_end(); /* - * Boot attempt without FDT - sandbox can't boot, but this verifies - * that label loading continued despite missing fdtdir FDT + * Test 3: Missing overlay file (but valid FDT) + * Label has fdt=/dtb/board.dtb (exists) and two overlays: + * - /dtb/nonexistent.dtbo (missing - should warn) + * - /dtb/overlay1.dtbo (exists - should load) */ - ut_assert_nextline("Unrecognized zImage"); + ctx.conf_fdt = 0; + label = list_entry(label->list.next, struct pxe_label, list); + ut_asserteq_str("missing-overlay", label->name); + ut_asserteq_str("/dtb/board.dtb", label->fdt); + + ut_assertok(pxe_load_label(&ctx, label)); + + /* FDT should be loaded */ + ut_asserteq(PXE_FDT_ADDR, ctx.conf_fdt); + fdt = map_sysmem(PXE_FDT_ADDR, 0); + ut_assertok(fdt_check_header(fdt)); + + /* Check console output */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("Retrieving file: /dtb/board.dtb"); + ut_assert_nextline("Retrieving file: /dtb/nonexistent.dtbo"); + ut_assert_nextline("Failed loading overlay /dtb/nonexistent.dtbo"); + ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); ut_assert_console_end(); - /* Clean up env vars */ + /* Clean up */ env_set("fdtfile", NULL); + destroy_pxe_menu(cfg); + pxe_destroy_ctx(&ctx); return 0; } @@ -695,6 +743,9 @@ static int pxe_test_ipappend_norun(struct unit_test_state *uts) ut_assertok(env_set("gatewayip", "192.168.1.254")); ut_assertok(env_set("netmask", "255.255.255.0")); + /* Clear fdtfile to ensure rescue label's fdtdir tries /dtb/.dtb */ + ut_assertok(env_set("fdtfile", NULL)); + /* Override to boot the rescue label which has ipappend=3 */ ut_assertok(env_set("pxe_label_override", "rescue")); ut_assertok(env_set("pxe_timeout", "1")); From patchwork Fri Jan 9 23:11:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1403 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=1768000366; bh=rMiGjwKTgQC7TRS+1yUglZRT+HjJSnWlSgwWt4rNpJc=; 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=BBdXcPrdvzREH7VF6ttM2Qhpggf0BOXOoFBn5DGpvqABAqxgK1hAW3gt0D0WUfVJn 0WBChlWMxV2FV0UHxikox/iAKuFNAZPQ9l77JCk3HB8OqAVioi8kfOe6eKaOFWsfsl BbLUT+hA5YLtYN23TCRX9OzqjGyPITMq/4VhbU+CQ+s2c0cS8BhUudj9nHeCQ2rhFj 38XykxG91w0F9nm6UGFORnVaIHJjDHQyLMVUeVIG5ER+yY3o9Kt1ZStC7dtW4b3Rpc 1sxvXk5XeJ/d558DBRLBAx0Makq7HYtggLFqm7CcfTi1Tmx8Q6UpuLU0g7CGXnbkoM jIgpwGJkgbvPg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3D4B169245 for ; Fri, 9 Jan 2026 16:12: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 6FiTy6L2DToe for ; Fri, 9 Jan 2026 16:12:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000366; bh=rMiGjwKTgQC7TRS+1yUglZRT+HjJSnWlSgwWt4rNpJc=; 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=BBdXcPrdvzREH7VF6ttM2Qhpggf0BOXOoFBn5DGpvqABAqxgK1hAW3gt0D0WUfVJn 0WBChlWMxV2FV0UHxikox/iAKuFNAZPQ9l77JCk3HB8OqAVioi8kfOe6eKaOFWsfsl BbLUT+hA5YLtYN23TCRX9OzqjGyPITMq/4VhbU+CQ+s2c0cS8BhUudj9nHeCQ2rhFj 38XykxG91w0F9nm6UGFORnVaIHJjDHQyLMVUeVIG5ER+yY3o9Kt1ZStC7dtW4b3Rpc 1sxvXk5XeJ/d558DBRLBAx0Makq7HYtggLFqm7CcfTi1Tmx8Q6UpuLU0g7CGXnbkoM jIgpwGJkgbvPg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0FD3369243 for ; Fri, 9 Jan 2026 16:12:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000363; bh=njGja6c0dK+JxbrKdbNDnRI6r31EbpiI197A8hKJl2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TJUASqU4uJWtnlvg6dPVT7dehMQti1omzxWNLrfvKHKRnLbkeoHtU+gXvFgKM+0Ne 6NvMIDQ+3t75jB92PJG/vvdUxP2VXR82SCiskoUTtb2mztFWkmJ3aaxKDkUSVyi0sR Ec8rP4c9j65zmnXySRaPzBmPBLjrCrb0Qgryk7tzL08TeDMuejs/Kbv6+CUFQvxpUn R5Fiit0mqnW4VysafDE6R6fa+N1vWTV0cEc0T3SpP/cGTo80mqLtwGqZevSSDpHT92 tvaIhlbUiRXJKayKmAKnVdc1xAAdTJzp4pW6gnUMfigVunMeNUq2OiWKEbF9a69mhx gKK97ZEze5nNw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E81FB6923A; Fri, 9 Jan 2026 16:12: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 10026) with ESMTP id 9_YJbnnxu_FB; Fri, 9 Jan 2026 16:12:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000363; bh=+Gdb+0x0QCLhAeClOH9kDoupXUm32L+3Hu/nk83azIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLHBbY9DmYDOXRH9WPult8lEUEEb5etr5MsHHrDykSjaRNUx5Lr4S9KrMjGm13EZl YCmXlzJkIVSI3YBOx9ezfuubTi976GFVHGVDDN9fkqbLxJ7SIXwBj0Abjc/bOtZqMT SZxsmhI+SWgYNOZBq49MvlmQfscH9eOnBU/poL4OiFsGtbTbdBW5eLpNDSIQnUbd5y 3IR+Uvl0mjK4QNLddABq0YwJJH0Qp8PeJ5+vwANnbb4A2FJ7+GyrB9vlY3weM32ME5 SXFa1Wv/rAd1hOxydrWW7LhQnes3xRqafGOaPLuwnRJ2MVAGQ0NiDznaozBGF5sTss B+Ai/DiTg6ytQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 399BE69206; Fri, 9 Jan 2026 16:12:43 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:16 -0700 Message-ID: <20260109231151.4056804-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EJKI7JNI3I6BFOWTDTGAO4A37J6YBMKV X-Message-ID-Hash: EJKI7JNI3I6BFOWTDTGAO4A37J6YBMKV 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/32] test: pxe: Add a test for missing fdtoverlay_addr_r 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 test that verifies the behaviour when a label has fdtoverlays defined in the extlinux.conf but fdtoverlay_addr_r is not set in the environment. The expected behaviour is that the overlay loading is skipped with a warning message ("Invalid fdtoverlay_addr_r for loading overlays") but the FDT is still loaded successfully, allowing the boot to proceed without overlays. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 87 ++++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 7 +++ 2 files changed, 94 insertions(+) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 2ee2ad24a7d..46b26496fbd 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -609,6 +609,93 @@ PXE_TEST_ARGS(pxe_test_errors_norun, UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }, { "cfg_path", UT_ARG_STR }); +/** + * Test overlay loading when fdtoverlay_addr_r is not set + * + * This tests that when a label has fdtoverlays but fdtoverlay_addr_r is not + * set, the overlay loading is skipped with an appropriate warning message, + * but the FDT is still loaded successfully. + */ +static int pxe_test_overlay_no_addr_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_test_info info; + struct pxe_context ctx; + struct pxe_label *label; + struct pxe_menu *cfg; + ulong addr = PXE_LOAD_ADDR; + void *fdt; + uint i; + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + info.uts = uts; + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Set up the PXE context */ + ut_assertok(pxe_setup_ctx(&ctx, pxe_test_getfile, &info, true, cfg_path, + false, false, NULL)); + + /* Read and parse the config file */ + ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); + + cfg = parse_pxefile(&ctx, addr); + ut_assertnonnull(cfg); + + /* Consume parsing output */ + ut_assert_nextline("Retrieving file: %s", cfg_path); + ut_assert_nextline("Booting default Linux kernel"); + ut_assert_nextline("Retrieving file: /extlinux/extra.conf"); + for (i = 3; i <= 16; i++) + ut_assert_nextline("Retrieving file: /extlinux/nest%d.conf", i); + ut_assert_console_end(); + + /* + * Set up environment for loading, but do NOT set fdtoverlay_addr_r. + * This should cause overlay loading to be skipped with a warning. + */ + ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); + ut_assertok(env_set_hex("ramdisk_addr_r", PXE_INITRD_ADDR)); + ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + ut_assertok(env_set("fdtoverlay_addr_r", NULL)); /* Clear it */ + + /* 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_assertnonnull(label->fdtoverlays); + + /* Load the label - should succeed but skip overlays */ + ut_assertok(pxe_load_label(&ctx, label)); + + /* FDT should be loaded */ + ut_asserteq(PXE_FDT_ADDR, ctx.conf_fdt); + fdt = map_sysmem(PXE_FDT_ADDR, 0); + ut_assertok(fdt_check_header(fdt)); + + /* + * Check console output - FDT loaded, but overlays skipped with + * warning about missing fdtoverlay_addr_r + */ + ut_assert_nextline("Retrieving file: /vmlinuz"); + ut_assert_nextline("Retrieving file: /initrd.img"); + ut_assert_nextline("Retrieving file: /dtb/board.dtb"); + ut_assert_nextline("Invalid fdtoverlay_addr_r for loading overlays"); + ut_assert_console_end(); + + /* Clean up */ + destroy_pxe_menu(cfg); + pxe_destroy_ctx(&ctx); + + return 0; +} +PXE_TEST_ARGS(pxe_test_overlay_no_addr_norun, UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }, + { "cfg_path", UT_ARG_STR }); + /** * Test pxe_get_file_size() function * diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index 61ff6d11e3e..b728fb86946 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -460,3 +460,10 @@ class TestPxeParser: with ubman.log.section('Test PXE alloc'): ubman.run_ut('pxe', 'pxe_test_alloc', fs_image=fs_img, cfg_path=cfg_path) + + def test_pxe_overlay_no_addr(self, ubman, pxe_image): + """Test overlay loading when fdtoverlay_addr_r is not set""" + fs_img, cfg_path = pxe_image + with ubman.log.section('Test PXE overlay no addr'): + ubman.run_ut('pxe', 'pxe_test_overlay_no_addr', + fs_image=fs_img, cfg_path=cfg_path) From patchwork Fri Jan 9 23:11:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1404 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=1768000371; bh=Z9gIqsSNFxbutY5PcC3gRvzn+V4Ob4Zzxm/XW0WBwEY=; 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=YVv/rJunbSak37D1RI+Sb4IhYWg769V7QB6EaeCSzKvYLWtcm66DuWXodBkla0pMC M8CmiA0K0MiiJF3XYd1cMbJt361hxkVL2YVX6yVt5aI958rZcyvmNikQlzxVNFUc0d 9kQ4XHwiCaak+MmuCcfJljqCdczktAX+PjNIR4tmGj/AM239w4ljQjJnF+iTrCQVxf niJtzY6ZV3vQcWnJXUR8VVQYFicT/PB/yZgOyqbehSXVFTIas7MB7snw0uCS5LEMaU gl85mYs8IwZ1Z7w7uINQoUchrBw+5dHg7S+w9oyAO9AHnNprw5YZzorpmvZYjaC9ru nsXrf6+FgAYIA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AF2456923D for ; Fri, 9 Jan 2026 16:12: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 d-WDRy5L0hnZ for ; Fri, 9 Jan 2026 16:12:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000371; bh=Z9gIqsSNFxbutY5PcC3gRvzn+V4Ob4Zzxm/XW0WBwEY=; 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=YVv/rJunbSak37D1RI+Sb4IhYWg769V7QB6EaeCSzKvYLWtcm66DuWXodBkla0pMC M8CmiA0K0MiiJF3XYd1cMbJt361hxkVL2YVX6yVt5aI958rZcyvmNikQlzxVNFUc0d 9kQ4XHwiCaak+MmuCcfJljqCdczktAX+PjNIR4tmGj/AM239w4ljQjJnF+iTrCQVxf niJtzY6ZV3vQcWnJXUR8VVQYFicT/PB/yZgOyqbehSXVFTIas7MB7snw0uCS5LEMaU gl85mYs8IwZ1Z7w7uINQoUchrBw+5dHg7S+w9oyAO9AHnNprw5YZzorpmvZYjaC9ru nsXrf6+FgAYIA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9E19569235 for ; Fri, 9 Jan 2026 16:12:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000368; bh=GC/NxxvA1bSlE/KfbHHn1eoIqS+AfLECIXXrzX7XP48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u37qijx6TCU49045h7LPI1pH7t2Fv3JKfBszN1NcSSKORQa6ynuDI5ljLpMla+iRQ dMmBzbxE2C3BP4iLKHSy9unpYaPdDr55Z9YGZDbcT3EXKu1MpnIR6qUAU79xLDFU2T +vBX/1YUweXh4QTUfQeBDwrEG1sYAwYSOtvVI61ulRW0u8oblFaKtQOQbeV7tkH8xj ZpMNzrGLAkXZymQLdZOyOnV/tF3qV/cy90ijIPk0TTjTgN7NR4qA+nmt/18lWZTC8B MCdaBXWQI45dN9ubLdP5gXiaayjcLx8B3hg3sI7Clf74mRrxrfIFI5sSFZ3YEsAnnp So2h2BTGwk3tA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BDD3569218; Fri, 9 Jan 2026 16:12: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 ZIhHm769xkuB; Fri, 9 Jan 2026 16:12:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000364; bh=5N3sC/p6BDPZqnq0u9HIdwO2X1oo+23N46X0OUvhxE8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FRNLWwOa75IJdUq5yCManMsmvPkDX8IY65Ye4OTDdS+4pD8qZpw2xnrdI2D4apocB vsHRCA8yL5Ho5pMbrlrL2yYDRG95kMq8z4LLnahEoYvTksJD0qWfqE0x2w2S9xqyl+ 9A7mpfIuP35llTcZCvsUGpzibn6DT26NVxDPrBjCMCUnLjCKbKX4esIZwKaboI/Xzn zDOKpq7Rs6D3zUeEwenJld8jJEkAQjTL/ms0tRg5aLADBuVKU/wbcgkZP5VQDd8tXM 0ixNC3JxyQKfqURa1uDyhxfPcAPgITjr/98pT0ChU9uffxxvTGQPaKGUm1KFzMTDH7 3Z7OgV8RoqLZg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3ACAF69206; Fri, 9 Jan 2026 16:12:44 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:17 -0700 Message-ID: <20260109231151.4056804-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3D7565VQ2ZYHZVFABPPLDFJR7VD3XJRM X-Message-ID-Hash: 3D7565VQ2ZYHZVFABPPLDFJR7VD3XJRM 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/32] test: pxe: Add test for FIT images with embedded FDT 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 test that verifies the handling of FIT images containing an embedded FDT when the extlinux.conf uses the 'fit' keyword without an explicit 'fdt' line. The test creates a FIT image with an embedded DTB using mkimage, then loads a label that references it via 'fit /boot/image.fit'. It verifies that ctx.conf_fdt_str is NULL (the current behaviour for this case). Note: Ideally conf_fdt_str should be set to the FIT address so bootm can extract the FDT, but that is a pre-existing limitation. This test detects regressions where conf_fdt_str is incorrectly set to fdt_addr_r instead of NULL. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/pxe.c | 91 ++++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 69 ++++++++++++++++++++++++ 2 files changed, 160 insertions(+) diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 46b26496fbd..4c87aafce55 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -1166,3 +1166,94 @@ static int pxe_test_alloc_norun(struct unit_test_state *uts) PXE_TEST_ARGS(pxe_test_alloc_norun, UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }, { "cfg_path", UT_ARG_STR }); + +/** + * Test FIT image with embedded FDT (no explicit fdt line) + * + * This tests that when using 'fit /path.fit' without an explicit 'fdt' + * line (label->fdt is NULL), the FDT address is set to the FIT address + * so bootm can extract the FDT from the FIT image. + * + * The buggy behavior: When label->fdt is NULL, the FIT check fails: + * if (label->fdt && label->kernel_label && + * !strcmp(label->kernel_label, label->fdt)) + * and conf_fdt_str is not set to the FIT address. + * + * The correct behavior: When the kernel is a FIT image with embedded FDT + * and no explicit fdt line is provided, conf_fdt_str should be set to + * the kernel (FIT) address so bootm can extract the FDT. + */ +static int pxe_test_fit_embedded_fdt_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_test_info info; + struct pxe_context ctx; + struct pxe_label *label; + struct pxe_menu *cfg; + ulong addr = PXE_LOAD_ADDR; + + ut_assertnonnull(fs_image); + ut_assertnonnull(cfg_path); + + info.uts = uts; + + /* Bind the filesystem image */ + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + + /* Set up the PXE context */ + ut_assertok(pxe_setup_ctx(&ctx, pxe_test_getfile, &info, true, cfg_path, + false, false, NULL)); + + /* Set up environment for loading */ + ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); + ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + + /* Read and parse the config file */ + ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); + + cfg = parse_pxefile(&ctx, addr); + ut_assertnonnull(cfg); + + /* Consume parsing output */ + ut_assert_nextline("Retrieving file: %s", cfg_path); + ut_assert_console_end(); + + /* Get the fitonly label which uses 'fit' without 'fdt' */ + label = list_first_entry(&cfg->labels, struct pxe_label, list); + ut_asserteq_str("fitonly", label->name); + + /* Verify this is a FIT label with no explicit fdt */ + ut_assertnonnull(label->kernel); /* /boot/image.fit */ + ut_assertnull(label->config); /* NULL when no #config suffix */ + ut_assertnull(label->fdt); /* No explicit fdt line - this is key */ + + /* Load the label */ + ut_assertok(pxe_load_label(&ctx, label)); + + /* Consume load output */ + ut_assert_nextline("Retrieving file: /boot/image.fit"); + ut_assert_console_end(); + + /* + * For FIT images with embedded FDT and no explicit fdt line, + * conf_fdt_str is currently NULL. Ideally it should be set to the + * kernel address so bootm can extract the FDT from the FIT, but + * that is a pre-existing limitation. + * + * This test detects regressions where conf_fdt_str is incorrectly + * set to fdt_addr_r instead of NULL (which would cause bootm to + * look at the wrong address for the FDT). + */ + ut_assertnull(ctx.conf_fdt_str); + ut_asserteq(0, ctx.conf_fdt); + + /* Clean up */ + destroy_pxe_menu(cfg); + pxe_destroy_ctx(&ctx); + + return 0; +} +PXE_TEST_ARGS(pxe_test_fit_embedded_fdt_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 b728fb86946..af97568e960 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -11,11 +11,14 @@ Tests are implemented in C (test/boot/pxe.c) and called from here. Python handles filesystem image setup and configuration. """ +import gzip import os import pytest import subprocess +import tempfile from fs_helper import FsHelper +import utils # Simple base DTS with symbols enabled (for overlay support) @@ -400,6 +403,60 @@ def pxe_error_image(u_boot_config): fsh.cleanup() +@pytest.fixture +def pxe_fit_image(u_boot_config, u_boot_log): + """Create a filesystem image with a FIT image containing embedded FDT + + This tests that when using the 'fit' keyword without an explicit 'fdt' + line, the FDT is extracted from the FIT image. This is the scenario where + label->fdt is NULL but the kernel is a FIT containing an embedded FDT. + """ + fsh = FsHelper(u_boot_config, 'vfat', 4, prefix='pxe_fit') + fsh.setup() + + # Create a FIT image with embedded FDT using mkimage + mkimage = u_boot_config.build_dir + '/tools/mkimage' + boot_dir = os.path.join(fsh.srcdir, 'boot') + os.makedirs(boot_dir, exist_ok=True) + + with tempfile.TemporaryDirectory(suffix='pxe_fit') as tmp: + # Create a fake gzipped kernel + kern = os.path.join(tmp, 'kern') + with open(kern, 'wb') as fd: + fd.write(gzip.compress(b'vmlinux-test')) + + # Create a DTB for the FIT + dtb = os.path.join(tmp, 'board.dtb') + compile_dts(BASE_DTS, dtb) + + # Create FIT image with embedded DTB + fit = os.path.join(boot_dir, 'image.fit') + subprocess.run( + f'{mkimage} -f auto -T kernel -A sandbox -O linux ' + f'-d {kern} -b {dtb} {fit}', + shell=True, check=True, capture_output=True) + + # Create extlinux.conf using 'fit' keyword without 'fdt' line + # This is the key test case: label->fdt is NULL, but FIT has embedded FDT + labels = [ + { + 'name': 'fitonly', + 'menu': 'FIT Boot (no explicit fdt)', + 'fit': '/boot/image.fit', + 'append': 'console=ttyS0', + 'default': True, + }, + ] + + cfg_path = create_extlinux_conf(fsh.srcdir, labels) + fsh.mk_fs() + + yield fsh.fs_img, cfg_path + + if not u_boot_config.persist: + fsh.cleanup() + + @pytest.mark.boardspec('sandbox') @pytest.mark.requiredtool('dtc') class TestPxeParser: @@ -467,3 +524,15 @@ class TestPxeParser: with ubman.log.section('Test PXE overlay no addr'): ubman.run_ut('pxe', 'pxe_test_overlay_no_addr', fs_image=fs_img, cfg_path=cfg_path) + + def test_pxe_fit_embedded_fdt(self, ubman, pxe_fit_image): + """Test FIT image with embedded FDT (no explicit fdt line) + + This tests that when using 'fit /path.fit' without an explicit 'fdt' + line, the FDT address is set to the FIT address so bootm can extract + the FDT from the FIT image. + """ + fs_img, cfg_path = pxe_fit_image + 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) From patchwork Fri Jan 9 23:11:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1405 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=1768000375; bh=6PR08LlmlY2sqarDXeV2OzhJ7h4jo8uCo+X8YMy07JI=; 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=V9Ndfacq6vPGIsYO5DuwETDbNk0Y3iBxBM6LEZmn6GEUmSA+qUCui2TSmDoTbMXCH GjVdLkJpxgxRFqL2O/q1A4MKVucMwEsrcDsZF38JjYNwqxGpFxdt9+gVDFj4gFNKAc iI+uibN8Af9lPasqeaf8YVpyFCtVultsrmug7zOpL2I2jxU5oI/HQTWSwGWY+R5ywC DY8z6yV/hy5VXWuJj+LYx0P6LhLMwE0d6CLcR16NLTm4nrnt9Srq9h3UUyrVTMvmgD OeapoYcavw2XjywvZypewRryO43GuL/kGHLqQWSBfm8WOu7jqvmSXoLRcSi0AwmtOd O4l1ZLb24yS1g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 59ECF6923D for ; Fri, 9 Jan 2026 16:12: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 10024) with ESMTP id HKeROvrwQ0zr for ; Fri, 9 Jan 2026 16:12:55 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000375; bh=6PR08LlmlY2sqarDXeV2OzhJ7h4jo8uCo+X8YMy07JI=; 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=V9Ndfacq6vPGIsYO5DuwETDbNk0Y3iBxBM6LEZmn6GEUmSA+qUCui2TSmDoTbMXCH GjVdLkJpxgxRFqL2O/q1A4MKVucMwEsrcDsZF38JjYNwqxGpFxdt9+gVDFj4gFNKAc iI+uibN8Af9lPasqeaf8YVpyFCtVultsrmug7zOpL2I2jxU5oI/HQTWSwGWY+R5ywC DY8z6yV/hy5VXWuJj+LYx0P6LhLMwE0d6CLcR16NLTm4nrnt9Srq9h3UUyrVTMvmgD OeapoYcavw2XjywvZypewRryO43GuL/kGHLqQWSBfm8WOu7jqvmSXoLRcSi0AwmtOd O4l1ZLb24yS1g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4846269235 for ; Fri, 9 Jan 2026 16:12:55 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000373; bh=hHmSAal+3AATpP8G4SyJLMQdvQoXebHL6Xgk2UIH2lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fUQgAYIab1369BAuCJzZ6KIJ4SR0Vw+dASaO9oy4fhh9zSuRD1kKk12n24mWcxo3f xdarJo7FCNs4x2slTojSzX/N7TBzviehRymGzxVg/YGg4MHzZ2W5Q8UQmZW+gL4wID 0O+aTAJRwyCSBi0IEYvSXrnVMh5Bpgw4wB25XKQWUaDUY0ALHOw+TfxVArkNcztcbC 2UYuZpsFObg1eTy5KlCQBvilt3Vwfv3AwRAsGGTSou+F+zGRCh4sMz8Pp2uvSRH/P9 WqeFooAXqcB8373iXuxN1WAu7I+5NICeMKzCPwGRvZiEMjyldIK5jjCM2r42L26UtJ vdc8RqQNuGAYA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 700DA69218; Fri, 9 Jan 2026 16:12: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 tiN8ojp-B_5n; Fri, 9 Jan 2026 16:12:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000369; bh=65Ejht9/oLmxy/Hw6N/XPK8NSglqhxfQ1npxONwzmxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s5QCWRNofw6pqjrMBlAoWJXuqsL/Yzcuvc6jkatRcGvXpwPSlEKjVLvrsfzJ6dNqR Eyn7vA0sHwILeZvmJzjUPxhVJHaNmFuhETHzwxfXt4q/AtYG6xwIl0lZQSmNCxIofN zQB23WUG2kiHfL5jgFWTBP+Pa2vqXLoE/HLPk4gU2CI21dnPqHQ044Yf0xjjNI+AF1 r0CiqrHp958PoZMlmI3bUotWCVQ0dpyW6Lnoi0qF9hdxF8PSNa4/RTdidHKFRg9Hrg iElm0ZpNmkzoZRuItBvS8HXDJNxKp5m03ThhRojmnSnb2BGuqcxSp7nEaLzaZ7Vw93 mKbNzdwQwpfiw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0EC1769206; Fri, 9 Jan 2026 16:12:48 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:18 -0700 Message-ID: <20260109231151.4056804-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AFRIYMCB7KUKO4FS4MFMIPOVPSUEEIFZ X-Message-ID-Hash: AFRIYMCB7KUKO4FS4MFMIPOVPSUEEIFZ 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/32] boot: pxe: Add a flag to suppress file-retrieval messages 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 'quiet' field to struct pxe_context to allow callers to suppress the "Retrieving file" message when loading files. This is useful when using the parser API to inspect labels without booting, where the message would be noise. Normal boot flows leave quiet as false (the default) so the message is still printed. Parse-only callers can set ctx.quiet = true to suppress it. Update the PXE parser test to use quiet mode. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 3 ++- include/pxe_utils.h | 2 ++ test/boot/pxe.c | 12 ++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 384293d9f8a..3c48b0ac51b 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -124,7 +124,8 @@ static int get_relfile(struct pxe_context *ctx, const char *file_path, strcat(relfile, file_path); - printf("Retrieving file: %s\n", relfile); + if (!ctx->quiet) + printf("Retrieving file: %s\n", relfile); ret = ctx->getfile(ctx, relfile, addrp, align, type, &size); if (ret < 0) diff --git a/include/pxe_utils.h b/include/pxe_utils.h index ef664f075a0..f910ea9d284 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -120,6 +120,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * @use_fallback: TRUE : use "fallback" option as default, FALSE : use * "default" option as default * @no_boot: Stop show of actually booting and just return + * @quiet: Suppress "Retrieving file" messages when loading files * @bflow: Bootflow being booted, or NULL if none (must be valid if @no_boot) * @cfg: PXE menu (NULL if not yet probed) * @@ -157,6 +158,7 @@ struct pxe_context { bool use_ipv6; bool use_fallback; bool no_boot; + bool quiet; struct bootflow *bflow; struct pxe_menu *cfg; diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 4c87aafce55..af45c1fbffd 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -160,7 +160,8 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertok(pxe_setup_ctx(&ctx, pxe_test_getfile, &info, true, cfg_path, false, false, NULL)); - /* Read the config file into memory */ + /* Read the config file into memory (quiet since we're just parsing) */ + ctx.quiet = true; ret = get_pxe_file(&ctx, cfg_path, addr); ut_asserteq(1, ret); /* get_pxe_file returns 1 on success */ @@ -168,12 +169,11 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) cfg = parse_pxefile(&ctx, addr); ut_assertnonnull(cfg); - /* Verify 'say' keyword printed its message during parsing */ - ut_assert_nextline("Retrieving file: %s", cfg_path); + /* + * Verify 'say' keyword printed its message during parsing (quiet + * suppresses file messages) + */ ut_assert_nextline("Booting default Linux kernel"); - ut_assert_nextline("Retrieving file: /extlinux/extra.conf"); - for (i = 3; i <= 16; i++) - ut_assert_nextline("Retrieving file: /extlinux/nest%d.conf", i); ut_assert_console_end(); /* Verify menu properties */ From patchwork Fri Jan 9 23:11:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1406 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=1768000380; bh=Mse4eJxpWdMm/wJx+RPE/aPr86XrmamgOhwta6Vtb7U=; 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=CSAiEUmcGClr1T5vKeS1ib6ttAziekZ8S1e9A9DCiRoCmr2ml1XdqSMNsNwyDuRBn 92g5uDnBV+akKFEA5fg4NmjLt6z/MZWfPWXMGzWm1JYqjv9/t4mBzc+BcUorQp4ONJ UGfvADv3HTFe8bYy/ASJQQWs3UpB7Lrv8QjbnLIpi/xki1lGmBmn2Bu10ruPz4LqjL 11ydrTpzKCArhpbQAREWzGwY6cqcCIY0tW3GIxVKiPeN4Dw0udsmEL4fytVolgPKgF yJoCnToFSV+B3+ElAf8kgUgulFt9N2838WP1pv7yECCp2k40eVIsw5gogns6BGCTb/ LJXJx3J05Xu8g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CDDAF6923D for ; Fri, 9 Jan 2026 16:13: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 10024) with ESMTP id oFYuUhN6PEuK for ; Fri, 9 Jan 2026 16:13:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000380; bh=Mse4eJxpWdMm/wJx+RPE/aPr86XrmamgOhwta6Vtb7U=; 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=CSAiEUmcGClr1T5vKeS1ib6ttAziekZ8S1e9A9DCiRoCmr2ml1XdqSMNsNwyDuRBn 92g5uDnBV+akKFEA5fg4NmjLt6z/MZWfPWXMGzWm1JYqjv9/t4mBzc+BcUorQp4ONJ UGfvADv3HTFe8bYy/ASJQQWs3UpB7Lrv8QjbnLIpi/xki1lGmBmn2Bu10ruPz4LqjL 11ydrTpzKCArhpbQAREWzGwY6cqcCIY0tW3GIxVKiPeN4Dw0udsmEL4fytVolgPKgF yJoCnToFSV+B3+ElAf8kgUgulFt9N2838WP1pv7yECCp2k40eVIsw5gogns6BGCTb/ LJXJx3J05Xu8g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BA3D869235 for ; Fri, 9 Jan 2026 16:13:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000378; bh=NeaRPrOTl9z22FPDyQnFdey6blLRwLhYszMVRgF/kT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VlhMINVzIiLzqW69WWPA1ozi8v0A4GmVnpNKTV8K4Cbd3nZh79kd99GS/mPGKrdY5 i/TBjUpz3iphdrDDTi7uHcxf1GLHCa6CFYU4xSseyR8OVHGNcPr96L2rqxxIa3wsfE oG24bWJCZk5cxSQ91OTSLRp2rOT/8IGpS/5yhSIyo3iU4AwQ4Ik2btGuD5VgysfuSW NzhAYqGhNGBI1s+hWYirWrM0jVOtbcLlMY8mq8w7VIJEHD64cefIx5JIxn7+JZZp0w 7TKq7+Jo2dRlo7WwqalP8h2dF9ZXG5kEk76AtPWppuUXqrt0E9eawJgcfR8+ym/U4E zG1nA/0KajCWA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A16B69218; Fri, 9 Jan 2026 16:12: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 mJr0X0vrDLot; Fri, 9 Jan 2026 16:12:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000374; bh=aiS5JcCoDINUgSVuE/TsivYk4HeksShKEBCatwvp5Cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qlm0uOvP+69M3F3lXNrfbTWqWic1AxquBwM1ssqu6Xg1IFxt4GsgJgX+5LXaAECGe BOD28E5QjGnBtrlRSeAxjbEpnKd1WkXT/q9xthL+NrTMEOXbdtjpYl8yWKyYwo8ztX H98UDIP4kJi56mjhiI2vy4P7364a739srsweAUIw2lfO525R2L4P93tvRhviiS9JTi 8SNBKji0HJ6Bg/+sZSE73gS427U1ec6wcAQVGuRyRe0BldsSi5cyIbiE3ylQY3DiXz e89ny2rsGLVcIHnD8eYkAHfO22j9AeEUAVZPlJK5fm5CvQyik+Z2q/nUI5lFUp5LTU K6EIaS3nte8gA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AE34D69206; Fri, 9 Jan 2026 16:12:53 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:19 -0700 Message-ID: <20260109231151.4056804-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VNHIS3PMCNVHJD45J5C767PSTLPTMXT5 X-Message-ID-Hash: VNHIS3PMCNVHJD45J5C767PSTLPTMXT5 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/32] boot: pxe: Print 'say' message when label is booted 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 Per the syslinux specification, the 'say' directive should print its message when the label is selected for booting, not during parsing. Store the 'say' message in struct pxe_label so it can be printed at the appropriate time. Print the message in label_boot() before displaying the label information. Update the test to verify the say field instead of expecting console output during parsing. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 6 ++++-- boot/pxe_utils.c | 5 +++-- include/pxe_utils.h | 2 ++ test/boot/pxe.c | 42 +++++++++++++++++++----------------------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 633b218a7cd..e3412166a63 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -121,6 +121,7 @@ void label_destroy(struct pxe_label *label) free(label->fdt); free(label->fdtdir); free(label->fdtoverlays); + free(label->say); free(label); } @@ -553,8 +554,9 @@ static int parse_label(char **c, struct pxe_menu *cfg) char *p = strchr(s, '\n'); if (p) { - printf("%.*s\n", (int)(p - *c) - 1, *c + 1); - + label->say = strndup(*c + 1, p - *c - 1); + if (!label->say) + return -ENOMEM; *c = p; } break; diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 3c48b0ac51b..1516065a467 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -812,6 +812,9 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) char ip_str[68] = ""; int ret; + if (label->say) + printf("%s\n", label->say); + label_print(label); label->attempted = 1; @@ -897,8 +900,6 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) return 1; } -/* - */ void destroy_pxe_menu(struct pxe_menu *cfg) { struct list_head *pos, *n; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index f910ea9d284..c0d2167cc25 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -39,6 +39,7 @@ * @fdt: path to FDT to use * @fdtdir: path to FDT directory to use * @fdtoverlays: space-separated list of paths of FDT overlays to apply + * @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 * @localboot: 1 if this label specified 'localboot', 0 otherwise @@ -58,6 +59,7 @@ struct pxe_label { char *fdt; char *fdtdir; char *fdtoverlays; + char *say; int ipappend; int attempted; int localboot; diff --git a/test/boot/pxe.c b/test/boot/pxe.c index af45c1fbffd..4ac0d6c6fa6 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -81,25 +81,20 @@ static int pxe_test_getfile(struct pxe_context *ctx, const char *file_path, * * This helper checks all the console output lines from loading and displaying * the PXE menu, including config file retrieval, include files, background - * image attempt, and the menu itself. + * image attempt, and the menu itself. Note: 'say' messages are now printed + * when the label is booted, not during parsing. * * @uts: Unit test state - * @say_msg: Expected 'say' message (shown before menu), or NULL if none * @error_msg: Expected error message after background image, or NULL if none * Return: 0 if OK, -ve on error */ -static int pxe_check_menu(struct unit_test_state *uts, const char *say_msg, - const char *error_msg) +static int pxe_check_menu(struct unit_test_state *uts, const char *error_msg) { int i; /* Config file retrieval */ ut_assert_nextline("Retrieving file: /extlinux/extlinux.conf"); - /* Say message appears before includes are processed */ - if (say_msg) - ut_assert_nextline(say_msg); - /* Include file retrievals */ ut_assert_nextline("Retrieving file: /extlinux/extra.conf"); for (i = 3; i <= 16; i++) @@ -169,11 +164,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) cfg = parse_pxefile(&ctx, addr); ut_assertnonnull(cfg); - /* - * Verify 'say' keyword printed its message during parsing (quiet - * suppresses file messages) - */ - ut_assert_nextline("Booting default Linux kernel"); + /* Verify no console output during parsing (say is printed on boot) */ ut_assert_console_end(); /* Verify menu properties */ @@ -198,6 +189,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->fdtdir); ut_asserteq_str("/dtb/overlay1.dtbo /dtb/overlay2.dtbo", label->fdtoverlays); + ut_asserteq_str("Booting default Linux kernel", label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); ut_asserteq(0, label->localboot); @@ -217,6 +209,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->fdt); ut_asserteq_str("/dtb/", label->fdtdir); ut_assertnull(label->fdtoverlays); + ut_assertnull(label->say); ut_asserteq(3, label->ipappend); ut_asserteq(0, label->attempted); ut_asserteq(0, label->localboot); @@ -236,6 +229,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); ut_assertnull(label->fdtoverlays); + ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); ut_asserteq(1, label->localboot); @@ -255,6 +249,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); ut_assertnull(label->fdtoverlays); + ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); ut_asserteq(0, label->localboot); @@ -337,9 +332,9 @@ static int pxe_test_sysboot_norun(struct unit_test_state *uts) ut_assertok(run_commandf("sysboot host 0:0 any %x %s", PXE_LOAD_ADDR, cfg_path)); - /* Check menu output */ - ut_assertok(pxe_check_menu(uts, "Booting default Linux kernel", NULL)); - ut_assert_nextline("Enter choice: 1:\tBoot Linux"); + /* Skip menu output and find the first label boot attempt */ + ut_assert_skip_to_line("Enter choice: Booting default Linux kernel"); + ut_assert_nextline("1:\tBoot Linux"); /* Verify files were loaded in order */ ut_assert_nextline("Retrieving file: /vmlinuz"); @@ -646,9 +641,8 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) cfg = parse_pxefile(&ctx, addr); ut_assertnonnull(cfg); - /* Consume parsing output */ + /* Consume parsing output (say message is printed on boot, not parsing) */ ut_assert_nextline("Retrieving file: %s", cfg_path); - ut_assert_nextline("Booting default Linux kernel"); ut_assert_nextline("Retrieving file: /extlinux/extra.conf"); for (i = 3; i <= 16; i++) ut_assert_nextline("Retrieving file: /extlinux/nest%d.conf", i); @@ -842,7 +836,7 @@ static int pxe_test_ipappend_norun(struct unit_test_state *uts) PXE_LOAD_ADDR, cfg_path)); /* Check menu output */ - ut_assertok(pxe_check_menu(uts, "Booting default Linux kernel", NULL)); + ut_assertok(pxe_check_menu(uts, NULL)); ut_assert_nextline("Enter choice: 2:\tRescue Mode"); /* Rescue label boot attempt */ @@ -962,7 +956,7 @@ static int pxe_test_label_override_norun(struct unit_test_state *uts) PXE_LOAD_ADDR, cfg_path)); /* Check menu output - say message is from default label */ - ut_assertok(pxe_check_menu(uts, "Booting default Linux kernel", NULL)); + ut_assertok(pxe_check_menu(uts, NULL)); /* Should boot 'local' label instead of default 'linux' */ ut_assert_nextline("Enter choice: 3:\tLocal Boot"); @@ -982,9 +976,11 @@ static int pxe_test_label_override_norun(struct unit_test_state *uts) PXE_LOAD_ADDR, cfg_path)); /* Check menu with error message before it */ - ut_assertok(pxe_check_menu(uts, "Booting default Linux kernel", - "Missing override pxe label: nonexistent")); - ut_assert_nextline("Enter choice: 1:\tBoot Linux"); + ut_assertok(pxe_check_menu(uts, "Missing override pxe label: nonexistent")); + + /* Say message is printed when label is selected (after "Enter choice:") */ + ut_assert_nextline("Enter choice: Booting default Linux kernel"); + ut_assert_nextline("1:\tBoot Linux"); /* Default label boot attempt - FDT/overlays loaded before append */ ut_assert_nextline("Retrieving file: /vmlinuz"); From patchwork Fri Jan 9 23:11:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1407 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=1768000385; bh=R5OrEtSpdapwRQaAu2NIMb++y//LNCWTqwteraININI=; 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=OUZHv7caA3WpRUAoNoqgFdoykzzOCJbmTUlioqawYcOwvU3i0L5gCBvTLzFz+XtlH 0/+yFojYBnPHs8TsmGp6uIMBo0zzjpNYTK1/XakXtXnNrpfpwicW6kL/4zvqO1QaVo DTr71WSt+6/kMyMKXJ/Mw1ZGvBWTBq/ekwJYn67P+XWUsc3RRCby/iIlW2OdRk6ekI QwctKSoy9EmSiiUMkBLNA82rxOAV62gSSoow6qjjVZKlVKIY3KfJpwVwd/UvZmrYp3 wq3Gpiler5FgOUrVz71wf4ijPp+B6V/+0W37824CGrHp65OjkOfhz3ARbGRlbzotBu i42XwgaWUuXBA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 536C569240 for ; Fri, 9 Jan 2026 16:13: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 bj1n9JViG7in for ; Fri, 9 Jan 2026 16:13:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000385; bh=R5OrEtSpdapwRQaAu2NIMb++y//LNCWTqwteraININI=; 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=OUZHv7caA3WpRUAoNoqgFdoykzzOCJbmTUlioqawYcOwvU3i0L5gCBvTLzFz+XtlH 0/+yFojYBnPHs8TsmGp6uIMBo0zzjpNYTK1/XakXtXnNrpfpwicW6kL/4zvqO1QaVo DTr71WSt+6/kMyMKXJ/Mw1ZGvBWTBq/ekwJYn67P+XWUsc3RRCby/iIlW2OdRk6ekI QwctKSoy9EmSiiUMkBLNA82rxOAV62gSSoow6qjjVZKlVKIY3KfJpwVwd/UvZmrYp3 wq3Gpiler5FgOUrVz71wf4ijPp+B6V/+0W37824CGrHp65OjkOfhz3ARbGRlbzotBu i42XwgaWUuXBA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 408336923A for ; Fri, 9 Jan 2026 16:13:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000383; bh=L3iqycogUmfLAwltuS4hCFaguhneYEstB13iwThFx48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oJDXo7YuUG+eqVtbP9xe4I1QH9Rr4BrOcU3yeIQxL3DFeC3v6p4QvoL83ZFTP6gKM 97pMtfza3LriOfN2i50d/TCM460U6RMioXc1EmQVHHB5s/TrcYKX4Nb2pD+sVyVqVs ZRiZN+t1G+TGUyn7x7oNgaIgUuSsAUH3FPillMI7J5rFRhh8Zlh0n7aBtxJntS3MW3 Ly8BKsV7Ltb62TmjBx7QO5VDv/VaAnGJ2PWKJn6g7sMd20cZDMtIGy2miwRse0ZGDU Jen4TvUrR9vcO5wYGzzV21v63jBnuQsbLGa3kfVEtBkrSS9OMTAu4fWgK6oX5C8vjE ik3oelpUgDyUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 40AFB6923A; Fri, 9 Jan 2026 16:13: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 Hfsxis16Znjf; Fri, 9 Jan 2026 16:13:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000378; bh=WTtp2rlM0bQZRGTI7EJHZ5Q6aT6VIskmazXkGlVtDGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gylSbMOAkbtQ2Xn+3j1ngSVUQjwW4KAWDtObeu/j8LkUoekSQ8zqUTxYrXk7UPur9 U+w9Ixyy3hOD4j5e4EpwykxRgR6yq3Khq+gG6GfNlZvxmg0VC7OlJ8MSMSP/vLuARl VY+uq/Ooe3grl+M/Bby4L5X4xKfKc6V6wyyrCVHBaKa7K/bqgTEBp6JdHipjh8iPn2 UuRsfRidxSvBLy9Dhj6XbSzqgFPbzRJxI6i7cKQ3aGgor1vmpMmDVscFPx7e6r1Ltr fXPZkU+kszndCseZCYjRlPjMeEVb9ROEuKkim6xHyTAvJcUX1KrEedT/10u4gYPPhN 4NEx8Q6LJ0LLg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5CE3269206; Fri, 9 Jan 2026 16:12:58 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:20 -0700 Message-ID: <20260109231151.4056804-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QV4JS5V3RWZWU3RC6VSHNLH6N6D4OSIU X-Message-ID-Hash: QV4JS5V3RWZWU3RC6VSHNLH6N6D4OSIU 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/32] boot: pxe: Rename destroy_pxe_menu() to 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 Use a consistent naming convention with the pxe_ prefix. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 6 +++--- include/pxe_utils.h | 6 +++--- test/boot/pxe.c | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 1516065a467..a824b1b5623 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -900,7 +900,7 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) return 1; } -void destroy_pxe_menu(struct pxe_menu *cfg) +void pxe_menu_uninit(struct pxe_menu *cfg) { struct list_head *pos, *n; struct pxe_label *label; @@ -946,7 +946,7 @@ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg) unmap_sysmem(buf); if (r < 0) { - destroy_pxe_menu(cfg); + pxe_menu_uninit(cfg); return NULL; } @@ -1192,7 +1192,7 @@ int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) handle_pxe_menu(ctx, cfg); - destroy_pxe_menu(cfg); + pxe_menu_uninit(cfg); return 0; } diff --git a/include/pxe_utils.h b/include/pxe_utils.h index c0d2167cc25..0de2f49aab5 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -179,13 +179,13 @@ struct pxe_context { }; /** - * destroy_pxe_menu() - Destroy an allocated pxe structure + * pxe_menu_uninit() - Destroy an allocated pxe structure * * Free the memory used by a pxe_menu and its labels * * @cfg: Config to destroy, previous returned from parse_pxefile() */ -void destroy_pxe_menu(struct pxe_menu *cfg); +void pxe_menu_uninit(struct pxe_menu *cfg); /** * get_pxe_file() - Read a file @@ -243,7 +243,7 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg); * Returns NULL if there is an error, otherwise, returns a pointer to a * pxe_menu struct populated with the results of parsing the pxe file (and any * files it includes). The resulting pxe_menu struct can be free()'d by using - * the destroy_pxe_menu() function. + * the pxe_menu_uninit() function. */ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, ulong menucfg); diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 4ac0d6c6fa6..8d7c6f7f2ae 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -286,7 +286,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assert_console_end(); /* Clean up */ - destroy_pxe_menu(cfg); + pxe_menu_uninit(cfg); pxe_destroy_ctx(&ctx); return 0; @@ -476,7 +476,7 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) env_set("soc", NULL); env_set("board", NULL); - destroy_pxe_menu(cfg); + pxe_menu_uninit(cfg); pxe_destroy_ctx(&ctx); return 0; @@ -595,7 +595,7 @@ static int pxe_test_errors_norun(struct unit_test_state *uts) /* Clean up */ env_set("fdtfile", NULL); - destroy_pxe_menu(cfg); + pxe_menu_uninit(cfg); pxe_destroy_ctx(&ctx); return 0; @@ -681,7 +681,7 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) ut_assert_console_end(); /* Clean up */ - destroy_pxe_menu(cfg); + pxe_menu_uninit(cfg); pxe_destroy_ctx(&ctx); return 0; @@ -1151,7 +1151,7 @@ static int pxe_test_alloc_norun(struct unit_test_state *uts) ut_asserteq(false, ctx.fake_go); /* Clean up */ - destroy_pxe_menu(ctx.cfg); + pxe_menu_uninit(ctx.cfg); pxe_destroy_ctx(&ctx); ut_assertok(env_set("pxe_timeout", NULL)); ut_assertok(env_set("fdt_addr", orig_fdt_addr)); @@ -1245,7 +1245,7 @@ static int pxe_test_fit_embedded_fdt_norun(struct unit_test_state *uts) ut_asserteq(0, ctx.conf_fdt); /* Clean up */ - destroy_pxe_menu(cfg); + pxe_menu_uninit(cfg); pxe_destroy_ctx(&ctx); return 0; From patchwork Fri Jan 9 23:11:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1408 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=1768000389; bh=kmiKst+/3ENQf/b1yOQVgt1qileuT+9vnb6nzUzjZaM=; 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=YFDoVgTxT5BRFQaVBxkBOCg1mAMH6/osS/jKmYJ2REc57sXnIyczJsE8JvCW2v8eE MazaH10CgLURvuBUu0Rqo2wPt34yQyFHii+2g9O/WhnUtsTD+mDuqhnA+MiFyVhIU8 jDJCAwiIhwML9kRJte2c54LX5dhKK93oi4+AM0W6XOsust4L0i00SJSjPKAz7ITxkN 3pMgPZ7bYI1LDpO1VwJATcaGddDAIN38eiulmt3GCaazbfxQ2pXkTCb8shg3lD9K6D Q4ESyOE6i3RAEK6/dFkElR7azMg2Z2hiwe1i2anvjQ6GdNC2SgW1DAmgu9syVLTDiL 6SVZZKrjrUaIA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4F74169241 for ; Fri, 9 Jan 2026 16:13:09 -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 xYIBfPinrtQu for ; Fri, 9 Jan 2026 16:13:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000389; bh=kmiKst+/3ENQf/b1yOQVgt1qileuT+9vnb6nzUzjZaM=; 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=YFDoVgTxT5BRFQaVBxkBOCg1mAMH6/osS/jKmYJ2REc57sXnIyczJsE8JvCW2v8eE MazaH10CgLURvuBUu0Rqo2wPt34yQyFHii+2g9O/WhnUtsTD+mDuqhnA+MiFyVhIU8 jDJCAwiIhwML9kRJte2c54LX5dhKK93oi4+AM0W6XOsust4L0i00SJSjPKAz7ITxkN 3pMgPZ7bYI1LDpO1VwJATcaGddDAIN38eiulmt3GCaazbfxQ2pXkTCb8shg3lD9K6D Q4ESyOE6i3RAEK6/dFkElR7azMg2Z2hiwe1i2anvjQ6GdNC2SgW1DAmgu9syVLTDiL 6SVZZKrjrUaIA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3D17A69206 for ; Fri, 9 Jan 2026 16:13:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000387; bh=1qOxjJ7DT9XboIxnXTfbwtqbzb1/5Dq/LbI9LGV0324=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbmYmdG/ESlbdbygIYZ+IXnDXD9kn5Z/b6lCqaapQHuKK6YnSbSnpsQ939LvXeotS LubL7X7rSbqwUI76j7Yjr3M5xuBRUuKoCNUehhkq0ah0SAO0byBRu5mFNzBCBmdZKg iRhpJk52VLaFRNLomWI8rLmTMmvEoOQvuqAl01JsOeUptQjTMUWarULLw1jde7G4tU e3h7+y3G7kaQytCSFcHyTxJ+CkJcACsCUoBr4mSE/oBVMomNvYRaq6Uqz91dsICGJx xQD55XNlmuEiH7wsfIKwlc9lnHO7YSG9XN5+alopAXEphLLD9cPhOEsXeeS8mSq8MP AvYcojII4I4iQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 69ED169206; Fri, 9 Jan 2026 16:13:07 -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 70VJFrTtwCxy; Fri, 9 Jan 2026 16:13:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000383; bh=f+O9/qvYHe5aBou6Jt7cTiB81XLv/7O99x2JZn5KXhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j1MxINUkOQhaZUnGfT3M7dbpoFV/nLM7azNtMHK5GkS48trpLQosO1ulxavkK8XQH 7GoWvmXHIDE4oJjyf14s7RCOCqgKUcnloVH9igs5Hlk9RV2CvootSA3EUmqzBz7f3A opjXIVAw/IG+8EY+SxgdPSag9ZqIeTch49SWUmCcKlA+6SHbbj+CcJX/nOTL4OHg5K +ugUUt5A+f9uSoseqAefCqdXP0K31Cs5xf62xX8/nUGG6LDy4Fja+6I6oyUqM9cst6 Zl6sF9uYX9l3uZS/WjiQDO304qOwxLLr3Cu3Px9uaw55O3o13pFcxjSFKdyLgkNtHO 3FDSn9rXpDYBg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0C07669235; Fri, 9 Jan 2026 16:13:02 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:21 -0700 Message-ID: <20260109231151.4056804-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KMQ237IYZDHZ2WGHD7VBPHUZRVSV36BO X-Message-ID-Hash: KMQ237IYZDHZ2WGHD7VBPHUZRVSV36BO 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/32] boot: pxe: Add pxe_menu_init() function 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 Extract the pxe_menu allocation and initialisation from parse_pxefile() into a new pxe_menu_init() function. This provides symmetry with pxe_menu_uninit() and allows callers to create a menu structure without going through the full parsing flow. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 20 +++++++++++++++----- include/pxe_utils.h | 11 +++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index a824b1b5623..e0b7faddbd0 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -900,6 +900,20 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) return 1; } +struct pxe_menu *pxe_menu_init(void) +{ + struct pxe_menu *cfg; + + cfg = malloc(sizeof(struct pxe_menu)); + if (!cfg) + return NULL; + + memset(cfg, '\0', sizeof(struct pxe_menu)); + INIT_LIST_HEAD(&cfg->labels); + + return cfg; +} + void pxe_menu_uninit(struct pxe_menu *cfg) { struct list_head *pos, *n; @@ -924,14 +938,10 @@ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg) char *buf; int r; - cfg = malloc(sizeof(struct pxe_menu)); + cfg = pxe_menu_init(); if (!cfg) return NULL; - memset(cfg, 0, sizeof(struct pxe_menu)); - - INIT_LIST_HEAD(&cfg->labels); - buf = map_sysmem(menucfg, 0); r = parse_pxefile_top(ctx, buf, menucfg, cfg, 1); diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 0de2f49aab5..0ea250300d6 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -179,11 +179,18 @@ struct pxe_context { }; /** - * pxe_menu_uninit() - Destroy an allocated pxe structure + * pxe_menu_init() - Allocate and initialise a pxe_menu structure + * + * Return: Allocated structure, or NULL on failure + */ +struct pxe_menu *pxe_menu_init(void); + +/** + * pxe_menu_uninit() - Free a pxe_menu structure * * Free the memory used by a pxe_menu and its labels * - * @cfg: Config to destroy, previous returned from parse_pxefile() + * @cfg: Config to free, previously returned from pxe_menu_init() */ void pxe_menu_uninit(struct pxe_menu *cfg); From patchwork Fri Jan 9 23:11:22 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1409 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=1768000393; bh=LHfFM0TEBQg5Mng+zQBembcuf3/Fk1japI0EOL8182o=; 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=Eu3St6enbNnRfYOqzNnUc0CFHKhbaCVcVvaPgC5qX4s1/K1rT8hm9J+F+4vJymXfP BmukIhheIU1dDMiAF5guYV/XyuwwFMsMozQL36VdG2O7otX7J0+rlsnHtIiGbmRs0g ukVd9CiHyMkqTyD2GXuBtAcVgkzua9U/BLLNvvKPj03ZQ39ibY4M+590fPAXPScSJJ 93pMJmhFpLVSWzUkzAJ5dIjdlbXUweze8a8K48I8aQ96ek2gvVeGt9XmBMk4ZtQunb FZeUl4GTDGqXpkkP7VKIzaMeWmdIEt8tlv4CF28jp+PnqLJqPbU5dz3ShQMXAPSuZE LumBZpt+oHneQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C1C9269241 for ; Fri, 9 Jan 2026 16:13:13 -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 j-B0b-pxxwRM for ; Fri, 9 Jan 2026 16:13:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000393; bh=LHfFM0TEBQg5Mng+zQBembcuf3/Fk1japI0EOL8182o=; 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=Eu3St6enbNnRfYOqzNnUc0CFHKhbaCVcVvaPgC5qX4s1/K1rT8hm9J+F+4vJymXfP BmukIhheIU1dDMiAF5guYV/XyuwwFMsMozQL36VdG2O7otX7J0+rlsnHtIiGbmRs0g ukVd9CiHyMkqTyD2GXuBtAcVgkzua9U/BLLNvvKPj03ZQ39ibY4M+590fPAXPScSJJ 93pMJmhFpLVSWzUkzAJ5dIjdlbXUweze8a8K48I8aQ96ek2gvVeGt9XmBMk4ZtQunb FZeUl4GTDGqXpkkP7VKIzaMeWmdIEt8tlv4CF28jp+PnqLJqPbU5dz3ShQMXAPSuZE LumBZpt+oHneQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AFF986923D for ; Fri, 9 Jan 2026 16:13:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000392; bh=m8QAuMZf5N/zXvCkIRE3tONTOjsSZVBbG/mXgOe7giQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IJCGReLVCBSrWSpntCDCXMM6tEeTW2DBoOanqZp8F1omO5wyNSO1PRTZaLSKLmYVd iF8cYWr9C13HtBxSzSz8DE82Etw5N83Oqf/GOVLwjyRA+OhOD7WON6sPHxDDysm0av kADEu0KAFAg0gp5SkVGiF+2Zeuv04aHIGFYy/TAyM2qdWDtqtDHHANLPCIRTeaNa2d 0U5IVPRo3E7wMqJ8XsyrCpGZOmMNIaKsPf7dlRquIHU8Aiv3KT6aoHiXqDseAITgHR 5Ch7dKzT5tRxbIQ0nBBUY33g9MclAxgsjB3ih8ZWYKTZXOEpECKzMfyDPZsvkoi29Z YEXwVCXLKTpVg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 257EA69206; Fri, 9 Jan 2026 16:13: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 10026) with ESMTP id dtPjTH3VHr4T; Fri, 9 Jan 2026 16:13:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000388; bh=O/MeHzdE2yDv6bz7Jwf3qtjIPrytj0ejYHInGx/9A0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIJwgUCkG0rXK+7sLGl8X/WOTfmEB8r+a22yKAuu7LlUnHeiAKxvqZshkN4PYSt+2 T0RD59Z6jjmz4VEzgeOQ4uWTpc8BLryv3OGBEuM9fk0OhyMI5v8MbJlaajSte+efM/ GdjVqw4vrrQvJwOJSneOVczadMTEB7BCQtgN8Q6Iz/xwCli1SEquysBv/0W8LsK4Uh SxRZbmb3iK/M228G/IVBrw3i5lEjnMkqfYFCMHPka10SG/NN6EQnD2ccIlSD6KPIn2 VMVgTXyEXsuCPpAawrHBQuIxaj+EOim+D05cbbrn793/kqouZmmDlODiw3R/y0uHN/ g/iIYGq8eezAQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AC07469235; Fri, 9 Jan 2026 16:13:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:22 -0700 Message-ID: <20260109231151.4056804-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WLQRCAJH46MDRT34RP37BLNCP6YAZUCZ X-Message-ID-Hash: WLQRCAJH46MDRT34RP37BLNCP6YAZUCZ 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/32] boot: pxe: Defer processing of include files 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 Instead of loading and parsing included files inline during parsing, store them in cfg->includes and process them after the initial parse completes. This separates the parsing logic from file loading. Add struct pxe_include to store the path, target menu pointer and nesting level. The nesting level ensures the MAX_NEST_LEVEL (16) limit is properly enforced for deeply nested includes. Add pxe_parse_include() for callers who want manual control over include processing. The parse_pxefile() function processes includes automatically to maintain backwards compatibility with existing callers. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 38 ++++++++++----------------- boot/pxe_utils.c | 62 +++++++++++++++++++++++++++++++++++++++++---- include/pxe_utils.h | 58 +++++++++++++++++++++++++++++++++++++----- test/boot/pxe.c | 19 +++++++++----- 4 files changed, 135 insertions(+), 42 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index e3412166a63..72a672354b5 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -326,39 +326,31 @@ static int parse_integer(char **c, int *dst) } /* - * Parse an include statement, and retrieve and parse the file it mentions. + * Parse an include statement and store the path for later loading. * - * base should point to a location where it's safe to store the file, and - * nest_level should indicate how many nested includes have occurred. For this - * include, nest_level has already been incremented and doesn't need to be - * incremented here. + * 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(struct pxe_context *ctx, char **c, unsigned long base, - struct pxe_menu *cfg, int nest_level) +static int handle_include(char **c, struct pxe_menu *cfg, int nest_level) { - char *include_path; + struct pxe_include inc; char *s = *c; int err; - char *buf; - int ret; - err = parse_sliteral(c, &include_path); + err = parse_sliteral(c, &inc.path); if (err < 0) { printf("Expected include path: %.*s\n", (int)(*c - s), s); return err; } + inc.cfg = cfg; + inc.nest_level = nest_level + 1; - err = get_pxe_file(ctx, include_path, base); - if (err < 0) { - printf("Couldn't retrieve %s\n", include_path); - return err; + if (!alist_add(&cfg->includes, inc)) { + free(inc.path); + return -ENOMEM; } - buf = map_sysmem(base, 0); - ret = parse_pxefile_top(ctx, buf, base, cfg, nest_level); - unmap_sysmem(buf); - - return ret; + return 1; } /* @@ -385,7 +377,7 @@ static int parse_menu(struct pxe_context *ctx, char **c, struct pxe_menu *cfg, err = parse_sliteral(c, &cfg->title); break; case T_INCLUDE: - err = handle_include(ctx, c, base, cfg, nest_level + 1); + err = handle_include(c, cfg, nest_level); break; case T_BACKGROUND: err = parse_sliteral(c, &cfg->bmp); @@ -635,9 +627,7 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, ulong base, } break; case T_INCLUDE: - err = handle_include(ctx, &p, - base + ALIGN(strlen(b), 4), cfg, - nest_level + 1); + err = handle_include(&p, cfg, nest_level); break; case T_PROMPT: err = parse_integer(&p, &cfg->prompt); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index e0b7faddbd0..410f2d1eafe 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -910,12 +910,14 @@ struct pxe_menu *pxe_menu_init(void) memset(cfg, '\0', sizeof(struct pxe_menu)); INIT_LIST_HEAD(&cfg->labels); + alist_init(&cfg->includes, sizeof(struct pxe_include), 0); return cfg; } void pxe_menu_uninit(struct pxe_menu *cfg) { + struct pxe_include *inc; struct list_head *pos, *n; struct pxe_label *label; @@ -929,6 +931,10 @@ void pxe_menu_uninit(struct pxe_menu *cfg) label_destroy(label); } + alist_for_each(inc, &cfg->includes) + free(inc->path); + alist_uninit(&cfg->includes); + free(cfg); } @@ -944,6 +950,12 @@ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg) buf = map_sysmem(menucfg, 0); r = parse_pxefile_top(ctx, buf, menucfg, cfg, 1); + unmap_sysmem(buf); + + if (r < 0) { + pxe_menu_uninit(cfg); + return NULL; + } if (ctx->use_fallback) { if (cfg->fallback_label) { @@ -954,13 +966,46 @@ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg) } } - unmap_sysmem(buf); - if (r < 0) { - pxe_menu_uninit(cfg); - return NULL; + return cfg; +} + +int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, + ulong base) +{ + struct pxe_include *inc; + char *buf; + uint i; + int r; + + /* + * Process includes - load each file and parse it. Get the include + * fresh each iteration since parsing may add more includes and cause + * alist reallocation. + */ + for (i = 0; i < cfg->includes.count; i++) { + inc = alist_getw(&cfg->includes, i, struct pxe_include); + + r = get_pxe_file(ctx, inc->path, base); + if (r < 0) { + printf("Couldn't retrieve %s\n", inc->path); + return r; + } + + buf = map_sysmem(base, 0); + r = pxe_parse_include(ctx, inc, buf, base); + unmap_sysmem(buf); + + if (r < 0) + return r; } - return cfg; + return 0; +} + +int pxe_parse_include(struct pxe_context *ctx, struct pxe_include *inc, + char *buf, ulong base) +{ + return parse_pxefile_top(ctx, buf, base, inc->cfg, inc->nest_level); } /* @@ -1179,6 +1224,7 @@ struct pxe_menu *pxe_prepare(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) { struct pxe_menu *cfg; + int ret; cfg = parse_pxefile(ctx, pxefile_addr_r); if (!cfg) { @@ -1186,6 +1232,12 @@ struct pxe_menu *pxe_prepare(struct pxe_context *ctx, ulong pxefile_addr_r, return NULL; } + ret = pxe_process_includes(ctx, cfg, pxefile_addr_r); + if (ret) { + pxe_menu_uninit(cfg); + return NULL; + } + if (prompt) cfg->prompt = prompt; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 0ea250300d6..7f5b8c040d6 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 @@ -68,6 +69,19 @@ struct pxe_label { struct list_head list; }; +/** + * struct pxe_include - an include file that needs to be loaded + * + * @path: Path to the include file + * @cfg: Menu to parse the include into + * @nest_level: Nesting level to use when parsing this include + */ +struct pxe_include { + char *path; + struct pxe_menu *cfg; + int nest_level; +}; + /* * Describes a pxe menu as given via pxe files. * @@ -81,6 +95,7 @@ struct pxe_label { * interrupted. If 1, always prompt for a choice regardless of * timeout. * labels - a list of labels defined for the menu. + * includes - list of struct pxe_include for files that need loading/parsing */ struct pxe_menu { char *title; @@ -90,6 +105,7 @@ struct pxe_menu { int timeout; int prompt; struct list_head labels; + struct alist includes; }; struct pxe_context; @@ -242,18 +258,48 @@ 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() - Parsing a pxe file + * parse_pxefile() - Parse a pxe file * - * This is only used for the top-level 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) - * Returns NULL if there is an error, otherwise, returns a pointer to a - * pxe_menu struct populated with the results of parsing the pxe file (and any - * files it includes). The resulting pxe_menu struct can be free()'d by using - * the pxe_menu_uninit() function. + * @menucfg: Address of the PXE file in memory + * 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); +/** + * pxe_process_includes() - Process include files in a parsed menu + * + * Load and parse all include files referenced in cfg->includes. This may + * add more includes if nested includes are found. + * + * @ctx: PXE context with getfile callback + * @cfg: Parsed PXE menu with includes to process + * @base: Memory address for loading include files + * Return: 0 on success, -ve on error + */ +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 * diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 8d7c6f7f2ae..365aff9f37a 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -164,6 +164,9 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) cfg = parse_pxefile(&ctx, addr); ut_assertnonnull(cfg); + /* Process any include files */ + ut_assertok(pxe_process_includes(&ctx, cfg, addr)); + /* Verify no console output during parsing (say is printed on boot) */ ut_assert_console_end(); @@ -621,7 +624,6 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) struct pxe_menu *cfg; ulong addr = PXE_LOAD_ADDR; void *fdt; - uint i; ut_assertnonnull(fs_image); ut_assertnonnull(cfg_path); @@ -635,17 +637,17 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) ut_assertok(pxe_setup_ctx(&ctx, pxe_test_getfile, &info, true, cfg_path, false, false, NULL)); - /* Read and parse the config file */ + /* Read and parse the config file (quiet since we're just parsing) */ + ctx.quiet = true; ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); cfg = parse_pxefile(&ctx, addr); ut_assertnonnull(cfg); - /* Consume parsing output (say message is printed on boot, not parsing) */ - ut_assert_nextline("Retrieving file: %s", cfg_path); - ut_assert_nextline("Retrieving file: /extlinux/extra.conf"); - for (i = 3; i <= 16; i++) - ut_assert_nextline("Retrieving file: /extlinux/nest%d.conf", i); + /* Process any include files */ + ut_assertok(pxe_process_includes(&ctx, cfg, addr)); + + /* Verify no console output during parsing (say is printed on boot) */ ut_assert_console_end(); /* @@ -662,6 +664,9 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) ut_asserteq_str("linux", label->name); ut_assertnonnull(label->fdtoverlays); + /* Enable output for loading phase */ + ctx.quiet = false; + /* Load the label - should succeed but skip overlays */ ut_assertok(pxe_load_label(&ctx, label)); From patchwork Fri Jan 9 23:11:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1410 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=1768000398; bh=VPLMOWLqUy90JUJw+fQZwNqDb2NQqO4EnLv2J1wrHDQ=; 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=TdioXeSRrGwjL2bFYlERo6cD6uMMWZptUAgHAL5PAFGRlEJKRBKr7WpErlhXWapus IpmcZqKGwyVE1DZAU70jW9a0Udpu3sPqlpnegDtMJ2bBGXdBxc7GmrjpRTHnjOOAxt 1OzqVQuBlIYublHsRxKuy4YKH7CtlyIzQOBc6RtSCv7eOsYNw6ZIROovuNsDyXW9yr BruIuAKIj1j7Z9wgefoBaw5cCgSk+o3D0GVE3cdU4hTe1QWx/tshxC/ZpQIqakDsdZ e4XQAJQ4KVmIEK1Sbcmcs6QoSBBoOmc+4qMb5hlhhh6O7+grbn9TtmVC1XVUN3q0ed 8EsajsE86uobQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 43B4C69241 for ; Fri, 9 Jan 2026 16:13: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 10024) with ESMTP id Oz6RzAkuWE6F for ; Fri, 9 Jan 2026 16:13:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000398; bh=VPLMOWLqUy90JUJw+fQZwNqDb2NQqO4EnLv2J1wrHDQ=; 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=TdioXeSRrGwjL2bFYlERo6cD6uMMWZptUAgHAL5PAFGRlEJKRBKr7WpErlhXWapus IpmcZqKGwyVE1DZAU70jW9a0Udpu3sPqlpnegDtMJ2bBGXdBxc7GmrjpRTHnjOOAxt 1OzqVQuBlIYublHsRxKuy4YKH7CtlyIzQOBc6RtSCv7eOsYNw6ZIROovuNsDyXW9yr BruIuAKIj1j7Z9wgefoBaw5cCgSk+o3D0GVE3cdU4hTe1QWx/tshxC/ZpQIqakDsdZ e4XQAJQ4KVmIEK1Sbcmcs6QoSBBoOmc+4qMb5hlhhh6O7+grbn9TtmVC1XVUN3q0ed 8EsajsE86uobQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 334B66923D for ; Fri, 9 Jan 2026 16:13:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000396; bh=J6poRs4shdRohvyQ2n2OdvJN2YoRhEcwqbZup4GJ4jA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UfFPqSTOqINHKpFUH3X8XGrJw3hy/OFeGpvEHDmOre+Gn5MFe2X8IF8fz1T/IkeXJ k0L8VHBfDU7OrEc+H6vzkGW9yITiQ4SCz7i+zY7/UMRdsZmLiSQwsdmVO/xKMEn4Hh 3HFCNmlOKdoQHRiiLz2erWBvdH1CQDhcs/y594kJwDXCLw7ORQ3YrCTO3Cd1kLLwA/ twnSiTjBaCxUmgFdjTBzsetOXqw6/3Adpd5V225idnvTorRsqaRKX7ASJb8I0HiKqO cmvW09ofrPcbjCq+orYl5CHNhUOB2PO/rxNOyXgjwjPsxcnTOKhQ94N1Nuev2qV5mm cb+jn3mSTwdVw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BF37E69206; Fri, 9 Jan 2026 16:13: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 10026) with ESMTP id HiX5sKL-1AoU; Fri, 9 Jan 2026 16:13:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000392; bh=znAT+FQ85HsE/EnU3+u0uRmqfbaHNeQan9fiy+ND/30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uq0aZqy0AVSfpbyrccsr6hrBu+0m14bCKAXj3j6cdrF8HmMazFf25xzQO0OFZ444r 1KNgDGUO418Cac7qxq440KGEQ876o0A3vz8NYT6k7Pmamiej336WcSodXEzRfuq1mz UEVIj29bKeiofmy023bUv7TUAkBz89MCPMH0AnQ7var1lN78mb9vjJDX0mwjZT7UGY NKiTao9u9eW/BmJH5CBAR7Ie32vo6FioBdS87WFk48HwyDQaLzcqjAwjarG2Y85rab ip1i4Jblce63ASYxa3oT5xe0+TEXcaHTFoJN4mV70dw6ftzhxuU1MkV/gtWRAZp8T3 dSRLB6WAz0oMA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6627369218; Fri, 9 Jan 2026 16:13:12 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:23 -0700 Message-ID: <20260109231151.4056804-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EZZYOZMOZOR6NDBIFA4BWOLBO27E323Z X-Message-ID-Hash: EZZYOZMOZOR6NDBIFA4BWOLBO27E323Z 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/32] boot: pxe: Extract pxe_load_files() from pxe_load_label() 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 Separate the file-loading logic (kernel, initrd) from pxe_load_label() into a new pxe_load_files() function. This stores the loaded addresses and sizes directly in the pxe_context. The pxe_load_label() function now calls pxe_load_files() and handles the remaining setup: FDT processing, string formatting and storing metadata in the context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 88 +++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 410f2d1eafe..55b738e5c45 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -679,31 +679,10 @@ static int generate_localboot(struct pxe_label *label) return 0; } -int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) +static int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label) { - char fit_addr[200]; - const char *conf_fdt_str; - ulong kern_addr = 0; - ulong initrd_addr = 0; - ulong initrd_size = 0; - ulong kern_size; - ulong conf_fdt = 0; - char initrd_str[28] = ""; int ret; - if (label->localboot) { - if (label->localboot_val >= 0) { - if (IS_ENABLED(CONFIG_BOOTMETH_EXTLINUX_LOCALBOOT)) { - ret = generate_localboot(label); - if (ret) - return ret; - } - } - /* negative localboot_val means skip loading */ - if (!label->kernel) - return 0; - } - if (!label->kernel) { printf("No kernel given, skipping %s\n", label->name); return -ENOENT; @@ -711,34 +690,64 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r", SZ_2M, (enum bootflow_img_t)IH_TYPE_KERNEL, - &kern_addr, &kern_size) < 0) { + &ctx->kern_addr, &ctx->kern_size) < 0) { printf("Skipping %s for failure retrieving kernel\n", label->name); return -EIO; } - /* for FIT, append the configuration identifier */ - snprintf(fit_addr, sizeof(fit_addr), "%lx%s", kern_addr, - label->config ? label->config : ""); - /* For FIT, the label can be identical to kernel one */ if (label->initrd && !strcmp(label->kernel_label, label->initrd)) { - initrd_addr = kern_addr; + ctx->initrd_addr = ctx->kern_addr; } else if (label->initrd) { - ulong size; - ret = get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r", SZ_2M, (enum bootflow_img_t)IH_TYPE_RAMDISK, - &initrd_addr, &size); + &ctx->initrd_addr, &ctx->initrd_size); if (ret < 0) { printf("Skipping %s for failure retrieving initrd\n", label->name); return -EIO; } - initrd_size = size; + } + + return 0; +} + +int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) +{ + char fit_addr[200]; + const char *conf_fdt_str; + ulong conf_fdt = 0; + char initrd_str[28] = ""; + int ret; + + if (label->localboot) { + if (label->localboot_val >= 0) { + if (IS_ENABLED(CONFIG_BOOTMETH_EXTLINUX_LOCALBOOT)) { + ret = generate_localboot(label); + if (ret) + return ret; + } + } + /* negative localboot_val means skip loading */ + if (!label->kernel) + return 0; + } + + ret = pxe_load_files(ctx, label); + if (ret) + return ret; + + /* for FIT, append the configuration identifier */ + snprintf(fit_addr, sizeof(fit_addr), "%lx%s", ctx->kern_addr, + label->config ? label->config : ""); + + if (ctx->initrd_addr && ctx->initrd_size) { + int size; + size = snprintf(initrd_str, sizeof(initrd_str), "%lx:%lx", - initrd_addr, size); + ctx->initrd_addr, ctx->initrd_size); if (size >= sizeof(initrd_str)) return -ENOSPC; } @@ -749,7 +758,7 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) return ret; if (!conf_fdt_str) - conf_fdt_str = pxe_get_fdt_fallback(label, kern_addr); + conf_fdt_str = pxe_get_fdt_fallback(label, ctx->kern_addr); if (conf_fdt_str) conf_fdt = hextoul(conf_fdt_str, NULL); log_debug("conf_fdt %lx\n", conf_fdt); @@ -760,25 +769,20 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) /* Save the loaded info to context */ ctx->label = label; ctx->kern_addr_str = strdup(fit_addr); - ctx->kern_addr = kern_addr; - ctx->kern_size = kern_size; - if (initrd_addr) { - ctx->initrd_addr = initrd_addr; - ctx->initrd_size = initrd_size; + if (ctx->initrd_addr) ctx->initrd_str = strdup(initrd_str); - } ctx->conf_fdt_str = strdup(conf_fdt_str); ctx->conf_fdt = conf_fdt; log_debug("Loaded label '%s':\n", label->name); log_debug("- kern_addr_str '%s' conf_fdt_str '%s' conf_fdt %lx\n", ctx->kern_addr_str, ctx->conf_fdt_str, conf_fdt); - if (initrd_addr) { + if (ctx->initrd_addr) { log_debug("- initrd addr %lx filesize %lx str '%s'\n", ctx->initrd_addr, ctx->initrd_size, ctx->initrd_str); } if (!ctx->kern_addr_str || (conf_fdt_str && !ctx->conf_fdt_str) || - (initrd_addr && !ctx->initrd_str)) { + (ctx->initrd_addr && !ctx->initrd_str)) { printf("malloc fail (saving label)\n"); return -ENOMEM; } From patchwork Fri Jan 9 23:11:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1411 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=1768000402; bh=UgFbU2jSASfR19RN+rW81Ecre1s0Z0KzkmPK3fWo9nA=; 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=BfRqZfq6Xhr2sgZQD9ux/sgXTg9wnjf1kAFxZHjtYfyisl01YjyXHiX5dmjPnUJFw surDfeJ+GLT7HlhXksZe0Jw4LQrQznNqCbtrPRhD+LRusl+H5beMITE5H8XkSGZBB4 tQBlLVWyAK6Zf0g5sTMJPR5vE21FrCJMbI41SnOhrr3moq2mPKKIa/pyuRaEMnUSQP VHoBkPe8KiJKwzq1VLEzpRXZ+OnibVXHJvI9i1YMX8U0jqdDpi3f4Av8q/gsYLZBLQ GgkyGVxfUAIFtpsYH/rto5B6sgRg9CktuMU1I/WWfW2wCO4z24HG9aYoLLmJd+I/1I k1eAkdGLsfKdQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C73AE69235 for ; Fri, 9 Jan 2026 16:13: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 x3JmNDklPwSy for ; Fri, 9 Jan 2026 16:13:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000402; bh=UgFbU2jSASfR19RN+rW81Ecre1s0Z0KzkmPK3fWo9nA=; 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=BfRqZfq6Xhr2sgZQD9ux/sgXTg9wnjf1kAFxZHjtYfyisl01YjyXHiX5dmjPnUJFw surDfeJ+GLT7HlhXksZe0Jw4LQrQznNqCbtrPRhD+LRusl+H5beMITE5H8XkSGZBB4 tQBlLVWyAK6Zf0g5sTMJPR5vE21FrCJMbI41SnOhrr3moq2mPKKIa/pyuRaEMnUSQP VHoBkPe8KiJKwzq1VLEzpRXZ+OnibVXHJvI9i1YMX8U0jqdDpi3f4Av8q/gsYLZBLQ GgkyGVxfUAIFtpsYH/rto5B6sgRg9CktuMU1I/WWfW2wCO4z24HG9aYoLLmJd+I/1I k1eAkdGLsfKdQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AC65E6923D for ; Fri, 9 Jan 2026 16:13:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000401; bh=IjvH2d4oLEsLL8rc17rkbbMswVHUK/ob1zVArT07jIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=klajRcaN1/iJ8nLPZYqSGIgiCF3bzVYgebwEBwBd3Me/vwoA4QVdtYQIEOcAU3a96 n6ZbeaBTKEBNn2Vsq1DNvV9bmCIGMBaMWJYmStaKz+aZhQst+u++RCleb+HeMHrK+G XScbb6YnucWAFkNfZDM3FTdlokY5AFfcXQ9HyesCFOK9KoJAX/aXoYvl77mXEz9EcH vAYF5e/kQw6zvvhUawEVjlZIJB9gVJkEspXezKQKUqG0BnIX3ctBcaniDX7ufANBaN LlNmHKWk2kztR6n11jphERawP/IPVq6kN1WLWLhdR6zxje45whcntXplvFDj+ecO/h Rkr7dGSgXX+jw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7F2D45FF82; Fri, 9 Jan 2026 16:13: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 10026) with ESMTP id xf1J1OUFxJ01; Fri, 9 Jan 2026 16:13:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000397; bh=18A2kDgNCioP15tqWcn3sKQO6BG5iEkuz56V+2/Rf/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aP1+Ke7lLR/zi4nqqNSmQ303y8fLCiSGuKD2mJkmra8PAxiaYKZ89FZKuB37ySf1k G78HMtJFdENPC42UDOJu03Dtw2+QRWXq13tJTE8vsddD15XPIbrzTXeDNDy/AezLIR tFZQgfPd1juNxcKAn71MJ0RMiAAIXt9omogtQ1OB99dduoHcjYwtPVQczhBaOwuR7X sXXYJ/FwzJ2ROYUBjxLNYAi5wCO0HcBK/bNgTdnv7mvsc4mp21yBeKnfml2QAI/lYw z4uu8jbhan1yr98a+ZdaLwPsDlQPDxcM8CBu4Bwkl5RPG2I0SZsIT/zolLTEmnjjdn 5smAvVCzcs3Sw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0F5F669218; Fri, 9 Jan 2026 16:13:17 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:24 -0700 Message-ID: <20260109231151.4056804-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5Q5WZXQLFMEOWYAHZA3XWPYWRAX5NCJY X-Message-ID-Hash: 5Q5WZXQLFMEOWYAHZA3XWPYWRAX5NCJY 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/32] boot: pxe: Split filename handling from label_process_fdt() 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 Separate the logic that determines the FDT filename into a new label_get_fdt_path() function. This handles both the label->fdt case and the label->fdtdir case where the filename is constructed from environment variables. The new function returns an allocated string that the caller must free. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 148 +++++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 63 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 55b738e5c45..0994e7e5196 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -428,6 +428,84 @@ const char *pxe_get_fdt_fallback(struct pxe_label *label, ulong kern_addr) return conf_fdt_str; } +/** + * label_get_fdt_path() - Get the FDT path for a label + * + * Determine the FDT filename from label->fdt or by constructing it from + * label->fdtdir and environment variables. + * + * @label: Label to get FDT path for + * @fdtfilep: Returns allocated FDT path, or NULL if none. Caller must free. + * Return: 0 on success, -ENOMEM on allocation failure + */ +static int label_get_fdt_path(struct pxe_label *label, char **fdtfilep) +{ + char *fdtfile = NULL; + + if (label->fdt) { + if (IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS)) { + if (strcmp("-", label->fdt)) + fdtfile = strdup(label->fdt); + } else { + fdtfile = strdup(label->fdt); + } + } else if (label->fdtdir) { + char *f1, *f2, *f3, *f4, *slash; + int len; + + f1 = env_get("fdtfile"); + if (f1) { + f2 = ""; + f3 = ""; + f4 = ""; + } else { + /* + * For complex cases where this code doesn't + * generate the correct filename, the board + * code should set $fdtfile during early boot, + * or the boot scripts should set $fdtfile + * before invoking "pxe" or "sysboot". + */ + f1 = env_get("soc"); + f2 = "-"; + f3 = env_get("board"); + f4 = ".dtb"; + if (!f1) { + f1 = ""; + f2 = ""; + } + if (!f3) { + f2 = ""; + f3 = ""; + } + } + + len = strlen(label->fdtdir); + if (!len) + slash = "./"; + else if (label->fdtdir[len - 1] != '/') + slash = "/"; + else + slash = ""; + + len = strlen(label->fdtdir) + strlen(slash) + + strlen(f1) + strlen(f2) + strlen(f3) + + strlen(f4) + 1; + fdtfile = malloc(len); + if (!fdtfile) { + printf("malloc fail (FDT filename)\n"); + return -ENOMEM; + } + + snprintf(fdtfile, len, "%s%s%s%s%s%s", + label->fdtdir, slash, f1, f2, f3, f4); + } + + *fdtfilep = fdtfile; + + return 0; +} + /* * label_process_fdt() - Process FDT for the label * @@ -459,6 +537,9 @@ const char *pxe_get_fdt_fallback(struct pxe_label *label, ulong kern_addr) static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, char *kernel_addr, const char **fdt_argp) { + char *fdtfile; + int ret; + log_debug("label '%s' kernel_addr '%s' label->fdt '%s' fdtdir '%s' " "kernel_label '%s' fdt_argp '%s'\n", label->name, kernel_addr, label->fdt, label->fdtdir, @@ -469,68 +550,9 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, *fdt_argp = kernel_addr; /* if fdt label is defined then get fdt from server */ } else if (*fdt_argp) { - char *fdtfile = NULL; - char *fdtfilefree = NULL; - - if (label->fdt) { - if (IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS)) { - if (strcmp("-", label->fdt)) - fdtfile = label->fdt; - } else { - fdtfile = label->fdt; - } - } else if (label->fdtdir) { - char *f1, *f2, *f3, *f4, *slash; - int len; - - f1 = env_get("fdtfile"); - if (f1) { - f2 = ""; - f3 = ""; - f4 = ""; - } else { - /* - * For complex cases where this code doesn't - * generate the correct filename, the board - * code should set $fdtfile during early boot, - * or the boot scripts should set $fdtfile - * before invoking "pxe" or "sysboot". - */ - f1 = env_get("soc"); - f2 = "-"; - f3 = env_get("board"); - f4 = ".dtb"; - if (!f1) { - f1 = ""; - f2 = ""; - } - if (!f3) { - f2 = ""; - f3 = ""; - } - } - - len = strlen(label->fdtdir); - if (!len) - slash = "./"; - else if (label->fdtdir[len - 1] != '/') - slash = "/"; - else - slash = ""; - - len = strlen(label->fdtdir) + strlen(slash) + - strlen(f1) + strlen(f2) + strlen(f3) + - strlen(f4) + 1; - fdtfilefree = malloc(len); - if (!fdtfilefree) { - printf("malloc fail (FDT filename)\n"); - return -ENOMEM; - } - - snprintf(fdtfilefree, len, "%s%s%s%s%s%s", - label->fdtdir, slash, f1, f2, f3, f4); - fdtfile = fdtfilefree; - } + ret = label_get_fdt_path(label, &fdtfile); + if (ret) + return ret; if (fdtfile) { ulong addr; @@ -541,7 +563,7 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, (enum bootflow_img_t)IH_TYPE_FLATDT, &addr, NULL); - free(fdtfilefree); + free(fdtfile); if (err < 0) { *fdt_argp = NULL; From patchwork Fri Jan 9 23:11:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1412 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000408; bh=wwPbHcPt1hPZ82UwKyTnk2inWAQT+9p+PA/iZyjKsj8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=EjAMjORE3liZzYr12GIyGq6pbSyQLvHkUBEUvgAqmQFfAMe+U+LFdxNvr5KSXn8Mj t3hk/Zwyx77w1Oi6kse5DyCg90JiUfU8qvgUhGn/kEFE2kVZvQ3zDivXyuth1+YPtL mBMRkI8i/MnL3ZIIxBVgNnLuLgQWmK3buLeJ6ltIoo6yGD7AMbIEwfpHO6QgsMLg06 p+I89M3q+KjJqooFETTBDikXhuU86myHIksHDpEzcccLRocMVseIycB/jSJumlhD7L FeBbhDG+gQ4dbbYVd4UmfQv6MNpB5osOIxoc1j55WXpMSuwE+65kGR0STQZ9iKaZBy hbRsq+ClWKoxQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 387696923D for ; Fri, 9 Jan 2026 16:13:28 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Be5R69LZF6KZ for ; Fri, 9 Jan 2026 16:13:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000408; bh=wwPbHcPt1hPZ82UwKyTnk2inWAQT+9p+PA/iZyjKsj8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=EjAMjORE3liZzYr12GIyGq6pbSyQLvHkUBEUvgAqmQFfAMe+U+LFdxNvr5KSXn8Mj t3hk/Zwyx77w1Oi6kse5DyCg90JiUfU8qvgUhGn/kEFE2kVZvQ3zDivXyuth1+YPtL mBMRkI8i/MnL3ZIIxBVgNnLuLgQWmK3buLeJ6ltIoo6yGD7AMbIEwfpHO6QgsMLg06 p+I89M3q+KjJqooFETTBDikXhuU86myHIksHDpEzcccLRocMVseIycB/jSJumlhD7L FeBbhDG+gQ4dbbYVd4UmfQv6MNpB5osOIxoc1j55WXpMSuwE+65kGR0STQZ9iKaZBy hbRsq+ClWKoxQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 15F3869240 for ; Fri, 9 Jan 2026 16:13:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000406; bh=OYAmkvPmWIhjMU3yi4BHXP2wj9BOC/P2QLPtCr6elWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g52MmInSxulnJ8ZyR5eDLKgwqnD8WWSufY9J5YMqv2KA/qwA6LEB5CL/XA5Sqn1I+ hgHJ1ezRYqh8GOCIHIatSJGPN0HdsJsuHDDchWkwb1MTMehksZlGL9m14zMrpoNE70 zGTKbHKEievjQKhkGu1RsTKOlsM0jLgylAYRzsqdPBp01XOXpkqjt+G8IVBfeVJrbR 9yEd6TBFFOvZXmwSmUcJ57zprjP1wx67c9VchygSi+ouJsYRoqG2rw5YmKvrYzjhnk C6iDaPkc9oYdmqy64vdh7aV8lMpmJ5YCYNrF4Ywk2VxKEURvZ/5j8QIzB5YhM33g2a fwzTs7a+AdO5w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8673E5FF82; Fri, 9 Jan 2026 16:13:26 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id pN7lOmYX0Fzq; Fri, 9 Jan 2026 16:13:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000402; bh=mA+jIegmE3diD4NALB1Z03MCYhj49zjoC7w2C8oeW1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XjnT/ST8O79dgMVfUBve7UpWeIOi1RSpvzasb8EcO947Mi/K2jT+7TimLw+xhUCv4 gXRkUnxKx3NxJ2LMdPyz/fefV6CQYAO/o3AkTMHu4QzbCJYVCp7gfYn8SoYvHtamZ5 tGcuejnK49i4SCRaJ7zLs5M1aWgENLuYCr173kOBFRAJ7KqXlq06M4ZC6X6+0QTp29 unzNvRllHKlxXvlk/Zhmrmha8Mu+vfTcQfvLJDRncXL+tPM798ReF/cNzGiUAqVRdr WHNGMyArkZs6XQCCQroDkuIzOUObo+B0XOPYX02HlHhNNCZQHIBcv0cXw4ZIh9cPfE PRQdw0aJheaHQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C3C7769218; Fri, 9 Jan 2026 16:13:21 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:25 -0700 Message-ID: <20260109231151.4056804-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QERII5GIH3PBQHJY35PJPBIHOIZNJBZS X-Message-ID-Hash: QERII5GIH3PBQHJY35PJPBIHOIZNJBZS X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/32] boot: pxe: Add FDT pointer to context for kaslrseed List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The label_boot_kaslrseed() function reads fdt_addr_r from the environment and maps it to get the working FDT. This requires CONFIG_CMDLINE to be enabled for the environment access. Add a new 'fdt' field to struct pxe_context to hold the working FDT pointer. Set this after loading the FDT file in label_process_fdt() and use it in label_boot_kaslrseed(). This removes the environment dependency and ensures the correct FDT is used. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 27 +++++++++++---------------- include/pxe_utils.h | 2 ++ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 0994e7e5196..93e00b6f97e 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -277,30 +277,23 @@ static int label_localboot(struct pxe_label *label) /* * label_boot_kaslrseed generate kaslrseed from hw rng */ - -static void label_boot_kaslrseed(void) +static void label_boot_kaslrseed(struct pxe_context *ctx) { #if CONFIG_IS_ENABLED(DM_RNG) - ulong fdt_addr; - struct fdt_header *working_fdt; int err; - /* Get the main fdt and map it */ - fdt_addr = hextoul(env_get("fdt_addr_r"), NULL); - working_fdt = map_sysmem(fdt_addr, 0); - err = fdt_check_header(working_fdt); + err = fdt_check_header(ctx->fdt); if (err) return; /* add extra size for holding kaslr-seed */ /* err is new fdt size, 0 or negtive */ - err = fdt_shrink_to_minimum(working_fdt, 512); + err = fdt_shrink_to_minimum(ctx->fdt, 512); if (err <= 0) return; - fdt_kaslrseed(working_fdt, true); + fdt_kaslrseed(ctx->fdt, true); #endif - return; } /** @@ -577,15 +570,17 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, printf("Skipping fdtdir %s for failure retrieving dts\n", label->fdtdir); } - } + } else { + ctx->fdt = map_sysmem(addr, 0); - if (label->kaslrseed) - label_boot_kaslrseed(); + if (label->kaslrseed) + label_boot_kaslrseed(ctx); #ifdef CONFIG_OF_LIBFDT_OVERLAY - if (label->fdtoverlays) - label_boot_fdtoverlay(ctx, label); + if (label->fdtoverlays) + label_boot_fdtoverlay(ctx, label); #endif + } } else { *fdt_argp = NULL; } diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 7f5b8c040d6..9bca8d7868d 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -152,6 +152,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * @initrd_str: initrd string to process (only used if @initrd_addr) * @conf_fdt_str: FDT-address string * @conf_fdt: FDT address + * @fdt: Working FDT pointer, for kaslrseed and overlay operations * @restart: true to use BOOTM_STATE_RESTART instead of BOOTM_STATE_START (only * supported with FIT / bootm) * @fake_go: Do a 'fake' boot, up to the last possible point, then return @@ -190,6 +191,7 @@ struct pxe_context { char *initrd_str; char *conf_fdt_str; ulong conf_fdt; + void *fdt; /* working FDT pointer, for kaslrseed/overlays */ bool restart; bool fake_go; }; From patchwork Fri Jan 9 23:11:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1413 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=1768000413; bh=25wAsNY5vbK0Hyz8zzWjfUVJxdTLfw4crWFgqfWF49o=; 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=tdmaNMQZHgDSBXh6s4jXv2iUuvDYudbD1gFZjW1lS8jG2YvXFqP8QiUO8dcnVJud1 8LawCmp/XYMYsYPLuiYyq2Zb6glr0WZrNYNr9SUw+ryXNWgJaMMOINxUfxKSRd8vyU 5RXat59WJtkFsAmkGaik2kvLNREJSTOvI8oGi0YxV/ezgh7wHgDSNW4VJdchwZ3TrH jhfAYvpbDLiNmuHYXuYcl8MjwqhsiSpoivWgv+bqk2ev4iu3AFCgld8MrIYug4Zlc0 qVbMP7W7wEHTk6hcJF3nvm97IWeo4W272ViOVHg7FeXuc0NFmqVyH0u5Ezh3XrQYWG QHgqSkv3VtMnA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A630169218 for ; Fri, 9 Jan 2026 16:13: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 10024) with ESMTP id cPUdg86RbgvB for ; Fri, 9 Jan 2026 16:13:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000413; bh=25wAsNY5vbK0Hyz8zzWjfUVJxdTLfw4crWFgqfWF49o=; 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=tdmaNMQZHgDSBXh6s4jXv2iUuvDYudbD1gFZjW1lS8jG2YvXFqP8QiUO8dcnVJud1 8LawCmp/XYMYsYPLuiYyq2Zb6glr0WZrNYNr9SUw+ryXNWgJaMMOINxUfxKSRd8vyU 5RXat59WJtkFsAmkGaik2kvLNREJSTOvI8oGi0YxV/ezgh7wHgDSNW4VJdchwZ3TrH jhfAYvpbDLiNmuHYXuYcl8MjwqhsiSpoivWgv+bqk2ev4iu3AFCgld8MrIYug4Zlc0 qVbMP7W7wEHTk6hcJF3nvm97IWeo4W272ViOVHg7FeXuc0NFmqVyH0u5Ezh3XrQYWG QHgqSkv3VtMnA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A11C5FF82 for ; Fri, 9 Jan 2026 16:13:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000411; bh=zCwloTE155WB4n3CUmYkyI6BdedIWu251VdeAEhEZUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E+X8ZGD2YyFc++u7HhOWxlHZNlA21dzLGXCuUKOgllzO8uupw/2Siu22+aYhifONd CyeVgDGrEGvZ5lDCYK4Pp1LD3TLNMaAxTEsNvcIMLjI/CItvLaowIYegqBRl2G+g3h bVGY5ou69j4rkbh4dDIgTthIKLxCzpxrwIM7XA2AZnqrUWa0AOLIPmZeHzN7K1GU+S v1cyP5PxOiTCe8yvhQcT37kBXGDH5f8OjucRFV7/4PWgpoj8oDoJVQj1Nk8TIZ/8rt COStheLI11YTodtY4+eInEGzr1gebFeMavhb/W8gHiPXbEbfAs8b0sdzVTqB0PzPot 1YUoTcZ1bideA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 945D05FF82; Fri, 9 Jan 2026 16:13: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 10026) with ESMTP id dmoxkHBcYL9W; Fri, 9 Jan 2026 16:13:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000407; bh=ocyyojzj5i1yo0C4rpKEiDAH0Ias3o8DMUcdV4hMcuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eO1lV/ha+3GXJRpxzAS1SpAggwzJAY2PH7mc9wJmoWRXSYrrWLNTwzy8IElABo6he hd0WTrGmb8Uywwl7UXA76WVEpMvrx3MSXThVREmAR9E7ZmxgePcmDpKRN+b2g+p2lP R93RupIR7zYMgJJB5ePx37f5nVB6qLF0ePPcK0hQrKqoWKPejpIqT1108gWLg7rzm2 9/r5mNpQEmuxHmRujD8YcAfKUD4IwZpK6WVzuQPHevqmW5jTTWr0hQxYRwsV8s3N3p TvGyADipUSRrEi0Lxlf3zAjjEwh2fXlscHTP1DG1nLMc0wZ9L83ckSCHRuhos1+QRd +Qme4ghwstGDg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C6C7169218; Fri, 9 Jan 2026 16:13:26 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:26 -0700 Message-ID: <20260109231151.4056804-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VGUH2OWA5MLXO7ZIL4VQ2CHJBGJYVPFJ X-Message-ID-Hash: VGUH2OWA5MLXO7ZIL4VQ2CHJBGJYVPFJ 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/32] boot: pxe: Move FIT handling from label_process_fdt() to caller List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The label_process_fdt() function handles both FIT images (where the FDT is embedded in the FIT) and separate FDT files. Move the FIT detection to pxe_load_label() to simplify label_process_fdt() In the FIT case, the label's fdt field matches kernel_label, indicating the FDT comes from the FIT image rather than a separate file. When this is detected, use the fit_addr string (which includes the FIT configuration) directly as conf_fdt_str This allows label_process_fdt() to focus solely on loading separate FDT files. Rename it to label_load_fdt() to reflect this. Also move the log_debug() and scenario documentation to the caller where more context is available. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 83 ++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 93e00b6f97e..0e335cb2fdd 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -499,50 +499,31 @@ static int label_get_fdt_path(struct pxe_label *label, char **fdtfilep) return 0; } -/* - * label_process_fdt() - Process FDT for the label - * - * @ctx: PXE context - * @label: Label to process - * @kernel_addr: String containing kernel address - * @fdt_argp: bootm argument to fill in, for FDT - * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if FDT file could not be - * loaded - * - * fdt usage is optional: - * It handles the following scenarios. - * - * Scenario 1: If fdt_addr_r specified and "fdt" or "fdtdir" label is - * defined in pxe file, retrieve fdt blob from server. Pass fdt_addr_r to - * bootm, and adjust argc appropriately. - * - * If retrieve fails and no exact fdt blob is specified in pxe file with - * "fdt" label, try Scenario 2. +/** + * label_load_fdt() - Load FDT file for the label * - * Scenario 2: If there is an fdt_addr specified, pass it along to - * bootm, and adjust argc appropriately. + * If "fdt" or "fdtdir" is defined in the pxe file, retrieve the FDT blob + * from the server. This is only called when fdt_addr_r is set in the + * environment. * - * Scenario 3: If there is an fdtcontroladdr specified, pass it along to - * bootm, and adjust argc appropriately, unless the image type is fitImage. + * If retrieval fails and an exact FDT file is specified with "fdt", an + * error is returned. If "fdtdir" is used and retrieval fails, this returns + * success and allows the caller to use fallback options. * - * Scenario 4: fdt blob is not available. + * @ctx: PXE context + * @label: Label to process + * @fdt_argp: Updated to NULL if FDT retrieval fails + * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if FDT file specified + * by "fdt" label could not be loaded */ -static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, - char *kernel_addr, const char **fdt_argp) +static int label_load_fdt(struct pxe_context *ctx, struct pxe_label *label, + const char **fdt_argp) { char *fdtfile; int ret; - log_debug("label '%s' kernel_addr '%s' label->fdt '%s' fdtdir '%s' " - "kernel_label '%s' fdt_argp '%s'\n", - label->name, kernel_addr, label->fdt, label->fdtdir, - label->kernel_label, *fdt_argp); - - /* For FIT, the label can be identical to kernel one */ - if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { - *fdt_argp = kernel_addr; /* if fdt label is defined then get fdt from server */ - } else if (*fdt_argp) { + if (*fdt_argp) { ret = label_get_fdt_path(label, &fdtfile); if (ret) return ret; @@ -769,11 +750,37 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) return -ENOSPC; } + /* + * FDT handling has several scenarios: + * + * 1. FIT image with embedded FDT: label->fdt matches kernel_label, + * use the FIT address so bootm extracts the FDT from the FIT + * + * 2. Separate FDT file: if fdt_addr_r is set and "fdt" or "fdtdir" + * is specified, load the FDT from the server + * + * 3. Fallback to fdt_addr env var if set + * + * 4. Fallback to fdtcontroladdr for non-FIT images + * + * 5. No FDT available + */ conf_fdt_str = env_get("fdt_addr_r"); - ret = label_process_fdt(ctx, label, fit_addr, &conf_fdt_str); - if (ret) - return ret; + log_debug("label '%s' kernel_addr '%s' label->fdt '%s' fdtdir '%s' kernel_label '%s' fdt_argp '%s'\n", + label->name, fit_addr, label->fdt, label->fdtdir, + label->kernel_label, conf_fdt_str); + + /* Scenario 1: FIT with embedded FDT */ + if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { + conf_fdt_str = fit_addr; + } else { + /* Scenario 2: load FDT file if fdt_addr_r is set */ + ret = label_load_fdt(ctx, label, &conf_fdt_str); + if (ret) + return ret; + } + /* Scenarios 3 and 4: fallback options */ if (!conf_fdt_str) conf_fdt_str = pxe_get_fdt_fallback(label, ctx->kern_addr); if (conf_fdt_str) From patchwork Fri Jan 9 23:11:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1414 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=1768000419; bh=7AdBBWFuB88mXPkMhxikE/BkeNTmK5+0CrST18/OTB8=; 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=sE+t/XUlk+MOYnd2WDeRgwJRJeg0HpBkpkq51Ns04pUuxqYmPJ9BSUMezVtip3rcY OoH9Z7XSguEVVsF5qh3oM9yc7569fZmTBGTctLJNExkcwp5zi8pNuSoKL6bbNqgKR6 GgZhqSdxtU6tMcZlFnmBSpV6OFdRkN66YEDFHTn50H9pqg+b2fwjYUrDWvAMR8rhwl y53rW4+TXBlwFEmqerxWjXlstbD3eoRbpZJGsNkw8M464Wd3OCs5CzjmtEOmiIdN9O psdg8mlysSQZJ05eyKpdC7KOyrhUMw1pZTtvA7Wj4+DbppY+aDcmf7+tKaOLkMcP1U rv6yePuw0huIw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B22E269240 for ; Fri, 9 Jan 2026 16:13: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 gpR8_5eCu4aZ for ; Fri, 9 Jan 2026 16:13:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000419; bh=7AdBBWFuB88mXPkMhxikE/BkeNTmK5+0CrST18/OTB8=; 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=sE+t/XUlk+MOYnd2WDeRgwJRJeg0HpBkpkq51Ns04pUuxqYmPJ9BSUMezVtip3rcY OoH9Z7XSguEVVsF5qh3oM9yc7569fZmTBGTctLJNExkcwp5zi8pNuSoKL6bbNqgKR6 GgZhqSdxtU6tMcZlFnmBSpV6OFdRkN66YEDFHTn50H9pqg+b2fwjYUrDWvAMR8rhwl y53rW4+TXBlwFEmqerxWjXlstbD3eoRbpZJGsNkw8M464Wd3OCs5CzjmtEOmiIdN9O psdg8mlysSQZJ05eyKpdC7KOyrhUMw1pZTtvA7Wj4+DbppY+aDcmf7+tKaOLkMcP1U rv6yePuw0huIw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8B0A969218 for ; Fri, 9 Jan 2026 16:13:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000416; bh=fujWWgBopStXkPRLlw/FW0M6SJDn5Tb4Q1ZmmVloRhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K6h6+hj2eh6AdaKeOOyl237BybFHtUFLMr5GK64I5kCs3p9x5zJqaAYMLZ6ka0zkr FQR8ZpRLSJh6+K/nInN0+BkKmwuqksYgmiMjF57uiuetZRpaFYfQwFIkkNw8irlfuz 6hcdFLxTwQPkJYQJOpWtnuz8sTV7o5Psw3GQZoDHcicDwljlyYWm60oxd0OF1QRh3t CtFl/DXOoGkf1bC8YMa4szeTNqiC672KQrjr72bbSaJwo2WZzSiIs8BJCKIPPaEi8Q KvVFHmd/O5RpGPZVvjcouTPv4hs3nS+h2GSUGand8VcFj4niG0pD4IKyqlDor5GrSR FKn2tg60V7JPw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6B33769218; Fri, 9 Jan 2026 16:13: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 10026) with ESMTP id xuSwlElyr1ZE; Fri, 9 Jan 2026 16:13:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000412; bh=NPnduS7H9Xr2jj22Z7Aov4QtloLGj5Nuw8s4EHzFRBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqrUPROfyB1NsZYmt//dokJAccDID5RT4PD8i4Zfyh107Wmi5crDqcNcTTAVQjWWI ne484rXA1dsu3LocU0wW5H9lDMOZKSurSNWVbl42nWvb+heD8LAwYEjHQs/p22GtWo +tk62Se2qRL0qKWSd2nwR082WxXX4oiaJtjWY6f6VgJB0hHp2bi0mXfa+VmuKZ/9Rs gCmELjjSFdQxQQUnUGJQ9OecPLL5FjdrItAjxtuvlCHJ+FrAyQauw6dzp5fiIOi7t8 OnEHmdc6rSSDpNQqPmK0vfNt7sj/p6K0KMlfoYCiJVnnITduowbArtjxcBUbvPfacK ocGi7Vkn9/Bcg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A190E6923D; Fri, 9 Jan 2026 16:13:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:27 -0700 Message-ID: <20260109231151.4056804-19-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: K6CWHJUF6EZ3WQ4VKY6Y72WXKDB7OPNJ X-Message-ID-Hash: K6CWHJUF6EZ3WQ4VKY6Y72WXKDB7OPNJ 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/32] boot: pxe: Move fdt_addr_r check to caller of label_load_fdt() 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 Move the check for whether fdt_addr_r is set from label_load_fdt() to the caller. This simplifies the function and makes the control flow clearer - the function is now only called when there's an FDT address to load to. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 73 +++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 0e335cb2fdd..f6ad3f905b9 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -503,8 +503,7 @@ static int label_get_fdt_path(struct pxe_label *label, char **fdtfilep) * label_load_fdt() - Load FDT file for the label * * If "fdt" or "fdtdir" is defined in the pxe file, retrieve the FDT blob - * from the server. This is only called when fdt_addr_r is set in the - * environment. + * from the server. * * If retrieval fails and an exact FDT file is specified with "fdt", an * error is returned. If "fdtdir" is used and retrieval fails, this returns @@ -512,7 +511,7 @@ static int label_get_fdt_path(struct pxe_label *label, char **fdtfilep) * * @ctx: PXE context * @label: Label to process - * @fdt_argp: Updated to NULL if FDT retrieval fails + * @fdt_argp: Updated to NULL if FDT retrieval fails or no FDT is specified * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if FDT file specified * by "fdt" label could not be loaded */ @@ -520,56 +519,48 @@ static int label_load_fdt(struct pxe_context *ctx, struct pxe_label *label, const char **fdt_argp) { char *fdtfile; + ulong addr; int ret; - /* if fdt label is defined then get fdt from server */ - if (*fdt_argp) { - ret = label_get_fdt_path(label, &fdtfile); - if (ret) - return ret; + ret = label_get_fdt_path(label, &fdtfile); + if (ret) + return ret; - if (fdtfile) { - ulong addr; - int err; + if (fdtfile) { + ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, + (enum bootflow_img_t)IH_TYPE_FLATDT, + &addr, NULL); - err = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", - SZ_4K, - (enum bootflow_img_t)IH_TYPE_FLATDT, - &addr, NULL); - - free(fdtfile); - if (err < 0) { - *fdt_argp = NULL; - - if (label->fdt) { - printf("Skipping %s for failure retrieving FDT\n", - label->name); - return -ENOENT; - } - - if (label->fdtdir) { - printf("Skipping fdtdir %s for failure retrieving dts\n", - label->fdtdir); - } - } else { - ctx->fdt = map_sysmem(addr, 0); + free(fdtfile); + if (ret < 0) { + *fdt_argp = NULL; - if (label->kaslrseed) - label_boot_kaslrseed(ctx); + if (label->fdt) { + printf("Skipping %s for failure retrieving FDT\n", + label->name); + return -ENOENT; + } -#ifdef CONFIG_OF_LIBFDT_OVERLAY - if (label->fdtoverlays) - label_boot_fdtoverlay(ctx, label); -#endif + if (label->fdtdir) { + printf("Skipping fdtdir %s for failure retrieving dts\n", + label->fdtdir); } } else { - *fdt_argp = NULL; + ctx->fdt = map_sysmem(addr, 0); + + if (label->kaslrseed) + label_boot_kaslrseed(ctx); + + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && + label->fdtoverlays) + label_boot_fdtoverlay(ctx, label); } + } else { + *fdt_argp = NULL; } return 0; } - /** * label_run_boot() - Set up the FDT and call the appropriate bootm/z/i command * @@ -773,7 +764,7 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) /* Scenario 1: FIT with embedded FDT */ if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { conf_fdt_str = fit_addr; - } else { + } else if (conf_fdt_str) { /* Scenario 2: load FDT file if fdt_addr_r is set */ ret = label_load_fdt(ctx, label, &conf_fdt_str); if (ret) From patchwork Fri Jan 9 23:11:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1415 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=1768000426; bh=cjCaFHW3SHC7DNbPxfqMUzuC5qMa6dozq1LcMDvVzUM=; 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=SH3Jy39Lc99oN+q0PhUGJZGqiN+2iJUQb6RcoBpnlP+/8u1F/JA4zbFpq51Q4gC1W uQ5jI5wHnyeLBckUf3+L27OSAgQCFBMptKDH/OFLgkEm75jl9SG2xqVd1kAmttGL2q ZLhAGOISZ+BBY8TmgVNq8HQ6x+qzU54eiL2MZQv+PuYeuLKKZHgfBU4Zpgwi6P6eQo RzkA90qkBAlXaTag3bhW7mq8yUKZvTpTfOSmO1b3h5S2KaGoHLeRvXVGZdKY52OdQ9 vZ0vzn3pJZqwxXQXxhbd5Qdu151RMj4jhfTWUMbRAoBvSnmC1Zuf+e4/lQ8DtyKsdG pIUNJdzzWvSgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 68B6F69243 for ; Fri, 9 Jan 2026 16:13: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 IbD3ANpLmSo0 for ; Fri, 9 Jan 2026 16:13:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000426; bh=cjCaFHW3SHC7DNbPxfqMUzuC5qMa6dozq1LcMDvVzUM=; 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=SH3Jy39Lc99oN+q0PhUGJZGqiN+2iJUQb6RcoBpnlP+/8u1F/JA4zbFpq51Q4gC1W uQ5jI5wHnyeLBckUf3+L27OSAgQCFBMptKDH/OFLgkEm75jl9SG2xqVd1kAmttGL2q ZLhAGOISZ+BBY8TmgVNq8HQ6x+qzU54eiL2MZQv+PuYeuLKKZHgfBU4Zpgwi6P6eQo RzkA90qkBAlXaTag3bhW7mq8yUKZvTpTfOSmO1b3h5S2KaGoHLeRvXVGZdKY52OdQ9 vZ0vzn3pJZqwxXQXxhbd5Qdu151RMj4jhfTWUMbRAoBvSnmC1Zuf+e4/lQ8DtyKsdG pIUNJdzzWvSgA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 39A7869240 for ; Fri, 9 Jan 2026 16:13:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000422; bh=GXzhIt9/yeOqjJ2Svo53PxTNeK/w6erZ20i/lhTqvLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ME26Y45qwfZWuc5dc2+oNypXHLgeE9I37DgT0K+EVWmuw/ABwNCvyf6kDalS+NWcs Ul+P3re2TKZTlgzEacMUqC3ea9Ujki688HZkTk71uOo7j8OFJ+Dmqw2AThSCNQeu2R tbj81jwHx1fR+nFWVbo0qcx+6mxYMa6w2bNtypfk4k/JDXD5sllGqjHoLxI1hIYC9k tR/qjGMNeQI4D9IaPitAyCUhGdjJIb9KZKWoxwRMyO8XspF3r45bzC8Ks8cfnJLqG1 tgSAne9WAufp3zhTbzArc77FrXsZ8nAaDfZ2N146DRDE0UoWjXm0+kob3uyhCQ6GsR uSKYu630fKTvQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 54DFF6924E; Fri, 9 Jan 2026 16:13: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 10026) with ESMTP id 9fvmGmnPsEir; Fri, 9 Jan 2026 16:13:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000416; bh=twTe9hLdc4FS8tAiJ+Vpr+jknq71YgSdat1dyzaqdZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eENml8s0iKVBFiduz10RU997354++1mH3gs4+yN4v875/QiSpPZTYi5o/KJaAVJ7k 4XGePZFUt+oJLqF+W+7CktyHa5oZzJdORKRI5vJV8yHWdiM9Xb0M3hVOeKM+3pQ7LE 5ASBr44ZX00SYWx2ntMl6uwKtToRBkRE3lw/NyzTMmSs1tJJIUSgCHlVOb3VYQBi0Z eHAXjjgRm5d0l4rnxLAp8JpUUGKy2C3L35uhy+EhHTVuW+NuTHpBi8zCWXLRngrau3 Ucdw0oPLERoYwUWTa3UcpBPWpOv9tw7wJ1NQOq155eqUDaew+ZvKCB3HFMkYnHUuvD J6eNSts1WI0LA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6CC8769243; Fri, 9 Jan 2026 16:13:36 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:28 -0700 Message-ID: <20260109231151.4056804-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6QT6QBOYBZ6BIDS7A4XJDACSSUEJTBGY X-Message-ID-Hash: 6QT6QBOYBZ6BIDS7A4XJDACSSUEJTBGY 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/32] boot: pxe: Use early return in label_load_fdt() 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 Return early if no FDT file is specified, rather than using an else branch. This flattens the code and makes the control flow clearer. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 54 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index f6ad3f905b9..c0ef524f3f1 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -526,39 +526,39 @@ static int label_load_fdt(struct pxe_context *ctx, struct pxe_label *label, if (ret) return ret; - if (fdtfile) { - ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, - (enum bootflow_img_t)IH_TYPE_FLATDT, - &addr, NULL); - - free(fdtfile); - if (ret < 0) { - *fdt_argp = NULL; - - if (label->fdt) { - printf("Skipping %s for failure retrieving FDT\n", - label->name); - return -ENOENT; - } + if (!fdtfile) { + *fdt_argp = NULL; + return 0; + } - if (label->fdtdir) { - printf("Skipping fdtdir %s for failure retrieving dts\n", - label->fdtdir); - } - } else { - ctx->fdt = map_sysmem(addr, 0); + ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, + (enum bootflow_img_t)IH_TYPE_FLATDT, + &addr, NULL); + free(fdtfile); + if (ret < 0) { + *fdt_argp = NULL; - if (label->kaslrseed) - label_boot_kaslrseed(ctx); + if (label->fdt) { + printf("Skipping %s for failure retrieving FDT\n", + label->name); + return -ENOENT; + } - if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && - label->fdtoverlays) - label_boot_fdtoverlay(ctx, label); + if (label->fdtdir) { + printf("Skipping fdtdir %s for failure retrieving dts\n", + label->fdtdir); } - } else { - *fdt_argp = NULL; + return 0; } + ctx->fdt = map_sysmem(addr, 0); + + if (label->kaslrseed) + label_boot_kaslrseed(ctx); + + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->fdtoverlays) + label_boot_fdtoverlay(ctx, label); + return 0; } /** From patchwork Fri Jan 9 23:11:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1416 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=1768000429; bh=h3RMWHVJz4mLJZeWvc+HRsO4wqmKnmFbs0HKdjQQ+Sk=; 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=rvT8Rs0shqi9cc45m5g4fYcgh7dJdRVeVLHgaix4pjaf7t98itYD1evgolfc2KId6 +PDICTzxYFw5vXvc91VBWgUzeoFqpH3+Hl1CLGDhPGWCoraLiYhS4ZIYUO7crL4vpA GI3501rPFsTNV7bXk4vWthzpCd7KU+SEkaTJgaGzOWrhgDgMzZjNnm8qWHUGpfBqsJ Ht3HsJt0rJPytymL1XAMh2il2ZSVQi62bnRNxzXISVOWNs8D1k0mZ8/1oALeQCpA43 6MFDxtipkpdxaezMZTlrj0i1biXZINbGQmbMnoCJ7B4ZZe6vXai/6VORgq7Wa6GLp2 tSF1My5P/jB6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6648E69221 for ; Fri, 9 Jan 2026 16:13:49 -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 IF5moTGRTvLQ for ; Fri, 9 Jan 2026 16:13:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000427; bh=h3RMWHVJz4mLJZeWvc+HRsO4wqmKnmFbs0HKdjQQ+Sk=; 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=i8NKf2i/4EMnMP60T8dqIOvOymOekGbpaFQwNboNrR9MQY3H0m4XgCswj57+iS3/k vOAY/SCoU9Wdl+hzrTwmqj+m1kXLNLlsUZph9z11vcLUlnpJQ8IC4T01sZva9OT42X pV8wy6W224CCzyoh9Lk84RQRJtmsG1xJ344XfqXQ51e874+QAByS7qn6rIQDJO+P58 fX3e7CXEj5Kroq8gdtQCUWL7hWnyyMtzzQovZgG0r2qqMyjcdIgtGeszEAyOivp0vm hFqvnStsIsqZZNmvcWXVnedJgBS9Jsu1hLbASv7mrPkH031ikat61veRPIs8SHDLuY FRAwQHImHcO9Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 85EFF6924E for ; Fri, 9 Jan 2026 16:13:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000425; bh=KTjZ6WHKKM022uNin3DFJ0hBnvsbQkRPXnnZvfrsr7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IOsRmguqAUPQnep7PGzBzzsFeA6ERWVp2IoaKQmwExtlKRZDWQT+FztWvqG4ygyfQ gleMsFYz+eMi6oaIqLLffnRKmHuOU8MLYOFwGzSBHUBZXJZ+lWyjT4k8QbysMkgGon Fu/cRzowwiXBuZ+b6l6Vt+XBBJs5+oN5AmL64h0bW+Gu+jJdvzTFPJcfyUh8KKleQ/ CTnkIK6Z7cE+OnveEXKj3cQpWPS3exMx9qyQ0qi+XZ5+dJ2c0MX06EZH1498E28e1u 7jKTS3CZyVVYPy9HxTgBMFIUWz5F+fnq6ccyudCH532wxPd6OZA7kmhh5qB02MTaq0 sbZvf4zWKrJ4g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E3BEE5FF82; Fri, 9 Jan 2026 16:13:45 -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 8Qa8DyrptcLJ; Fri, 9 Jan 2026 16:13:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000421; bh=07TDSKNTopUxnGTQsl/fNBNswXYSt7TWUO7gEzgTGNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W65oVvLPsj19+ztZ5K4JE1W4SOCua7RwzYV9EK5aYNOyBKV9twBnFPl3pjmHNR8rm IU+zcs2oDwHE7HxRfrxl3Z/k00i4Yv3QnvsDqWokmeTCmYxqL3QMdI7sOG/rb2pBar dDwen9N86t8d93QhB9KoUGGT1rPvF6fVhDQlLRO8WdxD/sTJIZxJarWsneQXwkVZ8Z zN8wjSzHwM2HH9y+2udcmDjSZOafyAZNdSnAyUPnI4+etad28pAv/X7X7Dng8Ml959 8eFGKme8GJtlGHkpJLVDcEHqEegUJPnrjIMDx+OYRqX2Mg7+5NkxEKkmFpZTm6mx34 jdBIpznI4vHKg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4583769218; Fri, 9 Jan 2026 16:13:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:29 -0700 Message-ID: <20260109231151.4056804-21-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IQBUBF2SKKVKESY6GCIUSINAFTFIQ7RY X-Message-ID-Hash: IQBUBF2SKKVKESY6GCIUSINAFTFIQ7RY 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/32] boot: pxe: Use ctx->fdt in label_boot_fdtoverlay() 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 ctx->fdt instead of re-mapping from the fdt_addr_r environment variable. Since ctx->fdt is set after loading the FDT, it is available for use by the overlay code. This avoids a crash when the FDT is loaded via LMB allocation without fdt_addr_r being set, and removes the dependency on the global working_fdt variable. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index c0ef524f3f1..05102914717 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -308,16 +308,11 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, struct pxe_label *label) { char *fdtoverlay = label->fdtoverlays; - struct fdt_header *working_fdt; char *fdtoverlay_addr_env; ulong fdtoverlay_addr; - ulong fdt_addr; int err; - /* Get the main fdt and map it */ - fdt_addr = hextoul(env_get("fdt_addr_r"), NULL); - working_fdt = map_sysmem(fdt_addr, 0); - err = fdt_check_header(working_fdt); + err = fdt_check_header(ctx->fdt); if (err) return; @@ -366,7 +361,7 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, } /* Resize main fdt */ - fdt_shrink_to_minimum(working_fdt, 8192); + fdt_shrink_to_minimum(ctx->fdt, 8192); blob = map_sysmem(fdtoverlay_addr, 0); err = fdt_check_header(blob); @@ -376,7 +371,7 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, goto skip_overlay; } - err = fdt_overlay_apply_verbose(working_fdt, blob); + err = fdt_overlay_apply_verbose(ctx->fdt, blob); if (err) { printf("Failed to apply overlay %s, skipping\n", overlayfile); From patchwork Fri Jan 9 23:11:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1417 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=1768000434; bh=3Ns4hgzgDOEbrKZDujaNTfZjbPaN80ukxfxYmB6jsu0=; 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=Uf84HGitGtSq3apvuuGeMw1pS1tkONdEO++IfxIgUEgxqv+crw1MTlM74OT9oHffA eegVYTw7hvUGe+Lc0aoijb7Vu3bv/uDjIv60OMy4wbvu002sMkjsavsTj0nz/3MnOR 46/Z66RoMhGXE3I+Hwc252QTuH8HjZRc4tG/AEylTMTxRQzXORnO/oHLxLV3JWAIfv RA5gT6OHfeEn6fWkNlp5gOfV5eCzVZcVWqTco/s6mgyZ1qPMfJ5rxW5M2l+BIpR13i 6uaELSTn7z2b2Id9iwv6nhBIbm7+x/PL8h1EmZ0ZUxKz5mitFB0ME4sJSHjTD3ccj8 Yk44s0FcFHvWw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 239D06925B for ; Fri, 9 Jan 2026 16:13:54 -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 pOIkxiSECPYD for ; Fri, 9 Jan 2026 16:13:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000431; bh=3Ns4hgzgDOEbrKZDujaNTfZjbPaN80ukxfxYmB6jsu0=; 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=lEIp+C+Q7F2A5bmDyHoCOe38OgTZ1cmAU5MjpwwxgmIUhYb25AAf5LLQjEoLIdF7N VXrZK7bYWZoCjcZ35Xff7prtC9O2oStpCHHq+23C/rzrKPMbAAhmU+e3Vwpia1ORwZ cGz9oz1Jq43SoRCQBRrrBTMH4/W90dUVajZVOpWYIJs6+rKGNnymdBNTPHDw89IGWl u1G7JIjGoe8jCehU6NRJ4AIswHelDwcI+6GPEDtF2+FTGpkyKw7apUAtUxZrXDzYwL Uk2TcgAdY57W/fe6U9e+n4RJS5XZeQjK4DHVJuApBtBoFqVaEbzR4JGW4/w/YCPNKQ /MfOYHTxkScPw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 46DD569221 for ; Fri, 9 Jan 2026 16:13:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000429; bh=v6wvp2vxmvXAsvYEAC8GajVyBrRRIJSP4z5Nf9WB1cw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qm1hpJZKtamSNqsPz60G3t9w2mqaI1Iy0qih8Xa0Q0xuVSS3QSX6Pl1gY1BKls4Rn pFbH7drBEQJdgCLbUZmQbSBuq/DNhKepEtZ/N/vDxKo7jo5VGKVrJECnMe6JF8Z/Lr Jcj59zCrnePIQ6tEWcHSUAnsPPx1X5dqlkbJ+XJu1GwEfVMgEwN+mUOH4nfCNuagIz EhAg1GrqLJ735+vr3V8v0km8y73rsuaozlOit2wkni7KG1Cd5hTkfc2kbzQsIpARzz 0pHMYqIuJU3qN6xOyh5/DdXy4r9tmm3yZAakvmcn6xOV595pGpcLnJZy/fVHxsKRte 8JloSAzU8ccJQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1AE3369249; Fri, 9 Jan 2026 16:13:49 -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 KaWep8fPRLgf; Fri, 9 Jan 2026 16:13:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000426; bh=sL5Ag6DqXn0ylXqnKTXJ123ZjT+7l1oOCRmmTkzW9TQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mVl8/tc5bIR+TkSWQAketeZh3R5b04WpaQevoCgGpShUkdrt4ssgmAYXcnx5N8HUH BLxFYjSJFyCb6ILDeFMokM0+I/zaFHSIk5eK0XOg0wciSKWJJqPhPdANYgsWWxQW98 G3PVNSH2HZwx73ykV+ceDBx7hoIkTobZjtzaNT21G+0SMUzhT03ED+xPI5ApXHYQfL MZMl5g3tbFo45accmKUgC+AKcNf1uHIDKf7WlqSwz2F24JW6XYSDjOGJFBZ8NqByDu dDlj2sEpbQDWOVeSn/j1dBUs2UEQnH5CRQp6lTOnLYqi4ZW8WRHDtujoYvhpy1za18 vcu2+acmDRCyQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 42DFD69221; Fri, 9 Jan 2026 16:13:46 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:30 -0700 Message-ID: <20260109231151.4056804-22-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FXBAO3LLER7IJUAPM2JX4N6F5EHIVQXP X-Message-ID-Hash: FXBAO3LLER7IJUAPM2JX4N6F5EHIVQXP 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/32] boot: pxe: Move label_get_fdt_path() call to pxe_load_label() 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 Move the FDT path lookup from label_process_fdt() to pxe_load_label(), calling it early just after determining if this is a FIT boot. This groups related path-resolution logic together in the caller. Update label_process_fdt() to take the fdtfile as a parameter instead of calling label_get_fdt_path() internally. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 05102914717..4cb14783c77 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -506,33 +506,24 @@ static int label_get_fdt_path(struct pxe_label *label, char **fdtfilep) * * @ctx: PXE context * @label: Label to process - * @fdt_argp: Updated to NULL if FDT retrieval fails or no FDT is specified + * @fdtfile: FDT file path to load (freed by this function), or NULL * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if FDT file specified * by "fdt" label could not be loaded */ static int label_load_fdt(struct pxe_context *ctx, struct pxe_label *label, - const char **fdt_argp) + char *fdtfile) { - char *fdtfile; ulong addr; int ret; - ret = label_get_fdt_path(label, &fdtfile); - if (ret) - return ret; - - if (!fdtfile) { - *fdt_argp = NULL; + if (!fdtfile) return 0; - } ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, (enum bootflow_img_t)IH_TYPE_FLATDT, &addr, NULL); free(fdtfile); if (ret < 0) { - *fdt_argp = NULL; - if (label->fdt) { printf("Skipping %s for failure retrieving FDT\n", label->name); @@ -704,6 +695,8 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) const char *conf_fdt_str; ulong conf_fdt = 0; char initrd_str[28] = ""; + char *fdtfile = NULL; + bool is_fit; int ret; if (label->localboot) { @@ -719,9 +712,21 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) return 0; } + /* Check for FIT case: FDT comes from FIT image, not a separate file */ + is_fit = label->fdt && label->kernel_label && + !strcmp(label->kernel_label, label->fdt); + + if (!is_fit) { + ret = label_get_fdt_path(label, &fdtfile); + if (ret) + return ret; + } + ret = pxe_load_files(ctx, label); - if (ret) + if (ret) { + free(fdtfile); return ret; + } /* for FIT, append the configuration identifier */ snprintf(fit_addr, sizeof(fit_addr), "%lx%s", ctx->kern_addr, @@ -757,13 +762,17 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) label->kernel_label, conf_fdt_str); /* Scenario 1: FIT with embedded FDT */ - if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { + if (is_fit) { conf_fdt_str = fit_addr; - } else if (conf_fdt_str) { + } else if (fdtfile) { /* Scenario 2: load FDT file if fdt_addr_r is set */ - ret = label_load_fdt(ctx, label, &conf_fdt_str); + ret = label_load_fdt(ctx, label, fdtfile); if (ret) return ret; + conf_fdt_str = env_get("fdt_addr_r"); + } else { + /* No FDT specified, use fallback */ + conf_fdt_str = NULL; } /* Scenarios 3 and 4: fallback options */ From patchwork Fri Jan 9 23:11:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1418 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=1768000434; bh=f1K5W67DZPnuVF/vqnsHKn84ajkuPNVtHx/0OEzLyao=; 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=uYguaKenCycHmibdQ8+0isa5urdzzuUfnpYVflWcFdXlNzubKUHbq/Xv6bRAbMkDm nXGVciK14eqrkibozGKkZH+e/8XCRPk9xmiO2oDtq4T+dFgDKZOcUxTz+zD6YebQ1u 7kGqlAztnztExRGkMIm/30zGAL6TIB/pSaesBrP6GkU4aTizRrfk0pLn+Jwdl7lSAl TKe3vMvQYtlll3sA6VHz3D69SLfyGBsJNJBpvTR4OOhNt4HAubGb40G9E6i2zboezn X+TggK2qb+QaQmdS3rzWHl+j+pJdDQcPV3VfqulbBWb5YRiCz18PjMcl4ebVNTdDlr 8FhqeGI01wrhA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7E8C469240 for ; Fri, 9 Jan 2026 16:13:54 -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 Mgak94PXVKcj for ; Fri, 9 Jan 2026 16:13:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000433; bh=f1K5W67DZPnuVF/vqnsHKn84ajkuPNVtHx/0OEzLyao=; 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=ozSMzbR9OyPf9HrjTzWtvcEL5JJfzkftkuNTeIDyQQIEck1+TyhyYXyjlMhc3SkKq Ohd7G6WG1VyYGf4H+vl8tEUqHN4pIh1SrQzN+uqoX8y5hQqrkWEW3e7kQ4iF4ns6jJ ZeYof6j/gqqfjDjUXhllE0MWOx4eyXgQSYBlq0lDq9Yo1/m7tf29e4ybKR1iGZHo/c 6dsTzSNZZtyrUFdC6nLs0f1kM8P9ugygXdV4TNm/5h+5rOUULGHBn0i8ygHUje6v5Y kSr3KhOZGITSuEB5GUijlCLciGkQGPAuBcidTYDQZGacOfgjWU9siHOpfJp6H5G59W pDIokLYjbhS4g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE14569256 for ; Fri, 9 Jan 2026 16:13:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000432; bh=hJweX+nNJctpsmluFNBhGSvID7Kbn3cOkhOTnRoOV2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VVHoRhlxfZi5XAwhxa0rXWkLXfpMp6krtcxtvCFgaqeHyqx8JY1kWDfkR6EsREBhQ vx5XH1EvqaB7eMrXcBAyQ/WPAQoo6Tk/Pzkc44daELVRv2WE+fMhBesBn01gQaoba7 2c8hnenfN+M9d0Fok8QfkArWYQZzZPW/Cap3Ujh+CTjZiJ6N8nzrxjvAssLV0vL5Rj Wn+MBTSaDH0Y6QpFmKfpjXpz0MZYvKjdchpNtj3jLrhucREsP5jXJ2e3BwmMT1nYGR VXUiYqdx9837nqc9brZeBrWh9tvLsgwcAi1LVSUcXHp91oVal25/vRJReW7LLykelh yJ1qcqyr7CVDA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0C7B369252; Fri, 9 Jan 2026 16:13:52 -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 SR0UIJ9_q8if; Fri, 9 Jan 2026 16:13:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000428; bh=adLyHAp/YC35UaTBV2+Fui/ICs/HYc8WedyT3P/aLqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WYP4eXnHl6+2NTPh3Esw9z/KlkINJQ7CNrl4q3DMl6zfabAkeud9ZvypSIUMmJ2x5 vSf6thSlR59FyRw/Hi7IADhQziVVe4pj/x96SlcG5qgsVM3+GeV0ZKYr6tepRCB0lv gIny9/xj9u0MtwDCkwl19EHHs+Z56QxpKgRKehbgVtU8D9rMjct5x2WSKTGsY16y/L o3H+3RhfjYsiboKS3zzP2i7lid/Fiva8gjGSlMXIZ603LlL6jfQDRWr7rVnnyVk/Hu aYyROJkRcD+HWxEkJnbca2RSlbjmOCeeMqPftOOHiWHtFu4Xbk2NRxS9VJX3iQzD3q pYtSBvAJuqA6Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BC29769254; Fri, 9 Jan 2026 16:13:47 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:31 -0700 Message-ID: <20260109231151.4056804-23-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ITHOIKVE6OPGRI2KXGR4JSR6ZQMUKSHF X-Message-ID-Hash: ITHOIKVE6OPGRI2KXGR4JSR6ZQMUKSHF 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/32] boot: pxe: Load FDT files in pxe_load_files() 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 Move the FDT file loading to pxe_load_files() so all file loading is in one place. Add fdtfile parameter to pxe_load_files() and store the loaded FDT address in ctx->fdt_addr This simplifies label_process_fdt() to just do post-processing: setting the working FDT address, handling kaslrseed, and applying overlays. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 76 ++++++++++++++++++++------------------------- include/pxe_utils.h | 2 ++ 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 4cb14783c77..2b1fe45c86d 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -495,49 +495,21 @@ static int label_get_fdt_path(struct pxe_label *label, char **fdtfilep) } /** - * label_load_fdt() - Load FDT file for the label + * label_process_fdt() - Process FDT after loading * - * If "fdt" or "fdtdir" is defined in the pxe file, retrieve the FDT blob - * from the server. - * - * If retrieval fails and an exact FDT file is specified with "fdt", an - * error is returned. If "fdtdir" is used and retrieval fails, this returns - * success and allows the caller to use fallback options. + * Set the working FDT address, handle kaslrseed, and apply overlays. + * The FDT must already be loaded (ctx->fdt_addr set by pxe_load_files()). * * @ctx: PXE context * @label: Label to process - * @fdtfile: FDT file path to load (freed by this function), or NULL - * Return: 0 if OK, -ENOMEM if out of memory, -ENOENT if FDT file specified - * by "fdt" label could not be loaded + * Return: 0 if OK */ -static int label_load_fdt(struct pxe_context *ctx, struct pxe_label *label, - char *fdtfile) +static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label) { - ulong addr; - int ret; - - if (!fdtfile) + if (!ctx->fdt_addr) return 0; - ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, - (enum bootflow_img_t)IH_TYPE_FLATDT, - &addr, NULL); - free(fdtfile); - if (ret < 0) { - if (label->fdt) { - printf("Skipping %s for failure retrieving FDT\n", - label->name); - return -ENOENT; - } - - if (label->fdtdir) { - printf("Skipping fdtdir %s for failure retrieving dts\n", - label->fdtdir); - } - return 0; - } - - ctx->fdt = map_sysmem(addr, 0); + ctx->fdt = map_sysmem(ctx->fdt_addr, 0); if (label->kaslrseed) label_boot_kaslrseed(ctx); @@ -654,7 +626,8 @@ static int generate_localboot(struct pxe_label *label) return 0; } -static int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label) +static int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, + char *fdtfile) { int ret; @@ -686,6 +659,25 @@ static int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label) } } + if (fdtfile) { + ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, + (enum bootflow_img_t)IH_TYPE_FLATDT, + &ctx->fdt_addr, NULL); + free(fdtfile); + if (ret < 0) { + if (label->fdt) { + printf("Skipping %s for failure retrieving FDT\n", + label->name); + return -ENOENT; + } + + if (label->fdtdir) { + printf("Skipping fdtdir %s for failure retrieving dts\n", + label->fdtdir); + } + } + } + return 0; } @@ -722,11 +714,9 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) return ret; } - ret = pxe_load_files(ctx, label); - if (ret) { - free(fdtfile); + ret = pxe_load_files(ctx, label, fdtfile); + if (ret) return ret; - } /* for FIT, append the configuration identifier */ snprintf(fit_addr, sizeof(fit_addr), "%lx%s", ctx->kern_addr, @@ -764,9 +754,9 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) /* Scenario 1: FIT with embedded FDT */ if (is_fit) { conf_fdt_str = fit_addr; - } else if (fdtfile) { - /* Scenario 2: load FDT file if fdt_addr_r is set */ - ret = label_load_fdt(ctx, label, fdtfile); + } else if (ctx->fdt_addr) { + /* Scenario 2: FDT loaded by pxe_load_files(), do post-processing */ + ret = label_process_fdt(ctx, label); if (ret) return ret; conf_fdt_str = env_get("fdt_addr_r"); diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 9bca8d7868d..ec7f12cd7bf 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -150,6 +150,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * @initrd_addr: initaddr address (0 if none) * @initrd_size: initrd size (only used if @initrd_addr) * @initrd_str: initrd string to process (only used if @initrd_addr) + * @fdt_addr: FDT address from loaded file (0 if none) * @conf_fdt_str: FDT-address string * @conf_fdt: FDT address * @fdt: Working FDT pointer, for kaslrseed and overlay operations @@ -189,6 +190,7 @@ struct pxe_context { ulong initrd_addr; ulong initrd_size; char *initrd_str; + ulong fdt_addr; char *conf_fdt_str; ulong conf_fdt; void *fdt; /* working FDT pointer, for kaslrseed/overlays */ From patchwork Fri Jan 9 23:11:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1419 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=1768000434; bh=iP5p7INKoi9j591+e8tLzTfs7eS0gYBhh2qrV/6Bq90=; 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=O4WxowZIqfkxthG/Mgf+XuY3Yo6mas5kr2WiNYY99EOJ5V8ssnLfi3zlqHNSI0J4k c2dPs4Is9IT8iwFYgdgGdrL3P4yf7YPUEa8FG1ESeE2v6uM2mCPGbhRjwAYeFKJLwn I3Bee47fXkqdRfjqyBXjacMimc+hfMvv7dXdzupTbkKK9xL61ubJDbWXuO/AMIVgd8 fxMVMMpyxojucmTOUxVUmnS2zhU4Jvvit1blvgyyg4bgWZQCi1P0c3EaK8F/ZeNsXZ mK6ReYWirx+dMX6tpMx+F2hcsbCnYv+MRHeUspnVDnfBy+3UKgoz9tl0Je8mCVj0eX bOMxs8CylwZ2g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EF1A869258 for ; Fri, 9 Jan 2026 16:13:54 -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 YEkL_ZCLehLz for ; Fri, 9 Jan 2026 16:13:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000434; bh=iP5p7INKoi9j591+e8tLzTfs7eS0gYBhh2qrV/6Bq90=; 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=O4WxowZIqfkxthG/Mgf+XuY3Yo6mas5kr2WiNYY99EOJ5V8ssnLfi3zlqHNSI0J4k c2dPs4Is9IT8iwFYgdgGdrL3P4yf7YPUEa8FG1ESeE2v6uM2mCPGbhRjwAYeFKJLwn I3Bee47fXkqdRfjqyBXjacMimc+hfMvv7dXdzupTbkKK9xL61ubJDbWXuO/AMIVgd8 fxMVMMpyxojucmTOUxVUmnS2zhU4Jvvit1blvgyyg4bgWZQCi1P0c3EaK8F/ZeNsXZ mK6ReYWirx+dMX6tpMx+F2hcsbCnYv+MRHeUspnVDnfBy+3UKgoz9tl0Je8mCVj0eX bOMxs8CylwZ2g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B33B969243 for ; Fri, 9 Jan 2026 16:13:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000432; bh=P0JEZg1M/f/3anzJXUSstj3ize0NLBPbRmnZy0dDVVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XvDwMaTvD+jYjLSIBPB1DigfZ2n8yuDKBJZOLr7b+SpJ5w6nOwCtCSgwDMUUX/p3t tMMpFOhwPEz2qxxDNCqUUHmSHRl95kN81C2hRLdm9FG1i9x6YzPH5E4vIscAbBOkRE QV3avvwnHAn5D3NUXuS03fDgKjCo7qaFJuCHSLbQGMuBrNPuwajR/fJC+PavdeaPXk 3muPczXpWm/hb3+z+6b7OLqtmPUp2CLWS6M8YO1ZiyZ1Y37dhx5Mo0sFQe+1VyH7pB E+HJE0x+Bu6CBKm61/DyUq6a+oijKTNU4W1017B4EcTt0nCot1Sm1uOREJUxH/2dPv BlvJQzjlqf0ww== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0C78E69251; Fri, 9 Jan 2026 16:13:52 -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 LFCC2K2r1hDH; Fri, 9 Jan 2026 16:13:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000429; bh=24hOfhL4/s4bImaUcjyuLk7BaQXMwb67r1YV0rqrNpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P3XC3KViaPg7YUJjkjBWGZwHgwMoj1VplDsn7T6hvcNJifsI9S69eYSDx2smPNdni SwWt9O42R6ItDGTYUal2UUGHnSCh/W1m2uenYGRbnUyBl8DDbfRKOPgdhXK02GsgcD 5hTdZXzx7/bLk/gYoZiiXadR6uRW3ofM29EOSVKtEp660cED3vmVvZ19+WlR9bN13o OVK6ZB0H3xNH+hXeLVwP1i/ib8hB3j6f/VTPzfDiv7Mbp3OEdxx4rW8wd4Pg66B6F8 011c3BULn2+jpJDXsaVax8lEtnzM+HxQZcooE3Wgk30CCkg3MEWwubInDMT9Eiivqk W5l1xK9KAwILg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F1EC469258; Fri, 9 Jan 2026 16:13:48 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:32 -0700 Message-ID: <20260109231151.4056804-24-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EBRFR6JVYQSVAFBILTBRSHB7LYGF2POI X-Message-ID-Hash: EBRFR6JVYQSVAFBILTBRSHB7LYGF2POI 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/32] boot: pxe: Use IS_ENABLED() for CONFIG_OF_LIBFDT_OVERLAY 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 Replace #ifdef CONFIG_OF_LIBFDT_OVERLAY with IS_ENABLED() to allow the compiler to check the code even when the option is disabled. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 2b1fe45c86d..2084bb3e9bf 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -303,7 +303,6 @@ static void label_boot_kaslrseed(struct pxe_context *ctx) * @ctx: PXE context * @label: Label to process */ -#ifdef CONFIG_OF_LIBFDT_OVERLAY static void label_boot_fdtoverlay(struct pxe_context *ctx, struct pxe_label *label) { @@ -383,7 +382,6 @@ skip_overlay: free(overlayfile); } while ((fdtoverlay = strstr(fdtoverlay, " "))); } -#endif const char *pxe_get_fdt_fallback(struct pxe_label *label, ulong kern_addr) { From patchwork Fri Jan 9 23:11: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: 1420 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=1768000439; bh=PqIR3Q+1mkgm1dW17yMN2f68KiBEnceqgKc84LBGNMU=; 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=o1HaLYsCQkSXcSmwSBPZwEvP8zz1u6PObcr/VY65axK0kPQgAFgMRbUw1VVa4/UQs 8C1SHtpcDKcwzLbsAmtVXHo4o0+X9Z0ZUNXS4xx4gSc/+I4w85ESEPx3y4+pYAgCUm dtYhmz2+L0T2tzfyo1h6abPSHm308/KcNBOYcJ8h+i+wKz/8A94UOsZSRXKDDT9Izj hPgl1EUUDSOlldpmSF5tUvna48MIZ0A1XvcLSfPG1WcJXwa08LpCWRAUykKK2CwsFD iDMQI07JFcP3jxDgN9kLRjxbLIA6oRzsEakWYUGiHVGAA6PFAZ1JQo9yYiliBxxbnh HqHzV8HAnADhQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 76E2269243 for ; Fri, 9 Jan 2026 16:13:59 -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 5Uk2k7n5nxin for ; Fri, 9 Jan 2026 16:13:59 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000439; bh=PqIR3Q+1mkgm1dW17yMN2f68KiBEnceqgKc84LBGNMU=; 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=o1HaLYsCQkSXcSmwSBPZwEvP8zz1u6PObcr/VY65axK0kPQgAFgMRbUw1VVa4/UQs 8C1SHtpcDKcwzLbsAmtVXHo4o0+X9Z0ZUNXS4xx4gSc/+I4w85ESEPx3y4+pYAgCUm dtYhmz2+L0T2tzfyo1h6abPSHm308/KcNBOYcJ8h+i+wKz/8A94UOsZSRXKDDT9Izj hPgl1EUUDSOlldpmSF5tUvna48MIZ0A1XvcLSfPG1WcJXwa08LpCWRAUykKK2CwsFD iDMQI07JFcP3jxDgN9kLRjxbLIA6oRzsEakWYUGiHVGAA6PFAZ1JQo9yYiliBxxbnh HqHzV8HAnADhQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5DC8A69218 for ; Fri, 9 Jan 2026 16:13:59 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000437; bh=nAetHA6jRAd1KAfPrFI9TK9x5u2soeCig5UinVYHOHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wLLKsN9oqEbVpnVWc4zftx9EW56DKaFI/EaRuvl1eKv/GV/+y7R3isccKvZG+bLsw dGMKNZCKiCVEx+ZwmqHFjw6Rg+96RwSFplinDyb6RysFpGzrraiCHq1ebTfabVuKQr 4Y8BXE4icntPMei/VFDfgXozQaudrHQmN68O7+auWdCtSo5yIhllA2hWGPyin0umYb HmLUm71qaw32+kkD/q6Ibo2/PIRXZEH9SL7FY166B59U4PUxSf33Qe4LifN0ZUi91K SZatwAVVYIWuNb4CDRmHjO5umvqgWoHnK/dd21w9whk0TRGOfKXXlYQxNZGYAQG04v V90yUT91ky70Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9B1EC69218; Fri, 9 Jan 2026 16:13: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 10026) with ESMTP id 3-ashCTsnIQh; Fri, 9 Jan 2026 16:13:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000430; bh=VF3G0aJJuNSuB2vFrEBwlilLUW1G/iCtYXFfWv1C2fU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N5D+KE1sorx+nJNwYmmykBnzYmLYBUXOEZ0rLgXgBO1TlvtEaF1J7KvdMOolaDRFC xB0Ey1Yge60ftsDSeopdQbHaDNDqnmzDBG4fbSusG0CzjRZu19JrRNs/5j1S9ZrsX1 4v7brIVcIRYj0MTTzw7acyz7JeX6ISKX+coedll43a+uDMO+jGYu/bmGam60wESddm U03IbYinvvj27YM5Q7zWTZnzxHhCw6uMADnk0LGYvSfDVAAAErZ8mGCGCF67Rdh64S jHJYn3qJOJzyAhNRrz+RA8bR6ZFsrwe08ZUPo25uSFhSP/eUVQ/1Ll7TVawtUKSpMp gRdHzMvFfBNIg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3F7A25FF82; Fri, 9 Jan 2026 16:13:50 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:33 -0700 Message-ID: <20260109231151.4056804-25-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YD2TE2ZPB4K5MCPZPHJOFXIGSCIVWCOP X-Message-ID-Hash: YD2TE2ZPB4K5MCPZPHJOFXIGSCIVWCOP 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/32] boot: pxe: Drop fdtoverlay_addr_r check in label_boot_fdtoverlay() 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 Remove the upfront check for fdtoverlay_addr_r environment variable. If it doesn't exist, get_relfile_envaddr() will reserve an address using LMB. Also use the address returned by get_relfile_envaddr() for mapping the overlay blob, rather than re-reading from the environment variable. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 13 +------------ test/boot/pxe.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 2084bb3e9bf..b269ef13f5a 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -307,23 +307,12 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, struct pxe_label *label) { char *fdtoverlay = label->fdtoverlays; - char *fdtoverlay_addr_env; - ulong fdtoverlay_addr; int err; err = fdt_check_header(ctx->fdt); if (err) return; - /* Get the specific overlay loading address */ - fdtoverlay_addr_env = env_get("fdtoverlay_addr_r"); - if (!fdtoverlay_addr_env) { - printf("Invalid fdtoverlay_addr_r for loading overlays\n"); - return; - } - - fdtoverlay_addr = hextoul(fdtoverlay_addr_env, NULL); - /* Cycle over the overlay files and apply them in order */ do { struct fdt_header *blob; @@ -362,7 +351,7 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, /* Resize main fdt */ fdt_shrink_to_minimum(ctx->fdt, 8192); - blob = map_sysmem(fdtoverlay_addr, 0); + blob = map_sysmem(addr, 0); err = fdt_check_header(blob); if (err) { printf("Invalid overlay %s, skipping\n", diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 365aff9f37a..7132d318c56 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -611,8 +611,8 @@ PXE_TEST_ARGS(pxe_test_errors_norun, UTF_CONSOLE | UTF_MANUAL, * Test overlay loading when fdtoverlay_addr_r is not set * * This tests that when a label has fdtoverlays but fdtoverlay_addr_r is not - * set, the overlay loading is skipped with an appropriate warning message, - * but the FDT is still loaded successfully. + * set, overlay loading is attempted via LMB allocation. The FDT is still + * loaded successfully even if overlays fail to load. */ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) { @@ -676,13 +676,16 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) ut_assertok(fdt_check_header(fdt)); /* - * Check console output - FDT loaded, but overlays skipped with - * warning about missing fdtoverlay_addr_r + * Check console output - FDT loaded, overlays attempted via LMB + * allocation but fail since test environment cannot load them */ ut_assert_nextline("Retrieving file: /vmlinuz"); ut_assert_nextline("Retrieving file: /initrd.img"); ut_assert_nextline("Retrieving file: /dtb/board.dtb"); - ut_assert_nextline("Invalid fdtoverlay_addr_r for loading overlays"); + ut_assert_nextline("Retrieving file: /dtb/overlay1.dtbo"); + ut_assert_nextline("Failed loading overlay /dtb/overlay1.dtbo"); + ut_assert_nextline("Retrieving file: /dtb/overlay2.dtbo"); + ut_assert_nextline("Failed loading overlay /dtb/overlay2.dtbo"); ut_assert_console_end(); /* Clean up */ From patchwork Fri Jan 9 23:11: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: 1421 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=1768000441; bh=Jm365v4SHxS6icTR49+7XW9iGuwp7gq6RPHWYqeBvg0=; 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=eZAE0eROuTGET0/P6U2x24xNgXJY4TFKdI2dadQMQuWQQJrVwlOLxsRRIzo0XWhJu n/T+WnDpfo54LKf7tqYgL7L90P7Sj3sit/nMYazbmDNfwMfZjKcBG/4vICtMhP2E8s c3pNP75snALu4SGT8MVLVblbtcEmQNn5rq1SttkX7z5HrVoxB5lGmtYzAe+pgwAngN 2PCm4bDSlT+Vv3xh9umZ7G0CcGUVzCLDtmjjVD73my2jPdyUDG4z1xFFsPRU/z6jPg MyMBV+mggQ5Cw8jc78rsrb7yOpFrIjIanr9clqZIea39Sq6ro5hQlpH0iSb1PhYPxX CxHj2nqibEdcA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C315869218 for ; Fri, 9 Jan 2026 16:14: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 0fQLXb_H5Ot0 for ; Fri, 9 Jan 2026 16:14:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000441; bh=Jm365v4SHxS6icTR49+7XW9iGuwp7gq6RPHWYqeBvg0=; 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=eZAE0eROuTGET0/P6U2x24xNgXJY4TFKdI2dadQMQuWQQJrVwlOLxsRRIzo0XWhJu n/T+WnDpfo54LKf7tqYgL7L90P7Sj3sit/nMYazbmDNfwMfZjKcBG/4vICtMhP2E8s c3pNP75snALu4SGT8MVLVblbtcEmQNn5rq1SttkX7z5HrVoxB5lGmtYzAe+pgwAngN 2PCm4bDSlT+Vv3xh9umZ7G0CcGUVzCLDtmjjVD73my2jPdyUDG4z1xFFsPRU/z6jPg MyMBV+mggQ5Cw8jc78rsrb7yOpFrIjIanr9clqZIea39Sq6ro5hQlpH0iSb1PhYPxX CxHj2nqibEdcA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 05F3869243 for ; Fri, 9 Jan 2026 16:14:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000439; bh=6OOF0FJ2e0BffgkJrVxtoI0w2XLdEmfRK98hpjMTTN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kfuYqU/fCWdlRs8QJpYOQhfM5XuvtPOkrwlvqCo8VfsX8X2Q/mM12VfOAGvXbnXqX iiz07kTG05P99nfMB8aFIPcLGx/OqYQ9/H5OLS8xCGFKubY56hJfoQchEs71lmbbvf ozFMAaGs85PVMtuRkVYSL/8v8gAm6Fz+zwQUnWGxAokq4gH+FvLflTwbg6ZZ/NIyNI B84+ugZV5YEJReMTAzCPTsBLBFTnNMObTTBb5AzgubcYE7nCQQ4vdlzLLPLz1IjxQ4 aeuxZgB86tjjJ5RiKzbiKn/trvIHNCBtI2dAUH27t5xjOOlGy/eLbjKbb1LE65MBON siq57SKQ74A8A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 645F569221; Fri, 9 Jan 2026 16:13:59 -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 PssxfV9beIyS; Fri, 9 Jan 2026 16:13:59 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000435; bh=GA+E3CItCeRKp4cjiVLl8MZ+uodhOVWJSOgnMN+6Gzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=luBb437V/tp4RV53xjYB+4D2tW0+ixbSPBagUzwwuqfHfcd1AGR27xgbYUIBq7n9i K6CudCKbgCAhYpyYwwByMiBctE8SInFqZvAt9bYQmKnYd41Y3YA0pYiOf5Xt9spIcp 8DgY10+5zxxkEMWCZZ4VG1CoxSb3BBuHUQmYGd/Lw6BH4CPrbAIezhrGFjElPAXg2H kc/9cPdNcDuBLl0/h5GH42fN45DISqXgxrwUbPsh0uglf0LU1TNcu5ZG2g/NrdYXvL 3b/zoeokSYHFJefooHQVprAEqpHlQWJH/qx2DFe/sGgAukntILs7+iPWpGJ0PKRS7M sN2T8I1TR1N+A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EC7D169256; Fri, 9 Jan 2026 16:13:54 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:34 -0700 Message-ID: <20260109231151.4056804-26-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: APVPU55QMYKHO4IBOG4QUFUWMTXN56UX X-Message-ID-Hash: APVPU55QMYKHO4IBOG4QUFUWMTXN56UX 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/32] boot: pxe: Convert fdtoverlays from string to alist 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 fdtoverlays from a space-separated string to an alist of individual paths. This moves the string parsing from boot time to config-file parsing time, simplifying label_boot_fdtoverlay(). The alist is initialised in label_create() and each overlay path is added during parsing by the new parse_fdtoverlays() function. The paths are freed in label_destroy(). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 53 ++++++++++++++++++++++++++++++++++++++++++--- boot/pxe_utils.c | 50 ++++++++++-------------------------------- include/pxe_utils.h | 4 ++-- test/boot/pxe.c | 18 +++++++++------ 4 files changed, 75 insertions(+), 50 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index 72a672354b5..b115fb413a2 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -106,12 +106,15 @@ static struct pxe_label *label_create(void) if (!label) return NULL; memset(label, 0, sizeof(struct pxe_label)); + alist_init_struct(&label->fdtoverlays, char *); return label; } void label_destroy(struct pxe_label *label) { + char **overlayp; + free(label->name); free(label->kernel_label); free(label->kernel); @@ -120,7 +123,9 @@ void label_destroy(struct pxe_label *label) free(label->initrd); free(label->fdt); free(label->fdtdir); - free(label->fdtoverlays); + alist_for_each(overlayp, &label->fdtoverlays) + free(*overlayp); + alist_uninit(&label->fdtoverlays); free(label->say); free(label); } @@ -305,6 +310,48 @@ static int parse_sliteral(char **c, char **dst) return 1; } +/* + * Parse a space-separated list of overlay paths into an alist. + */ +static int parse_fdtoverlays(char **c, struct alist *overlays) +{ + char *val; + int err; + + err = parse_sliteral(c, &val); + if (err < 0) + return err; + + while (*val) { + char *path; + char *end; + + /* Skip leading spaces */ + while (*val == ' ') + val++; + + if (!*val) + break; + + /* Find end of this path */ + end = strchr(val, ' '); + if (end) { + path = strndup(val, end - val); + val = end; + } else { + path = strdup(val); + val += strlen(val); + } + + if (!path || !alist_add(overlays, path)) { + free(path); + return -ENOMEM; + } + } + + return 1; +} + /* * Parse a base 10 (unsigned) integer and store it at *dst. */ @@ -527,8 +574,8 @@ static int parse_label(char **c, struct pxe_menu *cfg) err = parse_sliteral(c, &label->fdtdir); break; case T_FDTOVERLAYS: - if (!label->fdtoverlays) - err = parse_sliteral(c, &label->fdtoverlays); + if (!label->fdtoverlays.count) + err = parse_fdtoverlays(c, &label->fdtoverlays); break; case T_LOCALBOOT: label->localboot = 1; diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index b269ef13f5a..e368b15e500 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -306,37 +306,18 @@ static void label_boot_kaslrseed(struct pxe_context *ctx) static void label_boot_fdtoverlay(struct pxe_context *ctx, struct pxe_label *label) { - char *fdtoverlay = label->fdtoverlays; + struct fdt_header *blob; + char **overlayp; + ulong addr; int err; err = fdt_check_header(ctx->fdt); if (err) return; - /* Cycle over the overlay files and apply them in order */ - do { - struct fdt_header *blob; - char *overlayfile; - ulong addr; - char *end; - int len; - - /* Drop leading spaces */ - while (*fdtoverlay == ' ') - ++fdtoverlay; - - /* Copy a single filename if multiple provided */ - end = strstr(fdtoverlay, " "); - if (end) { - len = (int)(end - fdtoverlay); - overlayfile = malloc(len + 1); - strncpy(overlayfile, fdtoverlay, len); - overlayfile[len] = '\0'; - } else - overlayfile = fdtoverlay; - - if (!strlen(overlayfile)) - goto skip_overlay; + /* Apply each overlay file in order */ + alist_for_each(overlayp, &label->fdtoverlays) { + const char *overlayfile = *overlayp; /* Load overlay file */ err = get_relfile_envaddr(ctx, overlayfile, "fdtoverlay_addr_r", @@ -345,7 +326,7 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, &addr, NULL); if (err < 0) { printf("Failed loading overlay %s\n", overlayfile); - goto skip_overlay; + continue; } /* Resize main fdt */ @@ -354,22 +335,15 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, blob = map_sysmem(addr, 0); err = fdt_check_header(blob); if (err) { - printf("Invalid overlay %s, skipping\n", - overlayfile); - goto skip_overlay; + printf("Invalid overlay %s, skipping\n", overlayfile); + continue; } err = fdt_overlay_apply_verbose(ctx->fdt, blob); - if (err) { + if (err) printf("Failed to apply overlay %s, skipping\n", overlayfile); - goto skip_overlay; - } - -skip_overlay: - if (end) - free(overlayfile); - } while ((fdtoverlay = strstr(fdtoverlay, " "))); + } } const char *pxe_get_fdt_fallback(struct pxe_label *label, ulong kern_addr) @@ -501,7 +475,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) + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->fdtoverlays.count) label_boot_fdtoverlay(ctx, label); return 0; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index ec7f12cd7bf..52a520e4823 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -39,7 +39,7 @@ * @initrd: path to the initrd to use for this label. * @fdt: path to FDT to use * @fdtdir: path to FDT directory to use - * @fdtoverlays: space-separated list of paths of FDT overlays to apply + * @fdtoverlays: list of paths of FDT overlays to apply (alist of char *) * @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 @@ -59,7 +59,7 @@ struct pxe_label { char *initrd; char *fdt; char *fdtdir; - char *fdtoverlays; + struct alist fdtoverlays; char *say; int ipappend; int attempted; diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 7132d318c56..47cfa4042f5 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -190,8 +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_str("/dtb/overlay1.dtbo /dtb/overlay2.dtbo", - label->fdtoverlays); + ut_asserteq(2, label->fdtoverlays.count); + ut_asserteq_str("/dtb/overlay1.dtbo", + *alist_get(&label->fdtoverlays, 0, char *)); + ut_asserteq_str("/dtb/overlay2.dtbo", + *alist_get(&label->fdtoverlays, 1, char *)); ut_asserteq_str("Booting default Linux kernel", label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -211,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_assertnull(label->fdtoverlays); + ut_asserteq(0, label->fdtoverlays.count); ut_assertnull(label->say); ut_asserteq(3, label->ipappend); ut_asserteq(0, label->attempted); @@ -231,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_assertnull(label->fdtoverlays); + ut_asserteq(0, label->fdtoverlays.count); ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -251,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_assertnull(label->fdtoverlays); + ut_asserteq(0, label->fdtoverlays.count); ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); @@ -271,7 +274,8 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_assertnull(label->initrd); ut_assertnull(label->fdt); ut_assertnull(label->fdtdir); - ut_assertnull(label->fdtoverlays); + ut_asserteq(0, label->fdtoverlays.count); + ut_assertnull(label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); ut_asserteq(0, label->localboot); @@ -662,7 +666,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_assertnonnull(label->fdtoverlays); + ut_assert(label->fdtoverlays.count > 0); /* Enable output for loading phase */ ctx.quiet = false; From patchwork Fri Jan 9 23:11:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1422 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000446; bh=tPpUDQmCKkpjnLZkEoUtSQqw9B2jGLU7toQJW/8tcCw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kFr/TiEICYCxQGaUu/P4TTkLtye47Iy3/EQRvNP93VH4SmjnqGPoNbORxJXQ+8o/Y xO1ZOHjFoZLK1HHdxNVWFirXVNJ14a+bPSrHS47uYVfqibWPlmYR6BpTaSj7QHjeS6 29CmadfM+58wEg5j/dMslZGvhVrka2819/KGvuK+GFiCJtUg37jc7S+sZ2LornS0jp aZeLz4VhlZ2SWt3heB5S2FPYH6EkXtJUtYcdiOgxfKPY89P0ynxdeC0y14GGu10kEn CLEAmyp5eliA5fZnJXY+djHHhpyiKXfCOXExFZoB7XlMIefCIHXg5/VAq20meQiQ+z Gx8xhbwWh0CQQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 82B3769243 for ; Fri, 9 Jan 2026 16:14:06 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id prbWrlrz0A3p for ; Fri, 9 Jan 2026 16:14:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000446; bh=tPpUDQmCKkpjnLZkEoUtSQqw9B2jGLU7toQJW/8tcCw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kFr/TiEICYCxQGaUu/P4TTkLtye47Iy3/EQRvNP93VH4SmjnqGPoNbORxJXQ+8o/Y xO1ZOHjFoZLK1HHdxNVWFirXVNJ14a+bPSrHS47uYVfqibWPlmYR6BpTaSj7QHjeS6 29CmadfM+58wEg5j/dMslZGvhVrka2819/KGvuK+GFiCJtUg37jc7S+sZ2LornS0jp aZeLz4VhlZ2SWt3heB5S2FPYH6EkXtJUtYcdiOgxfKPY89P0ynxdeC0y14GGu10kEn CLEAmyp5eliA5fZnJXY+djHHhpyiKXfCOXExFZoB7XlMIefCIHXg5/VAq20meQiQ+z Gx8xhbwWh0CQQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6F19369221 for ; Fri, 9 Jan 2026 16:14:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000444; bh=VgM+iCp7NNY3QHzmO5dOkVU8kmKQab1dxNwgeIiyLEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYgsNbLoe0NGT4f75x1a7NRVp9BHqC5ZRUl0Qd+uYvvsYB9Cqy1ZxqNNjqCQDgib6 M6sk8yz3oREBkb/YDTU7YHNpOhnFQcNDlZ2roHqERvP7Bjo2VG2jRRFNIvSh3vUdWe 6K1w/J6FmSBUjKSHRPRMQIRSuBPjSWi6eXWpJWhNaWAjkffwpSKSKfeWovqfJOzRhQ V3zWyqFLiceW/tz1KKSg6rhTCiGclcDhlMagK7+OWapmaNjXA5fuwEMezs5DvXT6yV HC1aZx6m4lGiBZ0uGpFhV5ovFjllzvLmAByj6O7L/CxRZx17WBT6ibeLCaJkMZ8Ycg GEVz7T+JGNdcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1018F69218; Fri, 9 Jan 2026 16:14:04 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id iiVkADHVTboY; Fri, 9 Jan 2026 16:14:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000440; bh=PxkJvu7RV8zE2dxk7M9/j8o02UToeuS8RFxMO2h3l9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kx+bgk8vn4wtp/X+e2wzGqDGpj2dOLcHXDWND6V67KMvQFc2QUA5R8Fpu+byOreOx quyIFjyNZNZ4FIFSi1xi5ih2nlBf4Uc7SYcqtXlXFuxhWZWRx0akKdUT+XN+MM0XvU j1joohREHXTkxXwSxGLsZCkNfDaUIxXOz0N6CjSGaUs3w4FfgnU2V98uqp8F3Ogb5O FS5vgBOQ7d1Zs0Sd69C9MBTYrGTtrXTEeGr529w/sSVPItHBGOwxPfv1GUoe9FVqfp 2WfYn8V28vzZY72COsVO0CM/ivBC4Ll43akCcdfjvAdOneEFtUpEtIXH0DrS34dIlR k8yE52kdTVnOA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A7E895FF82; Fri, 9 Jan 2026 16:13:59 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:35 -0700 Message-ID: <20260109231151.4056804-27-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KNGCFSRYDQGEAC6FXNV7DRD44ZR6SUU4 X-Message-ID-Hash: KNGCFSRYDQGEAC6FXNV7DRD44ZR6SUU4 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 26/32] boot: pxe: Load overlays to sequential addresses List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Update label_boot_fdtoverlay() to load each overlay to a unique address. If fdtoverlay_addr_r is defined, start at that address and increment by the overlay size after each load. If not defined, let LMB allocate a fresh address for each overlay by passing addr = 0. This ensures that multiple overlays don't overwrite each other in memory before they are applied. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index e368b15e500..a50fa4bc333 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -307,23 +307,39 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, struct pxe_label *label) { struct fdt_header *blob; + ulong fdtoverlay_addr; char **overlayp; - ulong addr; + bool use_lmb; + char *envaddr; int err; err = fdt_check_header(ctx->fdt); if (err) return; + /* + * Get the overlay load address. If fdtoverlay_addr_r is defined, + * overlays are loaded sequentially at increasing addresses. Otherwise, + * LMB allocates a fresh address for each overlay. + */ + envaddr = env_get("fdtoverlay_addr_r"); + if (envaddr) { + fdtoverlay_addr = hextoul(envaddr, NULL); + use_lmb = false; + } else { + fdtoverlay_addr = 0; + use_lmb = true; + } + /* Apply each overlay file in order */ alist_for_each(overlayp, &label->fdtoverlays) { const char *overlayfile = *overlayp; + ulong addr = fdtoverlay_addr; + ulong size; /* Load overlay file */ - err = get_relfile_envaddr(ctx, overlayfile, "fdtoverlay_addr_r", - SZ_4K, - (enum bootflow_img_t)IH_TYPE_FLATDT, - &addr, NULL); + err = get_relfile(ctx, overlayfile, &addr, SZ_4K, + (enum bootflow_img_t)IH_TYPE_FLATDT, &size); if (err < 0) { printf("Failed loading overlay %s\n", overlayfile); continue; @@ -343,6 +359,10 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, if (err) printf("Failed to apply overlay %s, skipping\n", overlayfile); + + /* Move to next address if using fixed addresses */ + if (!use_lmb) + fdtoverlay_addr = addr + size; } } From patchwork Fri Jan 9 23:11: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: 1423 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=1768000450; bh=BIohxOgzTHE1BBEjeTHLYKwhbGIqkbzmsZ6CQ5kmciw=; 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=koPMwXAC6SxQq2FPBOI/pEa2XlqxSBghDLqwtWJMYRZdFVJa5cOVeV7Dg6TFsBig1 u/5g3ccv+VzKagzxYyKo5uy71lBDTPLGTjvqVy6ajKlOYvOEzy6KwdDkpGilCtwG7j BeCtnmUrjrZ+lo1MIgitZeZosABiBvgRYpynBy+Iprow+PVmrGGWSawp3qhH6l7obD tLFnuSOXXFiaBE6C7m+r1hlcKITfIPGxRu0DlTi7NHTz7yrFycFxzCHys9IKkvMBjd JgGbAYdSyxP23Cd5k5PMq7aqNI/zjawEs7q54KR9z+0ddYX0IL478FHCEmstHsPVCG ksRXEqFiYx7Wg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EBA9469243 for ; Fri, 9 Jan 2026 16:14: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 KqajOalGLUi1 for ; Fri, 9 Jan 2026 16:14:10 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000450; bh=BIohxOgzTHE1BBEjeTHLYKwhbGIqkbzmsZ6CQ5kmciw=; 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=koPMwXAC6SxQq2FPBOI/pEa2XlqxSBghDLqwtWJMYRZdFVJa5cOVeV7Dg6TFsBig1 u/5g3ccv+VzKagzxYyKo5uy71lBDTPLGTjvqVy6ajKlOYvOEzy6KwdDkpGilCtwG7j BeCtnmUrjrZ+lo1MIgitZeZosABiBvgRYpynBy+Iprow+PVmrGGWSawp3qhH6l7obD tLFnuSOXXFiaBE6C7m+r1hlcKITfIPGxRu0DlTi7NHTz7yrFycFxzCHys9IKkvMBjd JgGbAYdSyxP23Cd5k5PMq7aqNI/zjawEs7q54KR9z+0ddYX0IL478FHCEmstHsPVCG ksRXEqFiYx7Wg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DA7A069241 for ; Fri, 9 Jan 2026 16:14:10 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000448; bh=GKDONxy17cLnndN1MtxWGApzjA8LEPRxew4hkzxQZ1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDjXoMQK6OIlpig934BqvO+jA/BMOuMqRsblOkp0ieAbWUTcYzpFDRA9zlcDePtP5 d/jeSxBrynLbLVb15PDHPIdSVihntii9q60h2yYQe9z4GSTk/vGW7e1744SWvZys6S Imb+mvgPbBLFwxOShDpWWnWqVfBMjN2pxi3aJYCZxy/HX32VfAQuOePYVai40yplRN bPQA3hYHqx247d8X1QLneVORw2cQEWF02BF8SF4x0L97Sin9HXLLkKFIlc7cnl8L9w bslcHOF5mi00GvXFL1WpourlBDa68u2RalHsKasFHkwB1yQDUXQxprEPyaAyhNt6/3 ao/CjC0QCSthg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E637F69218; Fri, 9 Jan 2026 16:14: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 mwH7YhzNY9hs; Fri, 9 Jan 2026 16:14:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000444; bh=vqiDX4tKntZg8tQ3THH1IuG8e+gOJ/rssAY4nu65NmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Et0t/20A4OPnnViod1DATicKBzSN1I7NetA/IjIILZJRJMS2h7nEax8qD6JBBq54P iykQeWjkh6KwYH9HT9F92I5GQ9/tlUBWkFP5cMv3zny3QkoYjYNGxL2pJ8UTEunZ6f 93sn/pWQttIPXHLsO9AZPEAtMKvF17Owds/zlU24/MdfYnnKZzTg85XsrzzXVFP6wI DGmLcKQtfsYbE2ZS+f7Qh1C8gUMXdPBYI6vcMfFYdckUtXUnF7KCQVtNw7Dd7iWu6V P9hWwU4Lv20dsHbT+Dt4+M8U+HKYSHRQUOwpsenb1uAhb1lF/ih04rYBZKIV6631oj 763YDzcaiL2zg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5519D5FF82; Fri, 9 Jan 2026 16:14:04 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:36 -0700 Message-ID: <20260109231151.4056804-28-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: OMEKCG26JRJVXNGJC6VZOWWOXH4ZJ5KA X-Message-ID-Hash: OMEKCG26JRJVXNGJC6VZOWWOXH4ZJ5KA 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 27/32] boot: pxe: Split overlay loading and applying into two passes 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 Introduce struct pxe_fdtoverlay to hold both the path and loaded address for each overlay. Update label_boot_fdtoverlay() to: 1. First pass: load all overlay files and store their addresses 2. Resize the main FDT once to make room for all overlays 3. Second pass: apply all loaded overlays This ensures all overlays are loaded before any are applied, which may be useful when overlays depend on each other or when the FDT resize could affect memory layout. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_parse.c | 19 ++++++++++--------- boot/pxe_utils.c | 37 +++++++++++++++++++++---------------- include/pxe_utils.h | 13 ++++++++++++- test/boot/pxe.c | 4 ++-- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index b115fb413a2..6d148756b0d 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, char *); + alist_init_struct(&label->fdtoverlays, struct pxe_fdtoverlay); return label; } void label_destroy(struct pxe_label *label) { - char **overlayp; + struct pxe_fdtoverlay *overlay; free(label->name); free(label->kernel_label); @@ -123,8 +123,8 @@ void label_destroy(struct pxe_label *label) free(label->initrd); free(label->fdt); free(label->fdtdir); - alist_for_each(overlayp, &label->fdtoverlays) - free(*overlayp); + alist_for_each(overlay, &label->fdtoverlays) + free(overlay->path); alist_uninit(&label->fdtoverlays); free(label->say); free(label); @@ -323,7 +323,7 @@ static int parse_fdtoverlays(char **c, struct alist *overlays) return err; while (*val) { - char *path; + struct pxe_fdtoverlay item; char *end; /* Skip leading spaces */ @@ -336,15 +336,16 @@ static int parse_fdtoverlays(char **c, struct alist *overlays) /* Find end of this path */ end = strchr(val, ' '); if (end) { - path = strndup(val, end - val); + item.path = strndup(val, end - val); val = end; } else { - path = strdup(val); + item.path = strdup(val); val += strlen(val); } + item.addr = 0; - if (!path || !alist_add(overlays, path)) { - free(path); + if (!item.path || !alist_add(overlays, item)) { + free(item.path); return -ENOMEM; } } diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index a50fa4bc333..8d565d971fc 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -306,9 +306,9 @@ static void label_boot_kaslrseed(struct pxe_context *ctx) static void label_boot_fdtoverlay(struct pxe_context *ctx, struct pxe_label *label) { + struct pxe_fdtoverlay *overlay; struct fdt_header *blob; ulong fdtoverlay_addr; - char **overlayp; bool use_lmb; char *envaddr; int err; @@ -331,38 +331,43 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, use_lmb = true; } - /* Apply each overlay file in order */ - alist_for_each(overlayp, &label->fdtoverlays) { - const char *overlayfile = *overlayp; + /* First pass: load all overlay files */ + alist_for_each(overlay, &label->fdtoverlays) { ulong addr = fdtoverlay_addr; ulong size; - /* Load overlay file */ - err = get_relfile(ctx, overlayfile, &addr, SZ_4K, + err = get_relfile(ctx, overlay->path, &addr, SZ_4K, (enum bootflow_img_t)IH_TYPE_FLATDT, &size); if (err < 0) { - printf("Failed loading overlay %s\n", overlayfile); + printf("Failed loading overlay %s\n", overlay->path); continue; } + overlay->addr = addr; - /* Resize main fdt */ - fdt_shrink_to_minimum(ctx->fdt, 8192); + /* Move to next address if using fixed addresses */ + if (!use_lmb) + fdtoverlay_addr = addr + size; + } + + /* Resize main fdt to make room for overlays */ + fdt_shrink_to_minimum(ctx->fdt, 8192); - blob = map_sysmem(addr, 0); + /* Second pass: apply all loaded overlays */ + alist_for_each(overlay, &label->fdtoverlays) { + if (!overlay->addr) + continue; + + blob = map_sysmem(overlay->addr, 0); err = fdt_check_header(blob); if (err) { - printf("Invalid overlay %s, skipping\n", overlayfile); + printf("Invalid overlay %s, skipping\n", overlay->path); continue; } err = fdt_overlay_apply_verbose(ctx->fdt, blob); if (err) printf("Failed to apply overlay %s, skipping\n", - overlayfile); - - /* Move to next address if using fixed addresses */ - if (!use_lmb) - fdtoverlay_addr = addr + size; + overlay->path); } } diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 52a520e4823..d2062c03997 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -24,6 +24,17 @@ * 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 * @@ -39,7 +50,7 @@ * @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 paths of FDT overlays to apply (alist of char *) + * @fdtoverlays: list of FDT overlays to apply (alist of struct pxe_fdtoverlay) * @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 diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 47cfa4042f5..df5c106caab 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, char *)); + alist_get(&label->fdtoverlays, 0, struct pxe_fdtoverlay)->path); ut_asserteq_str("/dtb/overlay2.dtbo", - *alist_get(&label->fdtoverlays, 1, char *)); + alist_get(&label->fdtoverlays, 1, struct pxe_fdtoverlay)->path); ut_asserteq_str("Booting default Linux kernel", label->say); ut_asserteq(0, label->ipappend); ut_asserteq(0, label->attempted); From patchwork Fri Jan 9 23:11: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: 1424 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=1768000456; bh=kzEcyc/895siSfU5kGn2ApFL8PaW3S3UW/J/mTvRuYI=; 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=j0O3tWoJ0vWq7ITuLDBfRCsre4Yh+FkgCyrzD3ycK+jEnhBdm4uOHL89eWDuLPyIJ 8kXtC9+od7JeLEpWVhqoLd2vV/EL8WM9j7JdCrlbBNa8X3bkfsNnpW2mblKxhQYZQT ukC4Z7JabIWdDG1Xz6rReDwHPjnIk89mT2S+F6p7gZY4CJdBJX4YiBbCFhiP1MA1o/ CiE6X+LANCuK3q2DKrVS8UmExoBPc7QfVFSLJ67d9lw46Ea5+Jgmh40aNqNHLYTjaE vLBPqV1DzdC5K8V3xMeBuBW4pcqcEu3jDn9td5UIcNkTCl/JosEQaOWsfv0HDNGQp+ TpRx6EsfiUqkw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6C5B869243 for ; Fri, 9 Jan 2026 16:14: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 Q_M6JH0VFR3y for ; Fri, 9 Jan 2026 16:14:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000456; bh=kzEcyc/895siSfU5kGn2ApFL8PaW3S3UW/J/mTvRuYI=; 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=j0O3tWoJ0vWq7ITuLDBfRCsre4Yh+FkgCyrzD3ycK+jEnhBdm4uOHL89eWDuLPyIJ 8kXtC9+od7JeLEpWVhqoLd2vV/EL8WM9j7JdCrlbBNa8X3bkfsNnpW2mblKxhQYZQT ukC4Z7JabIWdDG1Xz6rReDwHPjnIk89mT2S+F6p7gZY4CJdBJX4YiBbCFhiP1MA1o/ CiE6X+LANCuK3q2DKrVS8UmExoBPc7QfVFSLJ67d9lw46Ea5+Jgmh40aNqNHLYTjaE vLBPqV1DzdC5K8V3xMeBuBW4pcqcEu3jDn9td5UIcNkTCl/JosEQaOWsfv0HDNGQp+ TpRx6EsfiUqkw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5A58769221 for ; Fri, 9 Jan 2026 16:14:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000453; bh=bBtX5M3Yzaz7JAdp19kOeyrXzUqK1YCoge27GjAstAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R2XA0u1RluELJkRQjp0n/guvGTGP0wxHgyNUcsKQdf9cbp6L/IEh278ulQYrQdvwU 9Y4NSse6rSOCOmkg5+RN9amfzStJjfiwv1v7MrWgLz5jjjzh8cOeo35riRt/6/51vm YRr9DBHceDlf+4Cz7V+OxCuEbkHLz+1dLCoLYJAHZXRTsgEoooJlY404KmfLYEewDH WMQOREJueY+uAytSba8E/qfGvJl6UgFWnHeEJsgrLf2gPiUVcX4Imp1D0sD9eC+DIh XKc6/QdfRLrrdhsnpzQRKiEwNQCNhC5++wroprq2NBCH91YkygnA1wEraMEl7kl00N Rwc8/GBE4b3tA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7218969218; Fri, 9 Jan 2026 16:14:13 -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_O23fvbQm8l; Fri, 9 Jan 2026 16:14:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000449; bh=xigozcrX0gw49LODqe71uDspyGnZccWu+FJ+HcsaRA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aVAvo0fguoOegUuq0Mb4N2f1w5Fo9GJibL8DFqA4InElbDDEujreTRdnOZr0UexAd uzmAF3YMNTzIuWPMaGfA5byOsrOzvADhLXIJcHM4fPDzUT6QzEco4IxRUU/gcuzw6u jCQWLKjzagf9/DCAVc7bZi2r6zKSgz6Zw0cjxyRDi00q06HK+NjFa7Xo+X504jsnPy pXKYkxMhDa6Arv/KsJxba1gMM1mXi54m5X5VCROPVuz4mJTRQsWgydtZjP5vQ39sgK uUG5KxaTccTSdvMEDjOnR4HcJBuh8WrsvW8hRTO5oQ7Mn87o7lJCTz7Fv8ZXBNZ0DV ro92PLaHKss6g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 05BF35FF82; Fri, 9 Jan 2026 16:14:08 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:37 -0700 Message-ID: <20260109231151.4056804-29-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XQECIXQZNPUBCHO5R6DVMTAWEXNJWVQU X-Message-ID-Hash: XQECIXQZNPUBCHO5R6DVMTAWEXNJWVQU 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 28/32] boot: pxe: Split label_boot_fdtoverlay() into load and apply 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 Split label_boot_fdtoverlay() into two separate functions: - label_load_fdtoverlays(): loads all overlay files and stores addresses - label_apply_fdtoverlays(): applies loaded overlays to working FDT This separation allows for future flexibility in when overlays are loaded versus applied. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 8d565d971fc..4bae830f353 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -297,25 +297,21 @@ static void label_boot_kaslrseed(struct pxe_context *ctx) } /** - * label_boot_fdtoverlay() - Loads fdt overlays specified in 'fdtoverlays' - * or 'devicetree-overlay' + * label_load_fdtoverlays() - Load FDT overlay files + * + * Load all overlay files specified in the label. The loaded addresses are + * stored in each overlay's addr field. * * @ctx: PXE context * @label: Label to process */ -static void label_boot_fdtoverlay(struct pxe_context *ctx, - struct pxe_label *label) +static void label_load_fdtoverlays(struct pxe_context *ctx, + struct pxe_label *label) { struct pxe_fdtoverlay *overlay; - struct fdt_header *blob; ulong fdtoverlay_addr; bool use_lmb; char *envaddr; - int err; - - err = fdt_check_header(ctx->fdt); - if (err) - return; /* * Get the overlay load address. If fdtoverlay_addr_r is defined, @@ -331,10 +327,10 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, use_lmb = true; } - /* First pass: load all overlay files */ alist_for_each(overlay, &label->fdtoverlays) { ulong addr = fdtoverlay_addr; ulong size; + int err; err = get_relfile(ctx, overlay->path, &addr, SZ_4K, (enum bootflow_img_t)IH_TYPE_FLATDT, &size); @@ -348,11 +344,30 @@ static void label_boot_fdtoverlay(struct pxe_context *ctx, if (!use_lmb) fdtoverlay_addr = addr + size; } +} + +/** + * label_apply_fdtoverlays() - Apply loaded FDT overlays to working FDT + * + * Apply all previously loaded overlays to the working FDT. + * + * @ctx: PXE context + * @label: Label containing overlays to apply + */ +static void label_apply_fdtoverlays(struct pxe_context *ctx, + struct pxe_label *label) +{ + struct pxe_fdtoverlay *overlay; + struct fdt_header *blob; + int err; + + err = fdt_check_header(ctx->fdt); + if (err) + return; /* Resize main fdt to make room for overlays */ fdt_shrink_to_minimum(ctx->fdt, 8192); - /* Second pass: apply all loaded overlays */ alist_for_each(overlay, &label->fdtoverlays) { if (!overlay->addr) continue; @@ -500,8 +515,10 @@ 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) - label_boot_fdtoverlay(ctx, label); + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->fdtoverlays.count) { + label_load_fdtoverlays(ctx, label); + label_apply_fdtoverlays(ctx, label); + } return 0; } From patchwork Fri Jan 9 23:11: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: 1425 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=1768000460; bh=UuiORVaWMWzj7sYropLNo7Glysan3pDiAzwzD8lrhKk=; 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=ZxU5GjsYhNVh4R1oZ4pM3t75leE17z4DDAXtubQ0jz9BGayU5vbE0uA5IrZhw+UV5 lEyPTqQZWlW8gh5Oipm+jvtzx3vzzATc6RMchkHOUYq/jOOhCm6GQrvLmEHUDDtP0q vWd+o7TcVF9Zh9TGVg33ot0KjcIjdFz60DAsHphvO1xfAbtsM+vMNdGxDj2xAYUay2 RyeuROJ15Rv/XzVUknRpCqDEmhm5VoxztdQbVsCf9tqyXJ2XKfPCIkYXf6HUHTvrLp LI3N62+SaG57dAPQ9WCu8d1iXYPb80NhXZYwuWWWYwC6UyBftJHP1eKgXPzx7umrHX w48QWKWPHp2sA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DC75B69243 for ; Fri, 9 Jan 2026 16:14:20 -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 8cYLE-Wajt55 for ; Fri, 9 Jan 2026 16:14:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000460; bh=UuiORVaWMWzj7sYropLNo7Glysan3pDiAzwzD8lrhKk=; 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=ZxU5GjsYhNVh4R1oZ4pM3t75leE17z4DDAXtubQ0jz9BGayU5vbE0uA5IrZhw+UV5 lEyPTqQZWlW8gh5Oipm+jvtzx3vzzATc6RMchkHOUYq/jOOhCm6GQrvLmEHUDDtP0q vWd+o7TcVF9Zh9TGVg33ot0KjcIjdFz60DAsHphvO1xfAbtsM+vMNdGxDj2xAYUay2 RyeuROJ15Rv/XzVUknRpCqDEmhm5VoxztdQbVsCf9tqyXJ2XKfPCIkYXf6HUHTvrLp LI3N62+SaG57dAPQ9WCu8d1iXYPb80NhXZYwuWWWYwC6UyBftJHP1eKgXPzx7umrHX w48QWKWPHp2sA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CBD3869221 for ; Fri, 9 Jan 2026 16:14:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000458; bh=vVRRC7vc5ltICFdtA0FKW8IfEToqbQ9A7PvazWIiObU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hxx3ktCdT7bFK0Vf//uECalgAz67CTCc2Cy8+edMgnqQ0UMnEtEIwMtnWC40TMFVf MxhB4ekM/aqV0NGKoK/vZENXYRn6kbg4ECYW1T7Ti3KtFKbXd8fBEaV9SbMUbw+c+8 FyGukDfvWLsqAzQSkiwOmcWSgQLUWpoXBN5LXLPeCWkwmtYqDzNosR54emNlDai/Gk VDk0qC3VnYj94eGM2MbyLMYzhpS8n9HRWD1sM9h/7/o+2A5sMywO3yB8doO0uJm4ws 7GQH9QA78uMuMVlvQfqa0z62S4sF+ie4Q/erl5o+irT88vTBebKTRINczhKjBOvShv uW7dSXrD7WQsg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CB51169221; Fri, 9 Jan 2026 16:14: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 Xu3Y3NZCR_0U; Fri, 9 Jan 2026 16:14:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000454; bh=2ZKvIeZ3Qaw4MwBH4HE+nEwW+qUrWNuvSbCuF4gkKTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lxwhjQPqUDlJ4twVCtL2TwTfTL1Lu4fj01Yw/S2SsGyku9rzxyCZ70/lzGFFBN8tz epFsr2n/Qh97OcQot3tAxwORp5hc+cNd9/LOjxI2oeVnl3LbXMYh15m1NERFxV6oCI RHybDlcQ5uKDFbL9aGz4JDNWPJ4SSwe5/yb9l29BMBxEi7HSmvHpJJIpCMa1fVAbIU 4/wu3CQzr8LTb06xq6nDDWYNB5ZtoGuGbdrP+nwm4fZXrzUk3jEox9prYhOCggf2e1 j0eOPKt00mOqPvvbAY3U9OkzYnLJ7QxVcXbNB04okLfzlH+lejQn6gMzO5mmGuqKAw yIIeRi8T2QJow== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B686E5FF82; Fri, 9 Jan 2026 16:14:13 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:38 -0700 Message-ID: <20260109231151.4056804-30-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XX2UZ4MPZYCDD5Y4XE62347QL5OFZJI4 X-Message-ID-Hash: XX2UZ4MPZYCDD5Y4XE62347QL5OFZJI4 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 29/32] boot: pxe: Move overlay loading to pxe_load_files() 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 Move the overlay loading from label_process_fdt() to pxe_load_files(), grouping all file loading (kernel, initrd, FDT, overlays) in one place. The overlay applying remains in label_process_fdt() since it operates on the working FDT after it has been set up. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 4bae830f353..e336b125716 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -515,10 +515,8 @@ 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) { - label_load_fdtoverlays(ctx, label); + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->fdtoverlays.count) label_apply_fdtoverlays(ctx, label); - } return 0; } @@ -681,6 +679,9 @@ static int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, } } + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->fdtoverlays.count) + label_load_fdtoverlays(ctx, label); + return 0; } From patchwork Fri Jan 9 23:11: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: 1426 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=1768000464; bh=V1w+yKVJbAlk2o3hofcCvn7r5qaAjZ6kSIh8UMlgIk8=; 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=am061q6UlOsnuWm2oSlf1eAaAxKJuV9A2Rxt60ZmxbZgJkABj9QZ+Oq4wAB5H3YZq k7IvqZUktQQu1bUHcVi3L8gQCOEH81cAVmMpU1Au8kK8spA4HXmOrdVMYqVEEVF5eG IcufJD8BO5ZwCgUIr/qHO7KdZm6+Ab8nkLRz/exQMokJOvAFYpuGfUQ36sbUvBM0H8 GPzZY+quUow69zLxEFhV3AZ7CzcwtSBg9fCTexmjKZM1ZI6ZMoUBYKZ3wt0Tx1MrnC 1K9kXBPyfXyP51dyaNav5OKAhoBQA/5iYrfBca15dw0yJAcWuVcLZ5YGzlCMzHuEPb 66Ixc7kSRhJcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A1F516924E for ; Fri, 9 Jan 2026 16:14: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 10024) with ESMTP id arxVO635qZ9C for ; Fri, 9 Jan 2026 16:14:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000464; bh=V1w+yKVJbAlk2o3hofcCvn7r5qaAjZ6kSIh8UMlgIk8=; 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=am061q6UlOsnuWm2oSlf1eAaAxKJuV9A2Rxt60ZmxbZgJkABj9QZ+Oq4wAB5H3YZq k7IvqZUktQQu1bUHcVi3L8gQCOEH81cAVmMpU1Au8kK8spA4HXmOrdVMYqVEEVF5eG IcufJD8BO5ZwCgUIr/qHO7KdZm6+Ab8nkLRz/exQMokJOvAFYpuGfUQ36sbUvBM0H8 GPzZY+quUow69zLxEFhV3AZ7CzcwtSBg9fCTexmjKZM1ZI6ZMoUBYKZ3wt0Tx1MrnC 1K9kXBPyfXyP51dyaNav5OKAhoBQA/5iYrfBca15dw0yJAcWuVcLZ5YGzlCMzHuEPb 66Ixc7kSRhJcw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 91BD369241 for ; Fri, 9 Jan 2026 16:14:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000463; bh=f44Z8eq3sE72GfLnDRZUy4VK9FZrrqh5Ee07AP3CTwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U6mC4EcQdk+/fxxV+zehyden/5cwMGTBzhbqrn6JD/8s8+nIeJxY/rD3V0ZYz7ra7 7sgYHsxn9rHLIYHwd1YLfE3z6Msj4N8eQi5wV/HLM9lOouFpA7OFbnAUUGMCTfVDAA jzyRH5ov5Hiu9Z8kczxGQLbAbx7B6rMr3D7LZi4bFLqlDW5D03cEsybZkqxR3P9npz Sn1FVswEclGEv8Ew12thyDs1JotGYrnvx+aC4ZN4MjuDqE5Q0dogdGb3KngLZ3nlhx 7wNvsmuLO9b1ZLrOoiKpMpxt8xhCz0Ji1Eh42V6TO2IcuLrbv+0ZVV7rgIFVVxPIp6 mnchuvYafll/w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3B5C869243; Fri, 9 Jan 2026 16:14:23 -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 5zIqJuMr0poY; Fri, 9 Jan 2026 16:14:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000458; bh=fER80fgJsRo7S/hYV6IPRg5QXzlLp9C1AdgxO3Bwb20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+FC+/zGnisER3zYHJ14FG/GZyVH2VW43IH81EctkMl3j2HacCDOuScWMo/byyfyo dOKC2WP5kxERvnCDiX7Sngu9QEtSpKiQa3bgzYMkkmp3nCpeh1lXetghH9u5FbVHeM /cnbTXP2ukSK3hUEaXziK4kl2h44PHkTkDBI80pzcOThlXKwzp3lgcYKVP+1BU0YD0 jzFSIWzvmtfOflU2ARQTPj7P6DSu0cViHI9VLwpwelpD87aygFeok9GtMP5u7PW6bs 3FQlDQPhVxMcruGuM4Na/b48n62vwoBaw2ganKFX5Z6u/5lAMYp+KPct4poiEZerKH R9OuKIQ90z7pA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 65AAA69218; Fri, 9 Jan 2026 16:14:18 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:39 -0700 Message-ID: <20260109231151.4056804-31-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: E3AYWV23YR6KCNEFD5YRSI3IFBM5UNKV X-Message-ID-Hash: E3AYWV23YR6KCNEFD5YRSI3IFBM5UNKV 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 30/32] boot: pxe: Add test for FDT overlay 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 Extend the PXE parser test to verify that FDT overlays can be loaded. This tests the label_load_fdtoverlays() function by: 1. Creating real DTB and DTBO files in the Python test fixture using dtc 2. Creating dummy kernel/initrd files for loading tests 3. Setting up environment variables for file loading addresses 4. Calling pxe_load_files() to load all files including overlays 5. Verifying overlay addresses are set and sequential Make pxe_load_files() a public function so it can be called from tests to verify file loading without the full boot setup. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 4 ++-- include/pxe_utils.h | 16 ++++++++++++++ test/boot/pxe.c | 36 ++++++++++++++++++++++++++++++++ test/py/tests/test_pxe_parser.py | 9 ++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index e336b125716..8609d832aa6 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -627,8 +627,8 @@ static int generate_localboot(struct pxe_label *label) return 0; } -static int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, - char *fdtfile) +int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, + char *fdtfile) { int ret; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index d2062c03997..aa73f5ff7f0 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -445,6 +445,22 @@ int pxe_do_boot(struct pxe_context *ctx); int pxe_select_label(struct pxe_menu *cfg, bool prompt, struct pxe_label **labelp); +/** + * pxe_load_files() - Load kernel/initrd/FDT/overlays for a label + * + * Loads the files specified in the label into memory and saves the + * addresses in @ctx. This does not process the FDT or set up boot + * parameters - use pxe_load_label() for that. + * + * @ctx: PXE context with getfile callback + * @label: Label whose files to load + * @fdtfile: Path to FDT file (may be NULL) + * Return: 0 on success, -ENOENT if no kernel specified, -EIO if file + * retrieval failed + */ +int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, + char *fdtfile); + /** * pxe_load_label() - Load kernel/initrd/FDT for a label * diff --git a/test/boot/pxe.c b/test/boot/pxe.c index df5c106caab..97049e27ab6 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -289,6 +289,42 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq_str(name, label->name); } + /* + * Test FDT overlay loading + * + * Get the first label (linux) which has fdtoverlays, set up the + * environment, and verify overlay files can be loaded. + */ + label = list_first_entry(&cfg->labels, struct pxe_label, list); + ut_asserteq(2, label->fdtoverlays.count); + + /* Set environment variables for file loading */ + ut_assertok(env_set_hex("kernel_addr_r", PXE_KERNEL_ADDR)); + ut_assertok(env_set_hex("ramdisk_addr_r", PXE_INITRD_ADDR)); + ut_assertok(env_set_hex("fdt_addr_r", PXE_FDT_ADDR)); + ut_assertok(env_set_hex("fdtoverlay_addr_r", PXE_OVERLAY_ADDR)); + + /* + * Load files via pxe_load_files(). Note: pxe_load_files takes + * ownership of fdtfile and frees it, so we must strdup here. + */ + ret = pxe_load_files(&ctx, label, strdup(label->fdt)); + ut_assertok(ret); + + /* Verify kernel and FDT were loaded */ + 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->fdtoverlays, 0, + struct pxe_fdtoverlay)->addr >= PXE_OVERLAY_ADDR); + ut_assert(alist_get(&label->fdtoverlays, 1, + struct pxe_fdtoverlay)->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); + /* Verify no more console output */ ut_assert_console_end(); diff --git a/test/py/tests/test_pxe_parser.py b/test/py/tests/test_pxe_parser.py index af97568e960..bbcd63d58e2 100644 --- a/test/py/tests/test_pxe_parser.py +++ b/test/py/tests/test_pxe_parser.py @@ -233,6 +233,15 @@ def pxe_image(u_boot_config): cfg_path = create_extlinux_conf(fsh.srcdir, labels, menu_opts) + # Create DTB and overlay files for testing + dtbdir = os.path.join(fsh.srcdir, 'dtb') + os.makedirs(dtbdir, exist_ok=True) + compile_dts(BASE_DTS, os.path.join(dtbdir, 'board.dtb')) + compile_dts(OVERLAY1_DTS, os.path.join(dtbdir, 'overlay1.dtbo'), + is_overlay=True) + compile_dts(OVERLAY2_DTS, os.path.join(dtbdir, 'overlay2.dtbo'), + is_overlay=True) + # Create a chain of 16 nested include files to test MAX_NEST_LEVEL # Level 1 is extlinux.conf, levels 2-16 are extra.conf, nest3.conf, etc. for level in range(2, 17): From patchwork Fri Jan 9 23:11: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: 1427 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=1768000469; bh=w7J7hTrNghNULuXnYCuuaL2RwmCf2dV3dq6RDy+rJRY=; 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=wf/sCJQOibEuwSGPJ7rFaLzQl880iiMp4SCUZLXTL+NXfrIstc5B+F9O/j/f+uCxC 9CXl8W3ilRbMfnBtBKhmxrEXxuRYrtMKgw4VBNZ/FQ0w5wTawFuCsI3bJ0EMGTmGEs 8mRelXGKbbDCUToz763+M3HK6Zi9t4w3bjPGPpJfDEPaaBvFhRK6TMF6bcCGaIXiHN oFBZmYlV6fNfZSTNPi+10MNvKih3DpCiWRSSX98HNPZLbeb4Nd9V7qtLHiOouYahiB jh4PgNii6sQbPi+prm1CCZQTZGAdRnuUBKs4uJz4OomZv+ATDYf5H4PpR3e4SMYriJ i+k3wCwYd1Jww== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 25DBF69254 for ; Fri, 9 Jan 2026 16:14: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 10024) with ESMTP id gecwktnOPZCW for ; Fri, 9 Jan 2026 16:14:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000469; bh=w7J7hTrNghNULuXnYCuuaL2RwmCf2dV3dq6RDy+rJRY=; 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=wf/sCJQOibEuwSGPJ7rFaLzQl880iiMp4SCUZLXTL+NXfrIstc5B+F9O/j/f+uCxC 9CXl8W3ilRbMfnBtBKhmxrEXxuRYrtMKgw4VBNZ/FQ0w5wTawFuCsI3bJ0EMGTmGEs 8mRelXGKbbDCUToz763+M3HK6Zi9t4w3bjPGPpJfDEPaaBvFhRK6TMF6bcCGaIXiHN oFBZmYlV6fNfZSTNPi+10MNvKih3DpCiWRSSX98HNPZLbeb4Nd9V7qtLHiOouYahiB jh4PgNii6sQbPi+prm1CCZQTZGAdRnuUBKs4uJz4OomZv+ATDYf5H4PpR3e4SMYriJ i+k3wCwYd1Jww== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 137BE69243 for ; Fri, 9 Jan 2026 16:14:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000467; bh=uJ10JBpoISkyeppd2aJY1OIy5qIOg0NaINY3DfPPRm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2iHcu5nZTC5FF+QXq9gwnkDyk3IGnde8Zgp7GdY/C8oWQ0VCOjqzsCNd5+oDqAKN ju3NwKbluIM++HCBINmJ8bl5zYlwVWG5u9H2amYYDh/9p0K1DvY+2/nIR8pya7Uhkz Zp5bEDkP6f9BcuVbLB9hxjPfCiBMkpvqbL0tknUCf60ZwsoJgjccvSRNiJd7yt+gDF EcUn5Fss8Z04wAzelnEMFVwd9hf3/rE4aYVw15qvsivDHAGz+jX8LCYtIBBUjxu87w Vj923V9xlpzQaABlMsadkXSEe06mgZzRAFOms9c321/A5rXoYIT8b5plrXJ4j0/0Un v3cITxFityEGg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 70FE369218; Fri, 9 Jan 2026 16:14: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 10026) with ESMTP id Ndx5g9y65Isk; Fri, 9 Jan 2026 16:14:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000463; bh=Qd9Ska3ZK71CvU6mI3l9YObdjGlaq/jss6rxNfhyA3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mcx3nWaBQTCE+SqlNHOEjSROjCHVRmEkXcZUfy3+qicyYw8cs7WlkZuRVKlGbnGoi yDbmEXy9vu07idAJFY/7f7Xs+7fjZ+a+YprjO7NuqFMrZTMydmci/GQPs7aN9wIA0M OsYITpbSE42JmXE3uvPcgn3ZR4nOH91NQjkTwhWZk5I/2o4zJ+bWYVyxlcKoOVeucG /l54d8Yg6v7qE4v1uomWQ9J5Htj5GgX6zcsYR3cTyAZkV/lSl8t84emifUYAH47amg 1kk6o39LBC2mvwLVXYqldKW4r6IB3OImfEPscPB7uGkTxqAsrPUwajFzzQtTQ62Q85 e7U7VF2mv9t4w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1768369221; Fri, 9 Jan 2026 16:14:23 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:40 -0700 Message-ID: <20260109231151.4056804-32-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZKNKEUBEKPFI3LOIOMP5CCDZCUMAJIZD X-Message-ID-Hash: ZKNKEUBEKPFI3LOIOMP5CCDZCUMAJIZD 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 31/32] boot: pxe: Split pxe_load_label() into load and setup phases 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 Split pxe_load_label() into two functions to allow more flexible use: - pxe_load_label(): Handles localboot setup, FIT detection, and calls pxe_load_files() to load all files (kernel, initrd, FDT, overlays) - pxe_setup_label(): Processes the FDT (applying overlays), determines the FDT address, and saves boot parameters to the context This separation allows callers to load files without immediately setting up boot parameters, which is useful for inspection or validation before booting. Update label_boot() to call both functions in sequence. Copy fdt_addr to conf_fdt at the end of pxe_load_label() to maintain backward compatibility for callers that only call pxe_load_label() without pxe_setup_label(). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 28 +++++++++++++++++++++++----- include/pxe_utils.h | 19 ++++++++++++++++--- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 8609d832aa6..49934d626ee 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -687,10 +687,6 @@ int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) { - char fit_addr[200]; - const char *conf_fdt_str; - ulong conf_fdt = 0; - char initrd_str[28] = ""; char *fdtfile = NULL; bool is_fit; int ret; @@ -722,6 +718,25 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) if (ret) return ret; + /* Copy fdt_addr to conf_fdt for callers that don't use pxe_setup_label */ + ctx->conf_fdt = ctx->fdt_addr; + + return 0; +} + +int pxe_setup_label(struct pxe_context *ctx, struct pxe_label *label) +{ + char fit_addr[200]; + const char *conf_fdt_str; + ulong conf_fdt = 0; + char initrd_str[28] = ""; + bool is_fit; + int ret; + + /* Check for FIT case: FDT comes from FIT image, not a separate file */ + is_fit = label->fdt && label->kernel_label && + !strcmp(label->kernel_label, label->fdt); + /* for FIT, append the configuration identifier */ snprintf(fit_addr, sizeof(fit_addr), "%lx%s", ctx->kern_addr, label->config ? label->config : ""); @@ -850,11 +865,14 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) } } - /* Load files if not already loaded */ + /* Load files and set up boot params if not already done */ if (!ctx->label) { ret = pxe_load_label(ctx, label); if (ret) return 1; + ret = pxe_setup_label(ctx, label); + if (ret) + return 1; } if (label->ipappend & 0x1) { diff --git a/include/pxe_utils.h b/include/pxe_utils.h index aa73f5ff7f0..a03e00e2a4a 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -464,9 +464,9 @@ int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, /** * pxe_load_label() - Load kernel/initrd/FDT for a label * - * Loads the files specified in the label into memory and saves the - * addresses and sizes in @ctx. Call this only when ready to boot or - * inspect loaded files. + * Loads the files specified in the label into memory. Call + * pxe_setup_label() after this to process the FDT and set up + * boot parameters. * * @ctx: PXE context with getfile callback * @label: Label whose files to load @@ -475,6 +475,19 @@ int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, */ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label); +/** + * pxe_setup_label() - Set up boot parameters for a loaded label + * + * Processes the FDT (applying overlays if needed) and saves the boot + * parameters in @ctx. Call this after pxe_load_label(). + * + * @ctx: PXE context with loaded files + * @label: Label to set up + * Return: 0 on success, -ENOSPC if initrd string too long, -ENOMEM if + * out of memory + */ +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. From patchwork Fri Jan 9 23:11: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: 1428 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=1768000473; bh=rR2PVtin5BOSa6qtpqFhph2tbwRBIj5IOAvEQ3enxtw=; 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=EzCQVuahCoh2GfGBxUVR4ADu7rKmpsEt/aKqGSJTNXIfDYtj1TQ+rFftxgg+8X+Y7 ZZqM8vjfR54miviUOH1SpqPm4sM+JEo1RzeQvjTLv7KdAq+MsHgkBwvlL/AcGKJvPd QQvxFHnae5iivCJ4oj0f0JmNz9PT4q9TvYgaNYIjjTRYIhYt8xceGDo11x8kNDPFSF BrDft24pwIC6Yh+sDmMh2P7BC6wcrlP5vbRVgaJoXJJynuEnFQsIVlevSWH8uBULMp bk3868gxfbL4VJ+nSqmanuJmIv4qUNwZYT5O1scJlQujudqUjb71ec7osX8FR4tE3d yrFpI9xCrwl0Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A2D869252 for ; Fri, 9 Jan 2026 16:14: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 10024) with ESMTP id wfqs_biL6vG2 for ; Fri, 9 Jan 2026 16:14:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000473; bh=rR2PVtin5BOSa6qtpqFhph2tbwRBIj5IOAvEQ3enxtw=; 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=EzCQVuahCoh2GfGBxUVR4ADu7rKmpsEt/aKqGSJTNXIfDYtj1TQ+rFftxgg+8X+Y7 ZZqM8vjfR54miviUOH1SpqPm4sM+JEo1RzeQvjTLv7KdAq+MsHgkBwvlL/AcGKJvPd QQvxFHnae5iivCJ4oj0f0JmNz9PT4q9TvYgaNYIjjTRYIhYt8xceGDo11x8kNDPFSF BrDft24pwIC6Yh+sDmMh2P7BC6wcrlP5vbRVgaJoXJJynuEnFQsIVlevSWH8uBULMp bk3868gxfbL4VJ+nSqmanuJmIv4qUNwZYT5O1scJlQujudqUjb71ec7osX8FR4tE3d yrFpI9xCrwl0Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7A6A269241 for ; Fri, 9 Jan 2026 16:14:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000472; bh=tZ3n0vEyFKpX9ezB4fB4Xg3bZfEV6MKiulXRY/9BnDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vHLLXovACzjne/fg1XSyOMPg3pM3X9ClwvbLH7ekLf4JeqUuS+hyJi6G4kwBdTOzl B6ENDICWcWpzI3HGYGHmi39pyjrKw1ZCpEa7iAAw7H36lTZAbGW0ybdOg/V/qFX+28 8eTutyXbTFbgExz3jvN7sM4zZUvsvEpRYNHYxB5vHXbiaiOJZ5I5HpNfEOVxw+KmRU /Q8EFoU7GFgmy+zW5zLA9LYl4K4BpfYDCOHE9eNXM2oSKncpBZZXLNZ4X3bh2x6BEM oCB/bD0bSiDh+bftfxWW7aODL07Zxxm7wimTLTWTp2vIh0yJuR1sNqXK1v9o9uzw4+ JUUS65jFut2kw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 25C9369218; Fri, 9 Jan 2026 16:14:32 -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 PFcdtBOSLdNZ; Fri, 9 Jan 2026 16:14:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000468; bh=XkGfRudhNd2FCewd8c/I3eMqUrgV1VE1G5PYiAii5so=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vei7O0OoK0h+Ys60P1HZG+C0k3AkRnZ+1l1BHP00UrChiC/E8fNy8af6LnDTiU03C QY5GSeOURwqMKLqgMdqheitWIMJDYuHSzEeuBwxml1E0AfcGVO6P+ezp4Ri0Wa7Cva o9dVqEj4VYSdsP+NCvsRTtm+Feq9kifi9z4Vo7oHNv9DlIgnrRjQ2v1Y9v3cqpNyia GiIcBSLf8wtormpZmNsdCpwqG1PEyQMcAR7/waO2QLvhivCekFrnf9Se+xaYBdbycD Hi/hfiZjc5kdnY7rzTA/eFefXydyrXUYeP9sEJTK2W+BsCypUCIuCVJkEMH08KhQcf eqY+mlC6OZ4jQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B7F4469221; Fri, 9 Jan 2026 16:14:27 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:41 -0700 Message-ID: <20260109231151.4056804-33-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: Z2RQEXB2I32FJVVIGQBYD4JEJC443JP3 X-Message-ID-Hash: Z2RQEXB2I32FJVVIGQBYD4JEJC443JP3 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 32/32] boot: pxe: Extract boot preparation into separate function 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 Move the localboot handling and file loading code from label_boot() into a new helper function label_boot_prep(). This function: - Handles localboot directive if present - Falls back to generate_localboot() if needed - Loads files via pxe_load_label() The pxe_setup_label() call remains in label_boot() to set up boot parameters after files are loaded. Returns: - 0 to continue with boot - 1 to skip this label (negative localboot_val) - negative error code on failure This improves code organisation and makes the main boot flow clearer. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 66 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 49934d626ee..52032d683c3 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -818,11 +818,50 @@ int pxe_setup_label(struct pxe_context *ctx, struct pxe_label *label) return 0; } +/** + * label_boot_prep() - Prepare a label for booting + * + * Handles localboot directive if present and loads all files needed for boot + * (kernel, initrd, FDT, overlays). For positive localboot_val, attempts + * localboot and falls back to generate_localboot() if needed. For negative + * localboot_val, indicates the label should be skipped. + * + * @ctx: PXE context + * @label: Label to process + * Return: 0 to continue booting, 1 to skip this label, -ve on error + */ +static int label_boot_prep(struct pxe_context *ctx, struct pxe_label *label) +{ + int ret; + + if (label->localboot) { + if (label->localboot_val >= 0) { + ret = label_localboot(label); + + if (IS_ENABLED(CONFIG_BOOTMETH_EXTLINUX_LOCALBOOT) && + ret == -ENOENT) + ret = generate_localboot(label); + if (ret) + return ret; + } else { + return 1; /* skip this label */ + } + } + + /* Load files if not already done */ + if (!ctx->label) { + ret = pxe_load_label(ctx, label); + if (ret) + return 1; + } + + return 0; +} + /** * label_boot() - Boot according to the contents of a pxe_label * - * If we can't boot for any reason, we return. A successful boot never - * returns. + * If we can't boot for any reason, we return. A successful boot never returns. * * The kernel will be stored in the location given by the 'kernel_addr_r' * environment variable. @@ -835,7 +874,7 @@ int pxe_setup_label(struct pxe_context *ctx, struct pxe_label *label) * * @ctx: PXE context * @label: Label to process - * Returns does not return on success, otherwise returns 0 if a localboot + * Return: does not return on success, otherwise returns 0 if a localboot * label was processed, or 1 on error */ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) @@ -851,25 +890,12 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) label->attempted = 1; - if (label->localboot) { - if (label->localboot_val >= 0) { - ret = label_localboot(label); - - if (IS_ENABLED(CONFIG_BOOTMETH_EXTLINUX_LOCALBOOT) && - ret == -ENOENT) - ret = generate_localboot(label); - if (ret) - return ret; - } else { - return 0; - } - } + ret = label_boot_prep(ctx, label); + if (ret) + return ret > 0 ? 0 : ret; - /* Load files and set up boot params if not already done */ + /* Set up boot params if not already done */ if (!ctx->label) { - ret = pxe_load_label(ctx, label); - if (ret) - return 1; ret = pxe_setup_label(ctx, label); if (ret) return 1;