diff --git a/arch/arc/core/fault.c b/arch/arc/core/fault.c index 065ed2df24a..da4af705f3a 100644 --- a/arch/arc/core/fault.c +++ b/arch/arc/core/fault.c @@ -20,7 +20,6 @@ #include #include -u32_t arc_exc_saved_sp; #ifdef CONFIG_USERSPACE Z_EXC_DECLARE(z_arch_user_string_nlen); @@ -363,7 +362,7 @@ static void dump_exception_info(u32_t vector, u32_t cause, u32_t parameter) * invokes the user provided routine k_sys_fatal_error_handler() which is * responsible for implementing the error handling policy. */ -void _Fault(z_arch_esf_t *esf) +void _Fault(z_arch_esf_t *esf, u32_t old_sp) { u32_t vector, cause, parameter; u32_t exc_addr = z_arc_v2_aux_reg_read(_ARC_V2_EFA); @@ -413,7 +412,7 @@ void _Fault(z_arch_esf_t *esf) #ifdef CONFIG_MPU_STACK_GUARD if (vector == ARC_EV_PROT_V && ((parameter == 0x4) || (parameter == 0x24))) { - if (z_check_thread_stack_fail(exc_addr, arc_exc_saved_sp)) { + if (z_check_thread_stack_fail(exc_addr, old_sp)) { z_arc_fatal_error(K_ERR_STACK_CHK_FAIL, esf); return; } diff --git a/arch/arc/core/fault_s.S b/arch/arc/core/fault_s.S index 86b087069ad..bc1b1dea3ea 100644 --- a/arch/arc/core/fault_s.S +++ b/arch/arc/core/fault_s.S @@ -39,7 +39,6 @@ GTEXT(z_irq_do_offload); #endif GDATA(exc_nest_count) -GDATA(arc_exc_saved_sWWp) /* the necessary stack size for exception handling */ #define EXCEPTION_STACK_SIZE 384 @@ -62,7 +61,7 @@ SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_dc_error) SECTION_SUBSEC_FUNC(TEXT,__fault,__ev_maligned) _exc_entry: - st sp, [arc_exc_saved_sp] + mov_s ilink, sp /* * re-use the top part of interrupt stack as exception * stack. If this top part is used by interrupt handling, @@ -94,6 +93,8 @@ _exc_entry: /* sp is parameter of _Fault */ mov r0, sp + /* ilink is the thread's original sp */ + mov r1, ilink jl _Fault _exc_return: @@ -142,7 +143,7 @@ _exc_return_from_exc: sr r0, [_ARC_V2_ERET] _pop_irq_stack_frame - ld sp, [arc_exc_saved_sp] + mov sp, ilink rtie