From 641f7ac677b65b6e2f24f47015c694b445a75cf7 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Sat, 6 Dec 2025 19:07:38 +0000 Subject: [PATCH] arch/arm64: Introduce distinct PRERAM and POSTRAM stack regions Refactor the stack definition macros to explicitly define separate memory regions for the stack, addressing resource conflicts on certain SoCs like Qualcomm x1p42100. The original STACK macro is split into PRERAM_STACK and POSTRAM_STACK. Motivation: On the Qualcomm x1p42100 SoC, the boot flow presents two constraints for the initial stack location: - Boot IMEM is unavailable after the ADSP is loaded. - The existing SSRAM stack address is reserved for QC QSEE by the Trust Zone. Solution: - PRERAM_STACK: Used by coreboot (e.g., till romstage) for static stack allocation (from an alternative SSRAM or BOOT IMEM region). - POSTRAM_STACK: Used starting from ramstage, leveraging the DRAM-mapped memory. This conditional split allows coreboot to manage stack memory independently for the limited environment before DRAM is fully initialized (ENV_ROMSTAGE_OR_BEFORE), resolving the hardware memory conflicts while maintaining compatibility with existing code via aliasing. BUG=b:456953373 BRANCH=None TEST=Able to build google/bluey. Change-Id: I6356adc63d595f59050e6dc5961404be4a9534c0 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/90402 Reviewed-by: Julius Werner Reviewed-by: Kapil Porwal Tested-by: build bot (Jenkins) Reviewed-by: Jayvik Desai --- src/arch/arm64/include/arch/memlayout.h | 20 +++++++++++++++++++- src/include/symbols.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/arch/arm64/include/arch/memlayout.h b/src/arch/arm64/include/arch/memlayout.h index 5c648b36f0..d84e7714fc 100644 --- a/src/arch/arm64/include/arch/memlayout.h +++ b/src/arch/arm64/include/arch/memlayout.h @@ -17,7 +17,25 @@ /* ARM64 stacks need 16-byte alignment. */ #define STACK(addr, size) \ REGION(stack, addr, size, 16) \ - _ = ASSERT(size >= 2K, "stack should be >= 2K, see toolchain.mk"); + _ = ASSERT(size >= 2K, "stack should be >= 2K, see toolchain.mk"); \ + ALIAS_REGION(stack, preram_stack) \ + ALIAS_REGION(stack, postram_stack) + +#if ENV_ROMSTAGE_OR_BEFORE + #define PRERAM_STACK(addr, size) \ + REGION(preram_stack, addr, size, 16) \ + _ = ASSERT(size >= 2K, "preram_stack should be >= 2K, see toolchain.mk"); \ + ALIAS_REGION(preram_stack, stack) + #define POSTRAM_STACK(addr, size) \ + REGION(postram_stack, addr, size, 16) +#else + #define PRERAM_STACK(addr, size) \ + REGION(preram_stack, addr, size, 16) + #define POSTRAM_STACK(addr, size) \ + REGION(postram_stack, addr, size, 16) \ + _ = ASSERT(size >= 2K, "postram_stack should be >= 2K, see toolchain.mk"); \ + ALIAS_REGION(postram_stack, stack) +#endif #define BL31(addr, size) \ REGION(bl31, addr, size, 4K) \ diff --git a/src/include/symbols.h b/src/include/symbols.h index c46b6ff9ef..53dbfb94a3 100644 --- a/src/include/symbols.h +++ b/src/include/symbols.h @@ -31,6 +31,8 @@ DECLARE_OPTIONAL_REGION(timestamp) DECLARE_REGION(preram_cbmem_console) DECLARE_REGION(cbmem_init_hooks) DECLARE_REGION(stack) +DECLARE_REGION(preram_stack) +DECLARE_REGION(postram_stack) DECLARE_OPTIONAL_REGION(preram_cbfs_cache) DECLARE_OPTIONAL_REGION(postram_cbfs_cache) DECLARE_OPTIONAL_REGION(cbfs_cache)