Commit 8da51ee3 authored by Wayne Ren's avatar Wayne Ren Committed by Andrew Boie
Browse files

arch: arc: optimize the _SysFatalErrorHandler



* For STACK_CANERY, the processor should not hang
* as _SysFatalErrorHandler is always executed in
  isr context, so remove k_is_in_isr
* the function should return after k_thread_abort

Signed-off-by: default avatarWayne Ren <wei.ren@synopsys.com>
parent 24acf2a4
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -43,8 +43,7 @@ __weak void _SysFatalErrorHandler(unsigned int reason,
	ARG_UNUSED(pEsf);

#if !defined(CONFIG_SIMPLE_FATAL_ERROR_HANDLER)
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_ARC_STACK_CHECKING) \
	|| defined(CONFIG_STACK_SENTINEL)
#if defined(CONFIG_ARC_STACK_CHECKING) || defined(CONFIG_STACK_SENTINEL)
	if (reason == _NANO_ERR_STACK_CHK_FAIL) {
		goto hang_system;
	}
@@ -53,14 +52,17 @@ __weak void _SysFatalErrorHandler(unsigned int reason,
		goto hang_system;
	}

	if (k_is_in_isr() || _is_thread_essential()) {
		printk("Fatal fault in %s! Spinning...\n",
		       k_is_in_isr() ? "ISR" : "essential thread");
	if (_is_thread_essential()) {
		printk("Fatal fault in essential thread! Spinning...\n");
		goto hang_system;
	}

	printk("Fatal fault in thread %p! Aborting.\n", _current);

	k_thread_abort(_current);

	return;

hang_system:
#else
	ARG_UNUSED(reason);
@@ -69,5 +71,4 @@ hang_system:
	for (;;) {
		k_cpu_idle();
	}
	CODE_UNREACHABLE;
}