[PATCH 1/2] board: amd: versal2: move platform_id/platform_version to .data

Michal Simek <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <067b90dbb09718c8c9b73a049702e2df30544849.1787745885.git.michal.simek@amd.com>
platform_id and platform_version are plain uninitialized statics,
placing them in .bss. U-Boot's linker script overlays .bss at the
same address as .rela.dyn (the relocation table), which is safe only
if nothing writes to .bss before relocation completes.

soc_detection() writes these variables during early board_init_f(),
well before relocation, corrupting live .rela.dyn entries. When
relocate_code() later reads the corrupted entry, it writes to an
invalid, unaligned address. QEMU 8.x tolerated this silently, QEMU
10.x enforces alignment checks and traps it, causing U-Boot to hang
right after printing "DRAM:  2 GiB", never reaching the console
prompt.

Move both variables to .data via __section(".data") so they no longer
share an address with the relocation table.

Fixes: 40f5046c221a ("arm64: versal2: Add support for AMD Versal Gen 2")
Signed-off-by: Michal Simek <[email protected]>
---

 arch/arm/mach-versal2/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-versal2/cpu.c b/arch/arm/mach-versal2/cpu.c
index d72f66f4fbac..19baa1331bdd 100644
--- a/arch/arm/mach-versal2/cpu.c
+++ b/arch/arm/mach-versal2/cpu.c
@@ -241,7 +241,8 @@ void versal2_timer_setup(void)
 	debug("timer 0x%llx\n", get_ticks());
 }
 
-static u32 platform_id, platform_version;
+static u32 platform_id __section(".data");
+static u32 platform_version __section(".data");
 
 char *soc_name_decode(void)
 {
---
base-commit: 964ad5b5c91b7be56e443e899d7f873e6aa8c9fc
branch: xnext/data_section

-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.