From b8cda662ffa6626c56876b4e23518e1452cd57c2 Mon Sep 17 00:00:00 2001 From: Sham Muthayyan Date: Mon, 29 Aug 2016 20:32:26 +0530 Subject: [PATCH] qcom: ipq: Fix relocation global data size The board goes into hung state when the GD_SIZE more than GENERATED_GLOBAL_DATA_SIZE. In this case, the stack poninter address will be pointing to the unknown address which leads to hung state. Fixed the hung state to point to correct address. Change-Id: I0efc807ca07c16ae0b79ea6c606fde931f02a220 Signed-off-by: Sham Muthayyan --- arch/arm/lib/crt0.S | 2 +- common/board_f.c | 4 +++- common/init/board_init.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S index 9ce7c656b1..1d1909586b 100644 --- a/arch/arm/lib/crt0.S +++ b/arch/arm/lib/crt0.S @@ -128,7 +128,7 @@ clbss_l:cmp r0, r1 /* while not at end of BSS */ bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ #endif ldr r9, [r9, #GD_BD] /* r9 = gd->bd */ - sub r9, r9, #GD_SIZE /* new GD is below bd */ + sub r9, r9, #GENERATED_GBL_DATA_SIZE /* new GD is below bd */ adr lr, here ldr r0, [r9, #GD_RELOC_OFF] /* r0 = gd->reloc_off */ diff --git a/common/board_f.c b/common/board_f.c index fae2593d95..3cf90576f3 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -59,6 +59,7 @@ #endif #include #include +#include /* * Pointer to initial global data area @@ -533,6 +534,7 @@ static int reserve_board(void) gd->start_addr_sp -= 0x40; gd->start_addr_sp -= sizeof(bd_t); + gd->start_addr_sp = ALIGN(gd->start_addr_sp, 16); gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t)); memset(gd->bd, '\0', sizeof(bd_t)); debug("Reserving %zu Bytes for Board Info at: %08lx\n", @@ -552,7 +554,7 @@ static int setup_machine(void) static int reserve_global_data(void) { - gd->start_addr_sp -= sizeof(gd_t); + gd->start_addr_sp -= GENERATED_GBL_DATA_SIZE; gd->new_gd = (gd_t *)map_sysmem(gd->start_addr_sp, sizeof(gd_t)); debug("Reserving %zu Bytes for Global Data at: %08lx\n", sizeof(gd_t), gd->start_addr_sp); diff --git a/common/init/board_init.c b/common/init/board_init.c index 28291b1c07..369e311804 100644 --- a/common/init/board_init.c +++ b/common/init/board_init.c @@ -8,6 +8,7 @@ */ #include +#include DECLARE_GLOBAL_DATA_PTR; #define STACK_MARKER_LEN 32 @@ -40,8 +41,7 @@ ulong board_init_f_mem(ulong top) /* Leave space for the stack we are running with now */ top -= 0x40; - top -= sizeof(struct global_data); - top = ALIGN(top, 16); + top -= GENERATED_GBL_DATA_SIZE; gd_ptr = (struct global_data *)top; #ifdef _USE_MEMCPY memset(gd_ptr, '\0', sizeof(*gd));