From 091faf85696905d36f685e562c03a5cc3a3b9fbc Mon Sep 17 00:00:00 2001 From: Jerome Forissier Date: Mon, 10 Oct 2016 18:25:13 +0200 Subject: [PATCH] arm32: unwind: print_stack() should create a more complete state Save general purpose registers and the frame pointer before starting the unwind operation. Also, set PC to the begining of the print_stack function since there's no point in going further. Fixes: https://github.com/OP-TEE/optee_os/issues/1069 Signed-off-by: Jerome Forissier --- core/arch/arm/kernel/unwind_arm32.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/arch/arm/kernel/unwind_arm32.c b/core/arch/arm/kernel/unwind_arm32.c index b8b53c84888..21ccefd39e4 100644 --- a/core/arch/arm/kernel/unwind_arm32.c +++ b/core/arch/arm/kernel/unwind_arm32.c @@ -367,10 +367,11 @@ void print_stack(int level) { struct unwind_state state; - memset(&state, 0, sizeof(state)); + asm volatile("stmia %0, {r0-r12}" :: "r" (state.registers) : "memory"); + state.registers[FP] = (uint32_t)__builtin_frame_address(0); state.registers[SP] = read_sp(); state.registers[LR] = read_lr(); - state.registers[PC] = read_pc(); + state.registers[PC] = (uint32_t)print_stack; do { switch (level) {