Skip to contentSkip to conversation

platform: generic: Keep some empty space in FDT passed to next stage

PATCH Applied Anup Patel 3 participants 6 messages Dec 9, 2025 – Dec 16, 2025

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

PATCH v3 1/1 platform: generic: Keep some empty space in FDT passed to next stage

Leaving no empty space in the FDT passed to the next booting stage causes the following U-Boot crash on Ventana internal platforms:

Unhandled exception: Load access fault
EPC: 00000000fffa6372 RA: 00000000fffa7418 TVAL: 0001746174730068
EPC: 0000000080245372 RA: 0000000080246418 reloc adjusted

SP:  00000000fef38440 GP:  00000000fef40e60 TP:  0000000000000000
T0:  00000000fef40a70 T1:  000000000000ff00 T2:  0000000000000000
S0:  00000000fffc17a8 S1:  00000000fef38d40 A0:  7375746174730068
A1:  00000000fffc17a8 A2:  0000000000000010 A3:  0000000000000010
A4:  0000000000000000 A5:  00000000fffc17b8 A6:  0000000000ff0000
A7:  000000000000b100 S2:  0000000000000000 S3:  0000000000000001
S4:  00000000fef38d40 S5:  7375746174730068 S6:  0000000000000000
S7:  00000000fef4eef0 S8:  00000000fef4ef90 S9:  0000000000000000
S10: 0000000000000000 S11: 00000000fef4efc0 T3:  00000000fef40ea8
T4:  0000000000ff0000 T5:  00000000fef40a60 T6:  00000000fef40a6c

To address the above issue, keep some minimal empty space in the FDT instead of no empty space.

Fixes bbe9a23060e9 ("platform: generic: Pack the FDT after applying fixups")

---
Changes since v2:
- Fix comments in generic_final_init()
Changes since v1:
- Add Kconfig option for amount of empty space in FDT with default value as 4KB

---
 platform/generic/Kconfig    | 5 +++++
 platform/generic/platform.c | 3 +++
 2 files changed, 8 insertions(+)
platform/generic/Kconfig +5 -0
index 25b8886b..b1808012 100644
@@ -23,6 +23,11 @@ config PLATFORM_GENERIC_MINOR_VER
 	range 0 65535
 	default 1
 
+config PLATFORM_GENERIC_FDT_EMPTY_SPACE
+	int "Platform FDT empty space (KB)"
+	range 0 1024
+	default 4
+
 config PLATFORM_ALLWINNER_D1
 	bool "Allwinner D1 support"
 	depends on FDT_IRQCHIP_PLIC
platform/generic/platform.c +3 -0
index e66f99fa..01fa03e0 100644
@@ -245,7 +245,10 @@ int generic_final_init(bool cold_boot)
 	fdt_fixups(fdt);
 	fdt_domain_fixup(fdt);
 
+	/* Set the empty space in FDT based on kconfig option */
 	fdt_pack(fdt);
+	fdt_open_into(fdt, fdt, fdt_totalsize(fdt) +
+		      CONFIG_PLATFORM_GENERIC_FDT_EMPTY_SPACE * 1024);
 
 	return 0;
 }
Signature · 7 lines
2.43.0


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Applied
#1 lore raw
Quoted 19 lines · Anup Patel

Leaving no empty space in the FDT passed to the next booting stage causes the following U-Boot crash on Ventana internal platforms:

Unhandled exception: Load access fault
EPC: 00000000fffa6372 RA: 00000000fffa7418 TVAL: 0001746174730068
EPC: 0000000080245372 RA: 0000000080246418 reloc adjusted

SP:  00000000fef38440 GP:  00000000fef40e60 TP:  0000000000000000
T0:  00000000fef40a70 T1:  000000000000ff00 T2:  0000000000000000
S0:  00000000fffc17a8 S1:  00000000fef38d40 A0:  7375746174730068
A1:  00000000fffc17a8 A2:  0000000000000010 A3:  0000000000000010
A4:  0000000000000000 A5:  00000000fffc17b8 A6:  0000000000ff0000
A7:  000000000000b100 S2:  0000000000000000 S3:  0000000000000001
S4:  00000000fef38d40 S5:  7375746174730068 S6:  0000000000000000
S7:  00000000fef4eef0 S8:  00000000fef4ef90 S9:  0000000000000000
S10: 0000000000000000 S11: 00000000fef4efc0 T3:  00000000fef40ea8
T4:  0000000000ff0000 T5:  00000000fef40a60 T6:  00000000fef40a6c
Quoted 5 lines

To address the above issue, keep some minimal empty space in the FDT instead of no empty space.

Fixes bbe9a23060e9 ("platform: generic: Pack the FDT after applying fixups")

Applied this patch to the riscv/opensbi repo.

Regards,
Anup

Quoted 45 lines

---
Changes since v2:
- Fix comments in generic_final_init()
Changes since v1:
- Add Kconfig option for amount of empty space in FDT with default value as 4KB

---
 platform/generic/Kconfig    | 5 +++++
 platform/generic/platform.c | 3 +++
 2 files changed, 8 insertions(+)
platform/generic/Kconfig +5 -0
index 25b8886b..b1808012 100644
@@ -23,6 +23,11 @@ config PLATFORM_GENERIC_MINOR_VER
        range 0 65535
        default 1
 
+config PLATFORM_GENERIC_FDT_EMPTY_SPACE
+       int "Platform FDT empty space (KB)"
+       range 0 1024
+       default 4
+
 config PLATFORM_ALLWINNER_D1
        bool "Allwinner D1 support"
        depends on FDT_IRQCHIP_PLIC
platform/generic/platform.c +3 -1
index e66f99fa..01fa03e0 100644
@@ -245,7 +245,10 @@ int generic_final_init(bool cold_boot)
        fdt_fixups(fdt);
        fdt_domain_fixup(fdt);
 
+       /* Set the empty space in FDT based on kconfig option */
        fdt_pack(fdt);
+       fdt_open_into(fdt, fdt, fdt_totalsize(fdt) +
+                     CONFIG_PLATFORM_GENERIC_FDT_EMPTY_SPACE * 1024);
 
        return 0;
 }
--

2.43.0

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#2 lore raw

Anup,

Quoted 20 lines · Anup Patel
Quoted 19 lines · Anup Patel

Leaving no empty space in the FDT passed to the next booting stage causes the following U-Boot crash on Ventana internal platforms:

Unhandled exception: Load access fault
EPC: 00000000fffa6372 RA: 00000000fffa7418 TVAL: 0001746174730068
EPC: 0000000080245372 RA: 0000000080246418 reloc adjusted

SP:  00000000fef38440 GP:  00000000fef40e60 TP:  0000000000000000
T0:  00000000fef40a70 T1:  000000000000ff00 T2:  0000000000000000
S0:  00000000fffc17a8 S1:  00000000fef38d40 A0:  7375746174730068
A1:  00000000fffc17a8 A2:  0000000000000010 A3:  0000000000000010
A4:  0000000000000000 A5:  00000000fffc17b8 A6:  0000000000ff0000
A7:  000000000000b100 S2:  0000000000000000 S3:  0000000000000001
S4:  00000000fef38d40 S5:  7375746174730068 S6:  0000000000000000
S7:  00000000fef4eef0 S8:  00000000fef4ef90 S9:  0000000000000000
S10: 0000000000000000 S11: 00000000fef4efc0 T3:  00000000fef40ea8
T4:  0000000000ff0000 T5:  00000000fef40a60 T6:  00000000fef40a6c
Quoted 7 lines
Quoted 5 lines

To address the above issue, keep some minimal empty space in the FDT instead of no empty space.

Fixes bbe9a23060e9 ("platform: generic: Pack the FDT after applying fixups")

Applied this patch to the riscv/opensbi repo.

Again, this patch reintroduces the bug that was fixed by the "Fixes:" commit. You can't just say "somebody will add the memset() somewhere later" and ignore the bug you are introducing. You need to add the memset() *now* along with the fdt_open_into() call.

Regards,
Samuel

Quoted 46 lines
Quoted 45 lines

