mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
sched/irq: add a check for the interrupt stack in irq_dispatch
After irq_dispatch finished, the interrupt stack will be checked to determine whether overflow occurs. The relevant configuration reuses the configuration of stack overflow detection during context switching. Signed-off-by: guoshengyuan1 <guoshengyuan1@xiaomi.com>
This commit is contained in:
committed by
Xiang Xiao
parent
a0ffe03ec5
commit
ca7608c2ac
@@ -226,10 +226,14 @@ size_t up_check_tcbstack(struct tcb_s *tcb, size_t check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
return arm_stack_check((void *)up_get_intstackbase(cpu),
|
if (check_size == 0)
|
||||||
STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
|
{
|
||||||
|
check_size = STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return arm_stack_check((void *)up_get_intstackbase(cpu), check_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -236,10 +236,14 @@ size_t up_check_tcbstack(struct tcb_s *tcb, size_t check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 7
|
#if CONFIG_ARCH_INTERRUPTSTACK > 7
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
return arm64_stack_check((void *)up_get_intstackbase(cpu),
|
if (check_size == 0)
|
||||||
STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
|
{
|
||||||
|
check_size = STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return arm64_stack_check((void *)up_get_intstackbase(cpu), check_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -150,10 +150,14 @@ size_t up_check_tcbstack(FAR struct tcb_s *tcb, size_t check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
uintptr_t start = (uintptr_t)g_intstackalloc;
|
if (check_size == 0)
|
||||||
return avr_stack_check(start, CONFIG_ARCH_INTERRUPTSTACK & ~3);
|
{
|
||||||
|
check_size = CONFIG_ARCH_INTERRUPTSTACK & ~3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return avr_stack_check((uintptr_t)g_intstackalloc, check_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -144,10 +144,14 @@ size_t up_check_tcbstack(struct tcb_s *tcb, size_t check_size)
|
|||||||
return ceva_stack_check((uintptr_t)tcb->stack_alloc_ptr, check_size);
|
return ceva_stack_check((uintptr_t)tcb->stack_alloc_ptr, check_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
return ceva_stack_check((uintptr_t)g_intstackalloc,
|
if (check_size == 0)
|
||||||
g_intstackbase - g_intstackalloc);
|
{
|
||||||
|
check_size = g_intstackbase - g_intstackalloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ceva_stack_check((uintptr_t)g_intstackalloc, check_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_STACK_COLORATION */
|
#endif /* CONFIG_STACK_COLORATION */
|
||||||
|
|||||||
@@ -121,10 +121,14 @@ size_t up_check_tcbstack(struct tcb_s *tcb, size_t check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
return or1k_stack_check((uintptr_t)g_intstackalloc,
|
if (check_size == 0)
|
||||||
(CONFIG_ARCH_INTERRUPTSTACK & ~3));
|
{
|
||||||
|
check_size = CONFIG_ARCH_INTERRUPTSTACK & ~3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return or1k_stack_check((uintptr_t)g_intstackalloc, check_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -182,10 +182,14 @@ size_t up_check_tcbstack(struct tcb_s *tcb, size_t check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
return riscv_stack_check((uintptr_t)g_intstackalloc,
|
if (check_size == 0)
|
||||||
(CONFIG_ARCH_INTERRUPTSTACK & ~15));
|
{
|
||||||
|
check_size = CONFIG_ARCH_INTERRUPTSTACK & ~15;
|
||||||
|
}
|
||||||
|
|
||||||
|
return riscv_stack_check((uintptr_t)g_intstackalloc, check_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -206,10 +206,14 @@ size_t up_check_tcbstack(struct tcb_s *tcb, size_t check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 7
|
#if CONFIG_ARCH_INTERRUPTSTACK > 7
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
return sparc_stack_check((void *)up_get_intstackbase(cpu),
|
if (check_size == 0)
|
||||||
STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
|
{
|
||||||
|
check_size = STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sparc_stack_check((void *)up_get_intstackbase(cpu), check_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -143,10 +143,14 @@ size_t up_check_tcbstack(struct tcb_s *tcb, size_t check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
return tricore_stack_check((uintptr_t)g_intstackalloc,
|
if (check_size == 0)
|
||||||
(CONFIG_ARCH_INTERRUPTSTACK & ~15));
|
{
|
||||||
|
check_size = CONFIG_ARCH_INTERRUPTSTACK & ~15;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tricore_stack_check((uintptr_t)g_intstackalloc, check_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -180,10 +180,14 @@ size_t up_check_tcbstack(struct tcb_s *tcb, size_t check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
return x86_64_stack_check((void *)up_get_intstackbase(cpu),
|
if (check_size == 0)
|
||||||
STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
|
{
|
||||||
|
check_size = STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return x86_64_stack_check((void *)up_get_intstackbase(cpu), check_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -164,9 +164,14 @@ size_t up_check_tcbstack(struct tcb_s *tcb, size_t check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
#if CONFIG_ARCH_INTERRUPTSTACK > 15
|
||||||
size_t up_check_intstack(int cpu)
|
size_t up_check_intstack(int cpu, size_t check_size)
|
||||||
{
|
{
|
||||||
return xtensa_stack_check(up_get_intstackbase(cpu), INTSTACK_SIZE);
|
if (check_size == 0)
|
||||||
|
{
|
||||||
|
check_size = INTSTACK_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return xtensa_stack_check(up_get_intstackbase(cpu), check_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -2565,7 +2565,7 @@ void irq_dispatch(int irq, FAR void *context);
|
|||||||
struct tcb_s;
|
struct tcb_s;
|
||||||
size_t up_check_tcbstack(FAR struct tcb_s *tcb, size_t check_size);
|
size_t up_check_tcbstack(FAR struct tcb_s *tcb, size_t check_size);
|
||||||
#if defined(CONFIG_ARCH_INTERRUPTSTACK) && CONFIG_ARCH_INTERRUPTSTACK > 3
|
#if defined(CONFIG_ARCH_INTERRUPTSTACK) && CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||||
size_t up_check_intstack(int cpu);
|
size_t up_check_intstack(int cpu, size_t check_size);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -157,4 +157,9 @@ void irq_dispatch(int irq, FAR void *context)
|
|||||||
kmm_checkcorruption();
|
kmm_checkcorruption();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_STACKCHECK_SOFTWARE) && CONFIG_STACKCHECK_MARGIN > 0
|
||||||
|
DEBUGASSERT(up_check_intstack(this_cpu(),
|
||||||
|
CONFIG_STACKCHECK_MARGIN) == 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -296,7 +296,7 @@ static void dump_stacks(FAR struct tcb_s *rtcb, uintptr_t sp)
|
|||||||
intstack_base,
|
intstack_base,
|
||||||
intstack_size,
|
intstack_size,
|
||||||
#ifdef CONFIG_STACK_COLORATION
|
#ifdef CONFIG_STACK_COLORATION
|
||||||
up_check_intstack(cpu)
|
up_check_intstack(cpu, 0)
|
||||||
#else
|
#else
|
||||||
0
|
0
|
||||||
#endif
|
#endif
|
||||||
@@ -500,7 +500,7 @@ static void dump_tasks(void)
|
|||||||
for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++)
|
for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++)
|
||||||
{
|
{
|
||||||
# ifdef CONFIG_STACK_COLORATION
|
# ifdef CONFIG_STACK_COLORATION
|
||||||
size_t stack_used = up_check_intstack(cpu);
|
size_t stack_used = up_check_intstack(cpu, 0);
|
||||||
size_t stack_filled = 0;
|
size_t stack_filled = 0;
|
||||||
|
|
||||||
if (stack_used > 0)
|
if (stack_used > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user