board: rzg2l: Check the DTB pointer passed by the TF-A.
Subsystems (2)
PATCH v2 1/1 board: rzg2l: Check the DTB pointer passed by the TF-A.
On the RZG2L platform, the advised
TF-A (https://github.com/renesas-rz/rzg_trusted-firmware-a/tree/v2.5/rzg2l)
does not pass any DTB blob to U-Boot.
On the other hand, the RZG2L part of U-Boot expects a DTB to be passed. It means that if one flashes the latest TF-A as well as the mainline U-Boot, it will crash trying to dereference the NULL DTB pointer before outputing anything.
Check if the DTB pointer is NULL before trying to use it.
---
v1: https://lists.denx.de/pipermail/u-boot/2025-September/598712.html
Changelog:
v2: Keep compatibility with TF-A passing DTB blobs.
arch/arm/mach-renesas/cpu_info-rzg2l.c | 2 +- board/renesas/rzg2l/rzg2l.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-renesas/cpu_info-rzg2l.c +1 -1
@@ -30,7 +30,7 @@ static const struct tfa_info *get_tfa_info(void) { void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]); - if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) { + if (atf_fdt_blob && fdt_magic(atf_fdt_blob) == FDT_MAGIC) { unsigned int i; for (i = 0; i < ARRAY_SIZE(tfa_info); i++) { if (!fdt_node_check_compatible(atf_fdt_blob, 0,
board/renesas/rzg2l/rzg2l.c +2 -2
@@ -22,7 +22,7 @@ int board_fit_config_name_match(const char *name) {void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1 ]); -if (fdt_magic (atf_fdt_blob) !=FDT_MAGIC ) +if (!atf_fdt_blob ||fdt_magic (atf_fdt_blob) !=FDT_MAGIC )return -1 ;if (is_rzg2l_board ("renesas,r9a07g044l2" ))
@@ -36,7 +36,7 @@ static void apply_atf_overlay(void *fdt_blob) {void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1 ]); -if (fdt_magic (atf_fdt_blob) ==FDT_MAGIC ) +if (atf_fdt_blob &&fdt_magic (atf_fdt_blob) ==FDT_MAGIC )fdt_overlay_apply_node (fdt_blob,0 , atf_fdt_blob,0 ); }
Signature · 1 line
2.49.0
Quoted 4 lines · Mathieu Othacehe
On the RZG2L platform, the advised
TF-A (https://github.com/renesas-rz/rzg_trusted-firmware-a/tree/v2.5/rzg2l)
does not pass any DTB blob to U-Boot.
Quoted 8 lines
On the other hand, the RZG2L part of U-Boot expects a DTB to be passed. It means that if one flashes the latest TF-A as well as the mainline U-Boot, it will crash trying to dereference the NULL DTB pointer before outputing anything.
Check if the DTB pointer is NULL before trying to use it.
Signed-off-by Mathieu Othacehe <[email protected]>
Thanks !
Hi Mathieu,
thanks for the patch, I have been wondering why the latest U-Boot didn't work for the renesas EVK.
Note: remove the trailing dot from all your commit messages.
Quoted 27 lines · On Mon, 22 Sep 2025 18:29:00 +0200 Mathieu Othacehe <[email protected]> wrote:
On the RZG2L platform, the advised
TF-A (https://github.com/renesas-rz/rzg_trusted-firmware-a/tree/v2.5/rzg2l)
does not pass any DTB blob to U-Boot.On the other hand, the RZG2L part of U-Boot expects a DTB to be passed. It means that if one flashes the latest TF-A as well as the mainline U-Boot, it will crash trying to dereference the NULL DTB pointer before outputing anything.
Check if the DTB pointer is NULL before trying to use it.
Signed-off-by Mathieu Othacehe <[email protected]>---
v1: https://lists.denx.de/pipermail/u-boot/2025-September/598712.htmlChangelog:
v2: Keep compatibility with TF-A passing DTB blobs.arch/arm/mach-renesas/cpu_info-rzg2l.c | 2 +- board/renesas/rzg2l/rzg2l.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)arch/arm/mach-renesas/cpu_info-rzg2l.c +0
-0
arch/arm/mach-renesas/cpu_info-rzg2l.c static const struct tfa_info *get_tfa_info(void) · line 36
Quoted 8 lines
arch/arm/mach-renesas/cpu_info-rzg2l.c +1
-1@@ -30,7 +30,7 @@ static const struct tfa_info *get_tfa_info(void) { void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]); - if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) { + if (atf_fdt_blob && fdt_magic(atf_fdt_blob) == FDT_MAGIC) { unsigned int i; for (i = 0; i < ARRAY_SIZE(tfa_info); i++) { if (!fdt_node_check_compatible(atf_fdt_blob, 0,
Would it be a good idea to:
a) "return &invalid_tfa_info" if atf_fdt_blob is valid but fdt_node_check_compatible() fails to find a valid node?
b) "return tfa_info" if atf_fdt_blob is not
valid?
This is inspired by what you proposed in your patch "board: rzg2l: Do not expect a DTB blob from the TF-A."
This would look like this (on top of this current patch):
--------------------------------------------------
@@ -37,9 +37,11 @@ static const struct tfa_info *get_tfa_info(void)
tfa_info[i].soc_name))
return &tfa_info[i];
}
+
+ return &invalid_tfa_info;
}- return &invalid_tfa_info;
+ return tfa_info;
}
--------------------------------------------------
With this, I am able to successfully boot using the current TF-A.
Quoted 25 lines
board/renesas/rzg2l/rzg2l.c +2
-2@@ -22,7 +22,7 @@ int board_fit_config_name_match(const char *name) {void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1 ]); -if (fdt_magic (atf_fdt_blob) !=FDT_MAGIC ) +if (!atf_fdt_blob ||fdt_magic (atf_fdt_blob) !=FDT_MAGIC )return -1 ;if (is_rzg2l_board ("renesas,r9a07g044l2" ))@@ -36,7 +36,7 @@ static void apply_atf_overlay(void *fdt_blob) {void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1 ]); -if (fdt_magic (atf_fdt_blob) ==FDT_MAGIC ) +if (atf_fdt_blob &&fdt_magic (atf_fdt_blob) ==FDT_MAGIC )fdt_overlay_apply_node (fdt_blob,0 , atf_fdt_blob,0 ); }Signature · 1 line
2.49.0
Signature · 1 line
Hugo Villeneuve