---
Changes since v2:
- Fix comments in generic_final_init()
Changes since v1:
- Add Kconfig option for amount of empty space in FDT with default value as 4KB

---
 platform/generic/Kconfig    | 5 +++++
 platform/generic/platform.c | 3 +++
 2 files changed, 8 insertions(+)
platform/generic/Kconfig +5 -0
index 25b8886b..b1808012 100644
@@ -23,6 +23,11 @@ config PLATFORM_GENERIC_MINOR_VER
        range 0 65535
        default 1
 
+config PLATFORM_GENERIC_FDT_EMPTY_SPACE
+       int "Platform FDT empty space (KB)"
+       range 0 1024
+       default 4
+
 config PLATFORM_ALLWINNER_D1
        bool "Allwinner D1 support"
        depends on FDT_IRQCHIP_PLIC
platform/generic/platform.c +3 -1
index e66f99fa..01fa03e0 100644
@@ -245,7 +245,10 @@ int generic_final_init(bool cold_boot)
        fdt_fixups(fdt);
        fdt_domain_fixup(fdt);
 
+       /* Set the empty space in FDT based on kconfig option */
        fdt_pack(fdt);
+       fdt_open_into(fdt, fdt, fdt_totalsize(fdt) +
+                     CONFIG_PLATFORM_GENERIC_FDT_EMPTY_SPACE * 1024);
 
        return 0;
 }
--

2.43.0

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
author
#3 lore raw
Quoted 30 lines · Samuel Holland

Anup,

Quoted 26 lines · Anup Patel
Quoted 24 lines · Anup Patel

Leaving no empty space in the FDT passed to the next booting stage causes the following U-Boot crash on Ventana internal platforms:

Unhandled exception: Load access fault
EPC: 00000000fffa6372 RA: 00000000fffa7418 TVAL: 0001746174730068
EPC: 0000000080245372 RA: 0000000080246418 reloc adjusted

SP:  00000000fef38440 GP:  00000000fef40e60 TP:  0000000000000000
T0:  00000000fef40a70 T1:  000000000000ff00 T2:  0000000000000000
S0:  00000000fffc17a8 S1:  00000000fef38d40 A0:  7375746174730068
A1:  00000000fffc17a8 A2:  0000000000000010 A3:  0000000000000010
A4:  0000000000000000 A5:  00000000fffc17b8 A6:  0000000000ff0000
A7:  000000000000b100 S2:  0000000000000000 S3:  0000000000000001
S4:  00000000fef38d40 S5:  7375746174730068 S6:  0000000000000000
S7:  00000000fef4eef0 S8:  00000000fef4ef90 S9:  0000000000000000
S10: 0000000000000000 S11: 00000000fef4efc0 T3:  00000000fef40ea8
T4:  0000000000ff0000 T5:  00000000fef40a60 T6:  00000000fef40a6c

To address the above issue, keep some minimal empty space in the FDT instead of no empty space.

Fixes bbe9a23060e9 ("platform: generic: Pack the FDT after applying fixups")
Quoted 6 lines
Quoted 1 line

Applied this patch to the riscv/opensbi repo.

Again, this patch reintroduces the bug that was fixed by the "Fixes:" commit. You can't just say "somebody will add the memset() somewhere later" and ignore the bug you are introducing. You need to add the memset() *now* along with the fdt_open_into() call.

Yes, but that fix broke U-boot booting.
The original fix itself was incomplete. Adding memset() to fdt_open_into() is a separate change. Feel free to send patch for it.

Regards,
Anup

Quoted 51 lines

Regards,
Samuel

Quoted 46 lines
Quoted 45 lines

---
Changes since v2:
- Fix comments in generic_final_init()
Changes since v1:
- Add Kconfig option for amount of empty space in FDT with default value as 4KB

---
 platform/generic/Kconfig    | 5 +++++
 platform/generic/platform.c | 3 +++
 2 files changed, 8 insertions(+)
platform/generic/Kconfig +5 -0
index 25b8886b..b1808012 100644
@@ -23,6 +23,11 @@ config PLATFORM_GENERIC_MINOR_VER
        range 0 65535
        default 1
 
+config PLATFORM_GENERIC_FDT_EMPTY_SPACE
+       int "Platform FDT empty space (KB)"
+       range 0 1024
+       default 4
+
 config PLATFORM_ALLWINNER_D1
        bool "Allwinner D1 support"
        depends on FDT_IRQCHIP_PLIC
platform/generic/platform.c +3 -1
index e66f99fa..01fa03e0 100644
@@ -245,7 +245,10 @@ int generic_final_init(bool cold_boot)
        fdt_fixups(fdt);
        fdt_domain_fixup(fdt);
 
+       /* Set the empty space in FDT based on kconfig option */
        fdt_pack(fdt);
+       fdt_open_into(fdt, fdt, fdt_totalsize(fdt) +
+                     CONFIG_PLATFORM_GENERIC_FDT_EMPTY_SPACE * 1024);
 
        return 0;
 }
--

2.43.0

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#4 lore raw
Quoted 32 lines · Anup Patel
Quoted 30 lines · Samuel Holland

Anup,

Quoted 26 lines · Anup Patel
Quoted 24 lines · Anup Patel

Leaving no empty space in the FDT passed to the next booting stage causes the following U-Boot crash on Ventana internal platforms:

Unhandled exception: Load access fault
EPC: 00000000fffa6372 RA: 00000000fffa7418 TVAL: 0001746174730068
EPC: 0000000080245372 RA: 0000000080246418 reloc adjusted

SP:  00000000fef38440 GP:  00000000fef40e60 TP:  0000000000000000
T0:  00000000fef40a70 T1:  000000000000ff00 T2:  0000000000000000
S0:  00000000fffc17a8 S1:  00000000fef38d40 A0:  7375746174730068
A1:  00000000fffc17a8 A2:  0000000000000010 A3:  0000000000000010
A4:  0000000000000000 A5:  00000000fffc17b8 A6:  0000000000ff0000
A7:  000000000000b100 S2:  0000000000000000 S3:  0000000000000001
S4:  00000000fef38d40 S5:  7375746174730068 S6:  0000000000000000
S7:  00000000fef4eef0 S8:  00000000fef4ef90 S9:  0000000000000000
S10: 0000000000000000 S11: 00000000fef4efc0 T3:  00000000fef40ea8
T4:  0000000000ff0000 T5:  00000000fef40a60 T6:  00000000fef40a6c

To address the above issue, keep some minimal empty space in the FDT instead of no empty space.

Fixes bbe9a23060e9 ("platform: generic: Pack the FDT after applying fixups")
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Applied this patch to the riscv/opensbi repo.

Again, this patch reintroduces the bug that was fixed by the "Fixes:" commit. You can't just say "somebody will add the memset() somewhere later" and ignore the bug you are introducing. You need to add the memset() *now* along with the fdt_open_into() call.

Yes, but that fix broke U-boot booting.

And it is entirely possible to fix U-boot booting without breaking other users (cvw, etc.) in the process. Yes, the original commit exposed a bug in U-Boot. Bugs happen; we can fix them or work around them. But needing to fix one bug is not license to intentionally introduce more bugs.

Quoted 3 lines

The original fix itself was incomplete. Adding memset() to fdt_open_into() is a separate change. Feel free to send patch for it.

If you want adding memset() to fdt_open_into() to be a separate change, then that change must be merged *first*, before this patch, so it is then safe to add the call to fdt_open_into(). Because now you have broken bisectability for the affected platforms. The uninitialized memory issue was completely fixed by the original patch, and OpenSBI could boot on cvw as of that commit; now it is broken again, and that is a regression.

Regards,
Samuel

Quoted 47 lines
Quoted 47 lines
Quoted 46 lines
Quoted 45 lines

---
Changes since v2:
- Fix comments in generic_final_init()
Changes since v1:
- Add Kconfig option for amount of empty space in FDT with default value as 4KB

---
 platform/generic/Kconfig    | 5 +++++
 platform/generic/platform.c | 3 +++
 2 files changed, 8 insertions(+)
