Skip to contentSkip to conversation

Fix booting kernels with ATAGS and extlinux

PATCH Superseded Svyatoslav Ryhel 3 participants 10 messages Jan 24, 2024 – Jan 25, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH 1/1 boot: pxe_utils: skip fdt setup in case legacy kernel is booted

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.

---
 boot/pxe_utils.c       | 8 +++++---
 doc/develop/distro.rst | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)
boot/pxe_utils.c +5 -3
index 83bc167785..6a2c881965 100644
@@ -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]) {
doc/develop/distro.rst +3 -0
index 8016acad09..c81da8a0fd 100644
@@ -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::
Signature · 1 line
2.40.1
#2 lore raw
In reply to Svyatoslav Ryhel
Quoted 6 lines · Svyatoslav Ryhel

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

author
#3 lore raw

25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter <[email protected]> написав(-ла):

Quoted 11 lines · Svyatoslav Ryhel
Quoted 6 lines

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.

Quoted 3 lines

regards,
dan carpenter

#4 lore raw
Quoted 11 lines · Svyatoslav

25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter <[email protected]> написав(-ла):

Quoted 8 lines · Svyatoslav Ryhel
Quoted 6 lines

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.

Quoted 8 lines
Quoted 3 lines

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.

Signature · 1 line
Tom
author
#5 lore raw

25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini <[email protected]> написав(-ла):

Quoted 21 lines · Svyatoslav
Quoted 11 lines

25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter <[email protected]> написав(-ла):

Quoted 8 lines · Svyatoslav Ryhel
Quoted 6 lines

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.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 5 lines

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?

#6 lore raw
Quoted 24 lines · Svyatoslav

25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini <[email protected]> написав(-ла):

Quoted 21 lines · Svyatoslav
Quoted 19 lines

25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter <[email protected]> написав(-ла):

Quoted 11 lines · Svyatoslav Ryhel
Quoted 6 lines

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.

Quoted 7 lines
Quoted 5 lines

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 "-".

Signature · 1 line
Tom
author
#7 lore raw

25 січня 2024 р. 16:17:34 GMT+02:00, Tom Rini <[email protected]> написав(-ла):

Quoted 31 lines · Svyatoslav
Quoted 30 lines

25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini <[email protected]> написав(-ла):

Quoted 26 lines · Svyatoslav
Quoted 11 lines

25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter <[email protected]> написав(-ла):

Quoted 8 lines · Svyatoslav Ryhel
Quoted 6 lines

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.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 4 lines
Quoted 1 line

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.

#8 lore raw
Quoted 34 lines · Svyatoslav

25 січня 2024 р. 16:17:34 GMT+02:00, Tom Rini <[email protected]> написав(-ла):

Quoted 31 lines · Svyatoslav
Quoted 30 lines

25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini <[email protected]> написав(-ла):

Quoted 26 lines · Svyatoslav
Quoted 11 lines

25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter <[email protected]> написав(-ла):

Quoted 8 lines · Svyatoslav Ryhel
Quoted 6 lines

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.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

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.

Signature · 1 line
Tom
author
#9 lore raw

25 січня 2024 р. 16:47:48 GMT+02:00, Tom Rini <[email protected]> написав(-ла):

Quoted 40 lines · Svyatoslav
Quoted 39 lines

25 січня 2024 р. 16:17:34 GMT+02:00, Tom Rini <[email protected]> написав(-ла):

Quoted 35 lines · Svyatoslav
Quoted 24 lines

25 січня 2024 р. 16:12:36 GMT+02:00, Tom Rini <[email protected]> написав(-ла):

Quoted 21 lines · Svyatoslav
Quoted 19 lines

25 січня 2024 р. 08:29:54 GMT+02:00, Dan Carpenter <[email protected]> написав(-ла):

Quoted 11 lines · Svyatoslav Ryhel
Quoted 6 lines

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.

Quoted 7 lines
Quoted 5 lines

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 "-".

Quoted 8 lines
Quoted 3 lines

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!