arm64: make sure fdt has #address-cells and #size-cells properties
PATCH 1/1 arm64: make sure fdt has #address-cells and #size-cells properties
From: Mark Salter <[email protected]>
Recent upstream changes to kexec-tools relies on #address-cells and #size-cells properties in the FDT. If grub2 needs to create a chosen node, it is likely because firmware did not provide one. In that case, set #address-cells and #size-cells properties to make sure they exist.
---
grub-core/loader/arm64/linux.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
loader/arm64/linux.c +15 -1
@@ -78,7 +78,21 @@ finalize_params_linux (void) node =grub_fdt_find_subnode (fdt,0 ,"chosen" );if (node <0 ) - node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + { +/* +* If we have to create a chosen node, Make sure we +* have #address-cells and #size-cells properties. +*/ + retval =grub_fdt_set_prop32 (fdt,0 ,"#address-cells" ,2 ); +if (retval) + goto failure; + + retval =grub_fdt_set_prop32 (fdt,0 ,"#size-cells" ,2 ); +if (retval) + goto failure; + + node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + }if (node <1 ) goto failure;
Signature · 1 line
2.21.0
This patch looks incomplete. What if "chosen" is there but does not contain the relevant fields?
Quoted 51 lines · On Thu, 31 Oct 2019, 11:39 Javier Martinez Canillas, <[email protected]> wrote:
From: Mark Salter <[email protected]>
Recent upstream changes to kexec-tools relies on #address-cells and #size-cells properties in the FDT. If grub2 needs to create a chosen node, it is likely because firmware did not provide one. In that case, set #address-cells and #size-cells properties to make sure they exist.
Signed-off-by Mark Salter <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/loader/arm64/linux.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)loader/arm64/linux.c +15
-2@@ -78,7 +78,21 @@ finalize_params_linux (void) node =grub_fdt_find_subnode (fdt,0 ,"chosen" );if (node <0 ) - node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + { +/* +* If we have to create a chosen node, Make sure we +* have #address-cells and #size-cells properties. +*/ + retval =grub_fdt_set_prop32 (fdt,0 ,"#address-cells" ,2 ); +if (retval) + goto failure; + + retval =grub_fdt_set_prop32 (fdt,0 ,"#size-cells" ,2 ); +if (retval) + goto failure; + + node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + }if (node <1 ) goto failure; --2.21.0
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 3 lines · Vladimir 'phcoder' Serbinenko
This patch looks incomplete. What if "chosen" is there but does not contain the relevant fields?
My understanding is that if there's a chosen node already defined in the Device Tree but without #address-cells and #size-cells properties, then is a malformed DT and is not up to GRUB to correct it.
But if GRUB is adding a child node as is the case of the chosen node, then is up to GRUB to make sure that there are #address-cells and #size-cells properties also defined so the child nodes are addressed correctly.
But maybe I'm wrong on this, so I'll let Mark comment since he authored the patch and knows better what's the problem that's fixing.
Quoted 43 lines
Quoted 40 lines · On Thu, 31 Oct 2019, 11:39 Javier Martinez Canillas, <[email protected]> wrote:
From: Mark Salter <[email protected]>
Recent upstream changes to kexec-tools relies on #address-cells and #size-cells properties in the FDT. If grub2 needs to create a chosen node, it is likely because firmware did not provide one. In that case, set #address-cells and #size-cells properties to make sure they exist.
Signed-off-by Mark Salter <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/loader/arm64/linux.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)loader/arm64/linux.c +15
-1@@ -78,7 +78,21 @@ finalize_params_linux (void) node =grub_fdt_find_subnode (fdt,0 ,"chosen" );if (node <0 ) - node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + { +/* +* If we have to create a chosen node, Make sure we +* have #address-cells and #size-cells properties. +*/ + retval =grub_fdt_set_prop32 (fdt,0 ,"#address-cells" ,2 ); +if (retval) + goto failure; + + retval =grub_fdt_set_prop32 (fdt,0 ,"#size-cells" ,2 ); +if (retval) + goto failure; + + node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + }
Quoted 6 lines
Quoted 6 lines
loader/arm64/linux.c +0
-1if (node <1 ) goto failure; --2.21.0
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat
Quoted 8 lines · Javier Martinez Canillas
Quoted 3 lines · Vladimir 'phcoder' Serbinenko
This patch looks incomplete. What if "chosen" is there but does not contain the relevant fields?
My understanding is that if there's a chosen node already defined in the Device Tree but without #address-cells and #size-cells properties, then is a malformed DT and is not up to GRUB to correct it.
Right. IIRC, this was the case where firmware only has ACPI tables and grub has to create a DT with just a chosen node.
Quoted 59 lines
But if GRUB is adding a child node as is the case of the chosen node, then is up to GRUB to make sure that there are #address-cells and #size-cells properties also defined so the child nodes are addressed correctly.
But maybe I'm wrong on this, so I'll let Mark comment since he authored the patch and knows better what's the problem that's fixing.
Quoted 43 lines
Quoted 40 lines · On Thu, 31 Oct 2019, 11:39 Javier Martinez Canillas, <[email protected]> wrote:
From: Mark Salter <[email protected]>
Recent upstream changes to kexec-tools relies on #address-cells and #size-cells properties in the FDT. If grub2 needs to create a chosen node, it is likely because firmware did not provide one. In that case, set #address-cells and #size-cells properties to make sure they exist.
Signed-off-by Mark Salter <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/loader/arm64/linux.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)loader/arm64/linux.c +15
-1@@ -78,7 +78,21 @@ finalize_params_linux (void) node =grub_fdt_find_subnode (fdt,0 ,"chosen" );if (node <0 ) - node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + { +/* +* If we have to create a chosen node, Make sure we +* have #address-cells and #size-cells properties. +*/ + retval =grub_fdt_set_prop32 (fdt,0 ,"#address-cells" ,2 ); +if (retval) + goto failure; + + retval =grub_fdt_set_prop32 (fdt,0 ,"#size-cells" ,2 ); +if (retval) + goto failure; + + node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + }Quoted 6 lines
Quoted 6 lines
loader/arm64/linux.c +0
-1if (node <1 ) goto failure; --2.21.0
Best regards,
Adding Leif and Alex...
Quoted 72 lines · Mark Salter
Quoted 8 lines · Javier Martinez Canillas
Quoted 3 lines · Vladimir 'phcoder' Serbinenko
This patch looks incomplete. What if "chosen" is there but does not contain the relevant fields?
My understanding is that if there's a chosen node already defined in the Device Tree but without #address-cells and #size-cells properties, then is a malformed DT and is not up to GRUB to correct it.
Right. IIRC, this was the case where firmware only has ACPI tables and grub has to create a DT with just a chosen node.
Quoted 59 lines
But if GRUB is adding a child node as is the case of the chosen node, then is up to GRUB to make sure that there are #address-cells and #size-cells properties also defined so the child nodes are addressed correctly.
But maybe I'm wrong on this, so I'll let Mark comment since he authored the patch and knows better what's the problem that's fixing.
Quoted 43 lines
Quoted 40 lines · On Thu, 31 Oct 2019, 11:39 Javier Martinez Canillas, <[email protected]> wrote:
From: Mark Salter <[email protected]>
Recent upstream changes to kexec-tools relies on #address-cells and #size-cells properties in the FDT. If grub2 needs to create a chosen node, it is likely because firmware did not provide one. In that case, set #address-cells and #size-cells properties to make sure they exist.
Signed-off-by Mark Salter <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/loader/arm64/linux.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)loader/arm64/linux.c +15
-1@@ -78,7 +78,21 @@ finalize_params_linux (void) node =grub_fdt_find_subnode (fdt,0 ,"chosen" );if (node <0 ) - node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + { +/* +* If we have to create a chosen node, Make sure we +* have #address-cells and #size-cells properties. +*/ + retval =grub_fdt_set_prop32 (fdt,0 ,"#address-cells" ,2 ); +if (retval) + goto failure; + + retval =grub_fdt_set_prop32 (fdt,0 ,"#size-cells" ,2 ); +if (retval) + goto failure; + + node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + }Quoted 6 lines
Quoted 6 lines
loader/arm64/linux.c +0
-1if (node <1 ) goto failure; --2.21.0
Best regards,
Quoted 7 lines · Javier Martinez Canillas
From: Mark Salter <[email protected]>
Recent upstream changes to kexec-tools relies on #address-cells and #size-cells properties in the FDT. If grub2 needs to create a chosen node, it is likely because firmware did not provide one. In that case, set #address-cells and #size-cells properties to make sure they exist.
I assumed we fixed that in 347210a5d5ce ("efi/fdt: Set address/size cells to 2 for empty tree")?
If we didn't, I still think the fix should be ingrub-core/loader/efi/fdt.c rather than here.
/
Leif
Quoted 42 lines
Signed-off-by Mark Salter <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/loader/arm64/linux.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)loader/arm64/linux.c +15
-1@@ -78,7 +78,21 @@ finalize_params_linux (void) node =grub_fdt_find_subnode (fdt,0 ,"chosen" );if (node <0 ) - node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + { +/* +* If we have to create a chosen node, Make sure we +* have #address-cells and #size-cells properties. +*/ + retval =grub_fdt_set_prop32 (fdt,0 ,"#address-cells" ,2 ); +if (retval) + goto failure; + + retval =grub_fdt_set_prop32 (fdt,0 ,"#size-cells" ,2 ); +if (retval) + goto failure; + + node =grub_fdt_add_subnode (fdt,0 ,"chosen" ); + }if (node <1 ) goto failure;Signature · 7 lines
2.21.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Hello Leif,
Quoted 12 lines · Leif Lindholm
Quoted 7 lines · Javier Martinez Canillas
From: Mark Salter <[email protected]>
Recent upstream changes to kexec-tools relies on #address-cells and #size-cells properties in the FDT. If grub2 needs to create a chosen node, it is likely because firmware did not provide one. In that case, set #address-cells and #size-cells properties to make sure they exist.
I assumed we fixed that in
347210a5d5ce("efi/fdt: Set address/size cells to 2 for empty tree")?
That indeed seems to be the case. I missed that was already fixed when rebasing Mark's patch because the fix was a different one.
So it's another patch that can be dropped from our package, thanks a lot for pointing it out.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat