[PATCH v1 0/1] Fix booting kernels with ATAGS and extlinux

Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass `-` in the fdt extlinux field as a signal that no tree should be used.
Tested with 3.4 legacy kernel and mainline 6.7 kernel on P895 (lg_x3 board).
Svyatoslav Ryhel (1): boot: pxe_utils: skip fdt setup in case legacy kernel is booted
boot/pxe_utils.c | 8 +++++--- doc/develop/distro.rst | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-)

Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass `-` in the fdt extlinux field as a signal that no tree should be used.
Suggested-by: Jonas Schwöbel jonasschwoebel@yahoo.de Tested-by: Jethro Bull jethrob@hotmail.com Signed-off-by: Svyatoslav Ryhel clamor95@gmail.com --- boot/pxe_utils.c | 8 +++++--- doc/develop/distro.rst | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 83bc167785..6a2c881965 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -634,7 +634,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) char *fdtfilefree = NULL;
if (label->fdt) { - fdtfile = label->fdt; + if (strcmp("-", label->fdt)) + fdtfile = label->fdt; } else if (label->fdtdir) { char *f1, *f2, *f3, *f4, *slash;
@@ -731,13 +732,14 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) zboot_argc = 5; }
- if (!bootm_argv[3]) + if (!bootm_argv[3] && strcmp("-", label->fdt)) bootm_argv[3] = env_get("fdt_addr");
kernel_addr_r = genimg_get_kernel_addr(kernel_addr); buf = map_sysmem(kernel_addr_r, 0);
- if (!bootm_argv[3] && genimg_get_format(buf) != IMAGE_FORMAT_FIT) + if (!bootm_argv[3] && genimg_get_format(buf) != IMAGE_FORMAT_FIT && + strcmp("-", label->fdt)) bootm_argv[3] = env_get("fdtcontroladdr");
if (bootm_argv[3]) { diff --git a/doc/develop/distro.rst b/doc/develop/distro.rst index 8016acad09..c81da8a0fd 100644 --- a/doc/develop/distro.rst +++ b/doc/develop/distro.rst @@ -81,6 +81,9 @@ as specified at `Boot Loader Specification`_: * Does not document the fdtdir option, which automatically selects the DTB to pass to the kernel.
+* If no fdt/fdtdir is provided, the U-Boot will pass its own device tree, and + if fdt is passed with ``-``, then device tree will not be used (legacy booting). + See also doc/README.pxe under 'pxe file format'.
One example extlinux.conf generated by the Fedora installer is::

On Wed, Jan 24, 2024 at 10:27:30PM +0200, Svyatoslav Ryhel wrote:
Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass `-` in the fdt extlinux field as a signal that no tree should be used.
Passing - doesn't seem like the most intuitive thing... Is there a different argument we could use?
regards, dan carpenter

25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter dan.carpenter@linaro.org написав(-ла):
On Wed, Jan 24, 2024 at 10:27:30PM +0200, Svyatoslav Ryhel wrote:
Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass `-` in the fdt extlinux field as a signal that no tree should be used.
Passing - doesn't seem like the most intuitive thing... Is there a different argument we could use?
I agree that `-` is not the most intuitive argument, but this is a way to implement a fix with the least code posssible. To make this less obscure I have adjusted documentation.
Currently if no fdt is specified u-boot will pass its own device tree and if leave fdt field blank u-boot will fail with the wrong name for the device tree. So there is NO way to boot ATAGs based kernel if u-boot has an appended tree and fdt support built in.
regards, dan carpenter

On Thu, Jan 25, 2024 at 08:51:09AM +0200, Svyatoslav wrote:
25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter dan.carpenter@linaro.org написав(-ла):
On Wed, Jan 24, 2024 at 10:27:30PM +0200, Svyatoslav Ryhel wrote:
Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass `-` in the fdt extlinux field as a signal that no tree should be used.
Passing - doesn't seem like the most intuitive thing... Is there a different argument we could use?
I agree that `-` is not the most intuitive argument, but this is a way to implement a fix with the least code posssible. To make this less obscure I have adjusted documentation.
It's also how historically we do similar things. eg, "bootm $kernel_addr_r - $fdt_addr_r". My question is can we re-work this, cleanly, with guards around SUPPORT_PASSING_ATAGS to not increase size anywhere that doesn't need this legacy case.

25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini trini@konsulko.com написав(-ла):
On Thu, Jan 25, 2024 at 08:51:09AM +0200, Svyatoslav wrote:
25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter dan.carpenter@linaro.org написав(-ла):
On Wed, Jan 24, 2024 at 10:27:30PM +0200, Svyatoslav Ryhel wrote:
Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass `-` in the fdt extlinux field as a signal that no tree should be used.
Passing - doesn't seem like the most intuitive thing... Is there a different argument we could use?
I agree that `-` is not the most intuitive argument, but this is a way to implement a fix with the least code posssible. To make this less obscure I have adjusted documentation.
It's also how historically we do similar things. eg, "bootm $kernel_addr_r - $fdt_addr_r". My question is can we re-work this, cleanly, with guards around SUPPORT_PASSING_ATAGS to not increase size anywhere that doesn't need this legacy case.
Which behavior you propose?

On Thu, Jan 25, 2024 at 04:16:11PM +0200, Svyatoslav wrote:
25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini trini@konsulko.com написав(-ла):
On Thu, Jan 25, 2024 at 08:51:09AM +0200, Svyatoslav wrote:
25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter dan.carpenter@linaro.org написав(-ла):
On Wed, Jan 24, 2024 at 10:27:30PM +0200, Svyatoslav Ryhel wrote:
Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass `-` in the fdt extlinux field as a signal that no tree should be used.
Passing - doesn't seem like the most intuitive thing... Is there a different argument we could use?
I agree that `-` is not the most intuitive argument, but this is a way to implement a fix with the least code posssible. To make this less obscure I have adjusted documentation.
It's also how historically we do similar things. eg, "bootm $kernel_addr_r - $fdt_addr_r". My question is can we re-work this, cleanly, with guards around SUPPORT_PASSING_ATAGS to not increase size anywhere that doesn't need this legacy case.
Which behavior you propose?
Well, using the IS_ENABLED macro with the new tests around "-".

25 січня 2024 р. 16:17:34 GMT+02:00, Tom Rini trini@konsulko.com написав(-ла):
On Thu, Jan 25, 2024 at 04:16:11PM +0200, Svyatoslav wrote:
25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini trini@konsulko.com написав(-ла):
On Thu, Jan 25, 2024 at 08:51:09AM +0200, Svyatoslav wrote:
25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter dan.carpenter@linaro.org написав(-ла):
On Wed, Jan 24, 2024 at 10:27:30PM +0200, Svyatoslav Ryhel wrote:
Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass `-` in the fdt extlinux field as a signal that no tree should be used.
Passing - doesn't seem like the most intuitive thing... Is there a different argument we could use?
I agree that `-` is not the most intuitive argument, but this is a way to implement a fix with the least code posssible. To make this less obscure I have adjusted documentation.
It's also how historically we do similar things. eg, "bootm $kernel_addr_r - $fdt_addr_r". My question is can we re-work this, cleanly, with guards around SUPPORT_PASSING_ATAGS to not increase size anywhere that doesn't need this legacy case.
Which behavior you propose?
Well, using the IS_ENABLED macro with the new tests around "-".
So using "-" for booting with extlinux with ATAGs is fine for you? Guards, sure, I will handle this. Which tests you are interested in? Maybe you can point to an example? Thanks.

On Thu, Jan 25, 2024 at 04:34:41PM +0200, Svyatoslav wrote:
25 січня 2024 р. 16:17:34 GMT+02:00, Tom Rini trini@konsulko.com написав(-ла):
On Thu, Jan 25, 2024 at 04:16:11PM +0200, Svyatoslav wrote:
25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini trini@konsulko.com написав(-ла):
On Thu, Jan 25, 2024 at 08:51:09AM +0200, Svyatoslav wrote:
25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter dan.carpenter@linaro.org написав(-ла):
On Wed, Jan 24, 2024 at 10:27:30PM +0200, Svyatoslav Ryhel wrote: > Currently, if boot with extlinux.conf and do not set the fdt > U-Boot will provide its own device tree. This behavior is > beneficial if the U-Boot device tree is in sync with Linux, > but it totally halts the booting of pre-dtb kernels (3.4 for > example) since it uses ATAGs. To fix this, pass `-` in the > fdt extlinux field as a signal that no tree should be used.
Passing - doesn't seem like the most intuitive thing... Is there a different argument we could use?
I agree that `-` is not the most intuitive argument, but this is a way to implement a fix with the least code posssible. To make this less obscure I have adjusted documentation.
It's also how historically we do similar things. eg, "bootm $kernel_addr_r - $fdt_addr_r". My question is can we re-work this, cleanly, with guards around SUPPORT_PASSING_ATAGS to not increase size anywhere that doesn't need this legacy case.
Which behavior you propose?
Well, using the IS_ENABLED macro with the new tests around "-".
So using "-" for booting with extlinux with ATAGs is fine for you? Guards, sure, I will handle this. Which tests you are interested in? Maybe you can point to an example? Thanks.
Sorry, I meant tests in terms of writing the code, not unit tests as no, we don't have enough unit tests around booting a kernel as it stands and I don't see how to just add a test for extlinux + legacy kernel.

25 січня 2024 р. 16:47:48 GMT+02:00, Tom Rini trini@konsulko.com написав(-ла):
On Thu, Jan 25, 2024 at 04:34:41PM +0200, Svyatoslav wrote:
25 січня 2024 р. 16:17:34 GMT+02:00, Tom Rini trini@konsulko.com написав(-ла):
On Thu, Jan 25, 2024 at 04:16:11PM +0200, Svyatoslav wrote:
25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini trini@konsulko.com написав(-ла):
On Thu, Jan 25, 2024 at 08:51:09AM +0200, Svyatoslav wrote:
25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter dan.carpenter@linaro.org написав(-ла): >On Wed, Jan 24, 2024 at 10:27:30PM +0200, Svyatoslav Ryhel wrote: >> Currently, if boot with extlinux.conf and do not set the fdt >> U-Boot will provide its own device tree. This behavior is >> beneficial if the U-Boot device tree is in sync with Linux, >> but it totally halts the booting of pre-dtb kernels (3.4 for >> example) since it uses ATAGs. To fix this, pass `-` in the >> fdt extlinux field as a signal that no tree should be used. > >Passing - doesn't seem like the most intuitive thing... Is there a >different argument we could use? >
I agree that `-` is not the most intuitive argument, but this is a way to implement a fix with the least code posssible. To make this less obscure I have adjusted documentation.
It's also how historically we do similar things. eg, "bootm $kernel_addr_r - $fdt_addr_r". My question is can we re-work this, cleanly, with guards around SUPPORT_PASSING_ATAGS to not increase size anywhere that doesn't need this legacy case.
Which behavior you propose?
Well, using the IS_ENABLED macro with the new tests around "-".
So using "-" for booting with extlinux with ATAGs is fine for you? Guards, sure, I will handle this. Which tests you are interested in? Maybe you can point to an example? Thanks.
Sorry, I meant tests in terms of writing the code, not unit tests as no, we don't have enough unit tests around booting a kernel as it stands and I don't see how to just add a test for extlinux + legacy kernel.
Alright then, thanks!
participants (4)
-
Dan Carpenter
-
Svyatoslav
-
Svyatoslav Ryhel
-
Tom Rini