From dc7584ffdca8eed6cc4e0466c461b0ce1d9edf38 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sat, 11 May 2013 22:32:43 +0000 Subject: [PATCH] Don't use the old stack-walking code with EABI ARM kernels or clang-compiled ARM kernels. This fixes a crash seen in clang-compiled ARM kernels that include WITNESS. This code could be easily modified to walk the stack for current clang-generated code (including EABI) but Andrew Turner has raised concerns that the stack frame currently emitted by clang isn't actually required by EABI so such a change might cause problems down the road. In case anyone wants to experiment, the change to support current clang-compiled kernels involves simply setting FR_RFP=0 and FR_SCP=1. --- sys/arm/arm/stack_machdep.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/arm/arm/stack_machdep.c b/sys/arm/arm/stack_machdep.c index a6032bc42869..d335934cf5a7 100644 --- a/sys/arm/arm/stack_machdep.c +++ b/sys/arm/arm/stack_machdep.c @@ -39,17 +39,16 @@ __FBSDID("$FreeBSD$"); static void stack_capture(struct stack *st, u_int32_t *frame) { +#if !defined(__ARM_EABI__) && !defined(__clang__) vm_offset_t callpc; - stack_zero(st); - while (1) { - if (!INKERNEL(frame)) - break; + while (INKERNEL(frame)) { callpc = frame[FR_SCP]; if (stack_put(st, callpc) == -1) break; frame = (u_int32_t *)(frame[FR_RFP]); } +#endif } void @@ -63,6 +62,7 @@ stack_save_td(struct stack *st, struct thread *td) panic("stack_save_td: running"); frame = (u_int32_t *)td->td_pcb->un_32.pcb32_r11; + stack_zero(st); stack_capture(st, frame); } @@ -72,5 +72,6 @@ stack_save(struct stack *st) u_int32_t *frame; frame = (u_int32_t *)__builtin_frame_address(0); + stack_zero(st); stack_capture(st, frame); }