Index: sys/arm64/arm64/exception.S =================================================================== --- sys/arm64/arm64/exception.S +++ sys/arm64/arm64/exception.S @@ -25,6 +25,9 @@ * */ +#include "opt_ddb.h" +#include "opt_stack.h" + #include #include __FBSDID("$FreeBSD$"); @@ -33,6 +36,13 @@ .text +#if defined(KDTRACE_HOOKS) || defined(STACK) +#define EXTRA_FRAME_SPACE (8 * 2) +#define SAVE_FP +#else +#define EXTRA_FRAME_SPACE 0 +#endif + /* * This is limited to 28 instructions as it's placed in the exception vector * slot that is 32 instructions long. We need one for the branch, and three @@ -43,7 +53,7 @@ mov x18, sp sub sp, sp, #128 .endif - sub sp, sp, #(TF_SIZE) + sub sp, sp, #(TF_SIZE + EXTRA_FRAME_SPACE) stp x28, x29, [sp, #(TF_X + 28 * 8)] stp x26, x27, [sp, #(TF_X + 26 * 8)] stp x24, x25, [sp, #(TF_X + 24 * 8)] @@ -60,6 +70,17 @@ stp x2, x3, [sp, #(TF_X + 2 * 8)] stp x0, x1, [sp, #(TF_X + 0 * 8)] mrs x10, elr_el1 +#if defined(SAVE_FP) + /* + * Save a stack frame so the in-kernel stack unwinder can get past + * the exception. + */ +.if \el == 1 + stp x29, x10, [sp, #(TF_SIZE)] +.else + stp xzr, xzr, [sp, #(TF_SIZE)] +.endif +#endif mrs x11, spsr_el1 mrs x12, esr_el1 .if \el == 0 @@ -69,7 +90,9 @@ stp w11, w12, [sp, #(TF_SPSR)] stp x18, lr, [sp, #(TF_SP)] mrs x18, tpidr_el1 +#if defined(SAVE_FP) add x29, sp, #(TF_SIZE) +#endif .endm .macro save_registers el @@ -158,7 +181,7 @@ ldr x29, [sp, #(TF_X + 29 * 8)] .endif .if \el == 0 - add sp, sp, #(TF_SIZE) + add sp, sp, #(TF_SIZE + EXTRA_FRAME_SPACE) .else mov sp, x18 mrs x18, tpidr_el1