Re: [PATCH 1/2] board: amd: versal2: move platform_id/platform_version to .data
Ilias Apalodimas <[email protected]>
| Newsgroups | org.u-boot-project.lists.u-boot |
|---|---|
| Message-ID | <CAC_iWjJ3mB19pF=yH6U3TX7yzVPS=h8NjdPUV-i_M6tf2ShPhw@mail.gmail.com> |
On Wed, 26 Aug 2026 at 15:05, Michal Simek <[email protected]> wrote: > > 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. Yes and we also need something the documentation explaining that since it's hard to debug > > 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. Reviewed-by: Ilias Apalodimas <[email protected]> > > 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 >