[PATCH 2/2] board: xilinx: versal-net: move platform_id/platform_version to .data
Michal Simek <[email protected]>
| Newsgroups | org.u-boot-project.lists.u-boot |
|---|---|
| Message-ID | <5908d1dcf2a650cac2b22d82e7f789b978f70748.1787745885.git.michal.simek@amd.com> |
From: Suraj Kakade <[email protected]> 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: f6aebdf676ed ("arm64: versal-net: Add support for Versal NET platform") Signed-off-by: Suraj Kakade <[email protected]> Signed-off-by: Michal Simek <[email protected]> --- arch/arm/mach-versal-net/cpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-versal-net/cpu.c b/arch/arm/mach-versal-net/cpu.c index 7df7c49ac711..1555751da2e8 100644 --- a/arch/arm/mach-versal-net/cpu.c +++ b/arch/arm/mach-versal-net/cpu.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2021 - 2022, Xilinx, Inc. - * Copyright (C) 2022, Advanced Micro Devices, Inc. + * Copyright (C) 2022 - 2026, Advanced Micro Devices, Inc. * * Michal Simek <[email protected]> */ @@ -151,7 +151,8 @@ u8 __weak versal_net_get_bootmode(void) return reg & BOOT_MODES_MASK; } -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