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 <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90402
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jayvik Desai <jayvik@google.com>
This commit is contained in:
Subrata Banik 2025-12-06 19:07:38 +00:00
commit 641f7ac677
2 changed files with 21 additions and 1 deletions

View file

@ -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) \

View file

@ -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)