platform/generic/Kconfig +5 -0
index 25b8886b..b1808012 100644
@@ -23,6 +23,11 @@ config PLATFORM_GENERIC_MINOR_VER
        range 0 65535
        default 1
 
+config PLATFORM_GENERIC_FDT_EMPTY_SPACE
+       int "Platform FDT empty space (KB)"
+       range 0 1024
+       default 4
+
 config PLATFORM_ALLWINNER_D1
        bool "Allwinner D1 support"
        depends on FDT_IRQCHIP_PLIC
platform/generic/platform.c +3 -1
index e66f99fa..01fa03e0 100644
@@ -245,7 +245,10 @@ int generic_final_init(bool cold_boot)
        fdt_fixups(fdt);
        fdt_domain_fixup(fdt);
 
+       /* Set the empty space in FDT based on kconfig option */
        fdt_pack(fdt);
+       fdt_open_into(fdt, fdt, fdt_totalsize(fdt) +
+                     CONFIG_PLATFORM_GENERIC_FDT_EMPTY_SPACE * 1024);
 
        return 0;
 }
--

2.43.0

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#5 lore raw
Quoted 41 lines · Samuel Holland
Quoted 39 lines · Anup Patel
Quoted 36 lines · Samuel Holland

Anup,

Quoted 20 lines · Anup Patel
Quoted 19 lines · Anup Patel

Leaving no empty space in the FDT passed to the next booting stage causes the following U-Boot crash on Ventana internal platforms:

Unhandled exception: Load access fault
EPC: 00000000fffa6372 RA: 00000000fffa7418 TVAL: 0001746174730068
EPC: 0000000080245372 RA: 0000000080246418 reloc adjusted

SP:  00000000fef38440 GP:  00000000fef40e60 TP:  0000000000000000
T0:  00000000fef40a70 T1:  000000000000ff00 T2:  0000000000000000
S0:  00000000fffc17a8 S1:  00000000fef38d40 A0:  7375746174730068
A1:  00000000fffc17a8 A2:  0000000000000010 A3:  0000000000000010
A4:  0000000000000000 A5:  00000000fffc17b8 A6:  0000000000ff0000
A7:  000000000000b100 S2:  0000000000000000 S3:  0000000000000001
S4:  00000000fef38d40 S5:  7375746174730068 S6:  0000000000000000
S7:  00000000fef4eef0 S8:  00000000fef4ef90 S9:  0000000000000000
S10: 0000000000000000 S11: 00000000fef4efc0 T3:  00000000fef40ea8
T4:  0000000000ff0000 T5:  00000000fef40a60 T6:  00000000fef40a6c
Quoted 7 lines
Quoted 5 lines

To address the above issue, keep some minimal empty space in the FDT instead of no empty space.

Fixes bbe9a23060e9 ("platform: generic: Pack the FDT after applying fixups")

Applied this patch to the riscv/opensbi repo.

Again, this patch reintroduces the bug that was fixed by the "Fixes:" commit. You can't just say "somebody will add the memset() somewhere later" and ignore the bug you are introducing. You need to add the memset() *now* along with the fdt_open_into() call.

Quoted 6 lines
Quoted 1 line

Yes, but that fix broke U-boot booting.

And it is entirely possible to fix U-boot booting without breaking other users (cvw, etc.) in the process. Yes, the original commit exposed a bug in U-Boot. Bugs happen; we can fix them or work around them. But needing to fix one bug is not license to intentionally introduce more bugs.

You failed to understand my point. You original fix was already incomplete since instead of packing the FDT it should have done memset() of uninitialized space in FDT.

Quoted 11 lines
Quoted 4 lines

The original fix itself was incomplete. Adding memset() to fdt_open_into() is a separate change. Feel free to send patch for it.

If you want adding memset() to fdt_open_into() to be a separate change, then that change must be merged *first*, before this patch, so it is then safe to add the call to fdt_open_into(). Because now you have broken bisectability for the affected platforms. The uninitialized memory issue was completely fixed by the original patch, and OpenSBI could boot on cvw as of that commit; now it is broken again, and that is a regression.

The original fix for packing FDT was already broken so don't blame me for partially reverting.

Regards,
Anup

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi