k_thread_abort(): assert if abort essential thread
Previously, this was only done if an essential thread self-exited, and was a runtime check that generated a kernel panic. Now if any thread has k_thread_abort() called on it, and that thread is essential to the system operation, this check is made. It is now an assertion. _NANO_ERR_INVALID_TASK_EXIT checks and printouts removed since this is now an assertion. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
7d627c5971
commit
8eaff5d6d2
15 changed files with 8 additions and 35 deletions
|
@ -44,10 +44,6 @@ FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
|
||||||
case _NANO_ERR_HW_EXCEPTION:
|
case _NANO_ERR_HW_EXCEPTION:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _NANO_ERR_INVALID_TASK_EXIT:
|
|
||||||
printk("***** Invalid Exit Software Error! *****\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_ARC_STACK_CHECKING)
|
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_ARC_STACK_CHECKING)
|
||||||
case _NANO_ERR_STACK_CHK_FAIL:
|
case _NANO_ERR_STACK_CHK_FAIL:
|
||||||
printk("***** Stack Check Fail! *****\n");
|
printk("***** Stack Check Fail! *****\n");
|
||||||
|
|
|
@ -46,10 +46,6 @@ void _NanoFatalErrorHandler(unsigned int reason,
|
||||||
const NANO_ESF *pEsf)
|
const NANO_ESF *pEsf)
|
||||||
{
|
{
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case _NANO_ERR_INVALID_TASK_EXIT:
|
|
||||||
printk("***** Invalid Exit Software Error! *****\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL)
|
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL)
|
||||||
case _NANO_ERR_STACK_CHK_FAIL:
|
case _NANO_ERR_STACK_CHK_FAIL:
|
||||||
printk("***** Stack Check Fail! *****\n");
|
printk("***** Stack Check Fail! *****\n");
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <linker/sections.h>
|
#include <linker/sections.h>
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
#include <wait_q.h>
|
#include <wait_q.h>
|
||||||
|
#include <misc/__assert.h>
|
||||||
|
|
||||||
extern void _k_thread_single_abort(struct k_thread *thread);
|
extern void _k_thread_single_abort(struct k_thread *thread);
|
||||||
|
|
||||||
|
@ -31,6 +32,9 @@ void k_thread_abort(k_tid_t thread)
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
|
|
||||||
|
__ASSERT(!(thread->base.user_options & K_ESSENTIAL),
|
||||||
|
"essential thread aborted");
|
||||||
|
|
||||||
_k_thread_single_abort(thread);
|
_k_thread_single_abort(thread);
|
||||||
_thread_monitor_exit(thread);
|
_thread_monitor_exit(thread);
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,6 @@ FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
|
||||||
case _NANO_ERR_SPURIOUS_INT:
|
case _NANO_ERR_SPURIOUS_INT:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _NANO_ERR_INVALID_TASK_EXIT:
|
|
||||||
printk("***** Invalid Exit Software Error! *****\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case _NANO_ERR_ALLOCATION_FAIL:
|
case _NANO_ERR_ALLOCATION_FAIL:
|
||||||
printk("**** Kernel Allocation Failure! ****\n");
|
printk("**** Kernel Allocation Failure! ****\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -65,10 +65,6 @@ FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
|
||||||
case _NANO_ERR_SPURIOUS_INT:
|
case _NANO_ERR_SPURIOUS_INT:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _NANO_ERR_INVALID_TASK_EXIT:
|
|
||||||
printk("***** Invalid Exit Software Error! *****\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL)
|
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL)
|
||||||
case _NANO_ERR_STACK_CHK_FAIL:
|
case _NANO_ERR_STACK_CHK_FAIL:
|
||||||
printk("***** Stack Check Fail! *****\n");
|
printk("***** Stack Check Fail! *****\n");
|
||||||
|
|
|
@ -64,10 +64,6 @@ FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
|
||||||
printk("*****\n");
|
printk("*****\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _NANO_ERR_INVALID_TASK_EXIT:
|
|
||||||
printk("***** Invalid Exit Software Error! *****\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL) || \
|
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL) || \
|
||||||
defined(CONFIG_X86_STACK_PROTECTION)
|
defined(CONFIG_X86_STACK_PROTECTION)
|
||||||
case _NANO_ERR_STACK_CHK_FAIL:
|
case _NANO_ERR_STACK_CHK_FAIL:
|
||||||
|
|
|
@ -52,9 +52,6 @@ FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
|
||||||
case _NANO_ERR_RESERVED_IRQ:
|
case _NANO_ERR_RESERVED_IRQ:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _NANO_ERR_INVALID_TASK_EXIT:
|
|
||||||
printk("***** Invalid Exit Software Error! *****\n");
|
|
||||||
break;
|
|
||||||
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL)
|
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL)
|
||||||
case _NANO_ERR_STACK_CHK_FAIL:
|
case _NANO_ERR_STACK_CHK_FAIL:
|
||||||
printk("***** Stack Check Fail! *****\n");
|
printk("***** Stack Check Fail! *****\n");
|
||||||
|
|
|
@ -28,7 +28,6 @@ extern void _SysFatalErrorHandler(unsigned int cause, const NANO_ESF *esf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _NANO_ERR_HW_EXCEPTION (0) /* MPU/Bus/Usage fault */
|
#define _NANO_ERR_HW_EXCEPTION (0) /* MPU/Bus/Usage fault */
|
||||||
#define _NANO_ERR_INVALID_TASK_EXIT (1) /* Invalid task exit */
|
|
||||||
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
||||||
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
||||||
#define _NANO_ERR_KERNEL_OOPS (4) /* Kernel oops (fatal to thread) */
|
#define _NANO_ERR_KERNEL_OOPS (4) /* Kernel oops (fatal to thread) */
|
||||||
|
|
|
@ -26,7 +26,6 @@ extern void _SysFatalErrorHandler(unsigned int reason, const NANO_ESF *esf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _NANO_ERR_HW_EXCEPTION (0) /* MPU/Bus/Usage fault */
|
#define _NANO_ERR_HW_EXCEPTION (0) /* MPU/Bus/Usage fault */
|
||||||
#define _NANO_ERR_INVALID_TASK_EXIT (1) /* Invalid task exit */
|
|
||||||
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
||||||
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
||||||
#define _NANO_ERR_KERNEL_OOPS (4) /* Kernel oops (fatal to thread) */
|
#define _NANO_ERR_KERNEL_OOPS (4) /* Kernel oops (fatal to thread) */
|
||||||
|
|
|
@ -25,7 +25,6 @@ extern "C" {
|
||||||
#define STACK_ALIGN 4
|
#define STACK_ALIGN 4
|
||||||
|
|
||||||
#define _NANO_ERR_CPU_EXCEPTION (0) /* Any unhandled exception */
|
#define _NANO_ERR_CPU_EXCEPTION (0) /* Any unhandled exception */
|
||||||
#define _NANO_ERR_INVALID_TASK_EXIT (1) /* Invalid task exit */
|
|
||||||
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
||||||
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
||||||
#define _NANO_ERR_SPURIOUS_INT (4) /* Spurious interrupt */
|
#define _NANO_ERR_SPURIOUS_INT (4) /* Spurious interrupt */
|
||||||
|
|
|
@ -69,7 +69,6 @@ extern void _SysFatalErrorHandler(unsigned int reason,
|
||||||
#endif /* _ASMLANGUAGE */
|
#endif /* _ASMLANGUAGE */
|
||||||
|
|
||||||
#define _NANO_ERR_CPU_EXCEPTION (0) /* Any unhandled exception */
|
#define _NANO_ERR_CPU_EXCEPTION (0) /* Any unhandled exception */
|
||||||
#define _NANO_ERR_INVALID_TASK_EXIT (1) /* Invalid task exit */
|
|
||||||
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
||||||
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
||||||
#define _NANO_ERR_SPURIOUS_INT (4) /* Spurious interrupt */
|
#define _NANO_ERR_SPURIOUS_INT (4) /* Spurious interrupt */
|
||||||
|
|
|
@ -358,8 +358,6 @@ typedef struct nanoIsf {
|
||||||
#define _NANO_ERR_PAGE_FAULT (1)
|
#define _NANO_ERR_PAGE_FAULT (1)
|
||||||
/** General protection fault */
|
/** General protection fault */
|
||||||
#define _NANO_ERR_GEN_PROT_FAULT (2)
|
#define _NANO_ERR_GEN_PROT_FAULT (2)
|
||||||
/** Invalid task exit */
|
|
||||||
#define _NANO_ERR_INVALID_TASK_EXIT (3)
|
|
||||||
/** Stack corruption detected */
|
/** Stack corruption detected */
|
||||||
#define _NANO_ERR_STACK_CHK_FAIL (4)
|
#define _NANO_ERR_STACK_CHK_FAIL (4)
|
||||||
/** Kernel Allocation Failure */
|
/** Kernel Allocation Failure */
|
||||||
|
|
|
@ -31,7 +31,6 @@ extern "C" {
|
||||||
#define SIZEOFUNIT_TO_OCTET(X) (X)
|
#define SIZEOFUNIT_TO_OCTET(X) (X)
|
||||||
|
|
||||||
#define _NANO_ERR_HW_EXCEPTION (0) /* MPU/Bus/Usage fault */
|
#define _NANO_ERR_HW_EXCEPTION (0) /* MPU/Bus/Usage fault */
|
||||||
#define _NANO_ERR_INVALID_TASK_EXIT (1) /* Invalid task exit */
|
|
||||||
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
||||||
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
||||||
#define _NANO_ERR_RESERVED_IRQ (4) /* Reserved interrupt */
|
#define _NANO_ERR_RESERVED_IRQ (4) /* Reserved interrupt */
|
||||||
|
|
|
@ -189,10 +189,6 @@ FUNC_NORETURN void _thread_entry(void (*entry)(void *, void *, void *),
|
||||||
_check_stack_sentinel();
|
_check_stack_sentinel();
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_MULTITHREADING
|
||||||
if (_is_thread_essential()) {
|
|
||||||
_k_except_reason(_NANO_ERR_INVALID_TASK_EXIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
k_thread_abort(_current);
|
k_thread_abort(_current);
|
||||||
#else
|
#else
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <linker/sections.h>
|
#include <linker/sections.h>
|
||||||
#include <wait_q.h>
|
#include <wait_q.h>
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
|
#include <misc/__assert.h>
|
||||||
|
|
||||||
extern void _k_thread_single_abort(struct k_thread *thread);
|
extern void _k_thread_single_abort(struct k_thread *thread);
|
||||||
|
|
||||||
|
@ -28,6 +29,9 @@ void k_thread_abort(k_tid_t thread)
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
|
|
||||||
|
__ASSERT(!(thread->base.user_options & K_ESSENTIAL),
|
||||||
|
"essential thread aborted");
|
||||||
|
|
||||||
_k_thread_single_abort(thread);
|
_k_thread_single_abort(thread);
|
||||||
_thread_monitor_exit(thread);
|
_thread_monitor_exit(thread);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue