From d553515758f3c8639e507035e74224c916b041dd Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Thu, 22 Oct 2020 14:06:31 +0900 Subject: [PATCH] armv7-m, cxd56xx, lc823450: Refactor interrupt stack related code Summary: - Remove +4/-8 offset coding - Also, fix alignments for g_intstackalloc - NOTE: stack pointer alignment is 8-byte Impact: - Affects armv7-m with interrupt stack enabled Testing: - Tested with spresense:wifi_smp - Tested with lc823450:smp - Tested with stm32f4discovery:wifi Signed-off-by: Masayuki Ishikawa --- arch/arm/src/armv7-m/arm_assert.c | 2 +- arch/arm/src/armv7-m/gnu/arm_exception.S | 6 +++--- arch/arm/src/armv7-m/gnu/arm_lazyexception.S | 6 +++--- arch/arm/src/cxd56xx/cxd56_irq.c | 14 +++++++------- arch/arm/src/lc823450/lc823450_irq.c | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/arm/src/armv7-m/arm_assert.c b/arch/arm/src/armv7-m/arm_assert.c index 382297f202b..c1a29cdd60b 100644 --- a/arch/arm/src/armv7-m/arm_assert.c +++ b/arch/arm/src/armv7-m/arm_assert.c @@ -244,7 +244,7 @@ static void up_dumpstate(void) * stack? */ - if (sp <= istackbase && sp > istackbase - istacksize) + if (sp < istackbase && sp > istackbase - istacksize) { /* Yes.. dump the interrupt stack */ diff --git a/arch/arm/src/armv7-m/gnu/arm_exception.S b/arch/arm/src/armv7-m/gnu/arm_exception.S index b9580eeec57..34e5031264c 100644 --- a/arch/arm/src/armv7-m/gnu/arm_exception.S +++ b/arch/arm/src/armv7-m/gnu/arm_exception.S @@ -67,7 +67,7 @@ * no privileged task has run. */ -# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 4 +# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 8 # error Interrupt stack must be used with high priority interrupts in kernel mode # endif @@ -197,7 +197,7 @@ exception_common: * here prohibits nested interrupts without some additional logic! */ - setintstack r2, r3 + setintstack r2, r3 /* SP = IRQ stack top */ #else /* Otherwise, we will re-use the interrupted thread's stack. That may @@ -321,7 +321,7 @@ exception_common: .bss .global g_intstackalloc .global g_intstackbase - .align 8 + .balign 8 g_intstackalloc: .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: diff --git a/arch/arm/src/armv7-m/gnu/arm_lazyexception.S b/arch/arm/src/armv7-m/gnu/arm_lazyexception.S index 57ee25096ff..9d15f901eeb 100644 --- a/arch/arm/src/armv7-m/gnu/arm_lazyexception.S +++ b/arch/arm/src/armv7-m/gnu/arm_lazyexception.S @@ -50,7 +50,7 @@ * nested interrupt, the interrupt stack if no privileged task has run. */ -# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 4 +# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 8 # error Interrupt stack must be used with high priority interrupts in kernel mode # endif @@ -192,7 +192,7 @@ exception_common: * here prohibits nested interrupts without some additional logic! */ - setintstack r2, r3 + setintstack r2, r3 /* SP = IRQ stack top */ #else /* Otherwise, we will re-use the interrupted thread's stack. That may @@ -340,7 +340,7 @@ exception_common: .bss .global g_intstackalloc .global g_intstackbase - .align 8 + .balign 8 g_intstackalloc: .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: diff --git a/arch/arm/src/cxd56xx/cxd56_irq.c b/arch/arm/src/cxd56xx/cxd56_irq.c index f113dcef06f..d59872e6157 100644 --- a/arch/arm/src/cxd56xx/cxd56_irq.c +++ b/arch/arm/src/cxd56xx/cxd56_irq.c @@ -112,17 +112,17 @@ static uint64_t g_intstack_alloc[INTSTACK_ALLOC >> 3]; const uint32_t g_cpu_intstack_top[CONFIG_SMP_NCPUS] = { - (uint32_t)g_intstack_alloc + INTSTACK_SIZE - 8, + (uint32_t)g_intstack_alloc + INTSTACK_SIZE, #if CONFIG_SMP_NCPUS > 1 - (uint32_t)g_intstack_alloc + (2 * INTSTACK_SIZE) - 8, + (uint32_t)g_intstack_alloc + (2 * INTSTACK_SIZE), #if CONFIG_SMP_NCPUS > 2 - (uint32_t)g_intstack_alloc + (3 * INTSTACK_SIZE) - 8, + (uint32_t)g_intstack_alloc + (3 * INTSTACK_SIZE), #if CONFIG_SMP_NCPUS > 3 - (uint32_t)g_intstack_alloc + (4 * INTSTACK_SIZE) - 8, + (uint32_t)g_intstack_alloc + (4 * INTSTACK_SIZE), #if CONFIG_SMP_NCPUS > 4 - (uint32_t)g_intstack_alloc + (5 * INTSTACK_SIZE) - 8, + (uint32_t)g_intstack_alloc + (5 * INTSTACK_SIZE), #if CONFIG_SMP_NCPUS > 5 - (uint32_t)g_intstack_alloc + (6 * INTSTACK_SIZE) - 8, + (uint32_t)g_intstack_alloc + (6 * INTSTACK_SIZE), #endif /* CONFIG_SMP_NCPUS > 5 */ #endif /* CONFIG_SMP_NCPUS > 4 */ #endif /* CONFIG_SMP_NCPUS > 3 */ @@ -667,6 +667,6 @@ uintptr_t arm_intstack_base(void) #if defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7 uintptr_t arm_intstack_alloc(void) { - return g_cpu_intstack_top[up_cpu_index()] - (INTSTACK_SIZE - 8); + return g_cpu_intstack_top[up_cpu_index()] - INTSTACK_SIZE; } #endif diff --git a/arch/arm/src/lc823450/lc823450_irq.c b/arch/arm/src/lc823450/lc823450_irq.c index 4e0beaa0715..4583ae95f5e 100644 --- a/arch/arm/src/lc823450/lc823450_irq.c +++ b/arch/arm/src/lc823450/lc823450_irq.c @@ -95,9 +95,9 @@ uint64_t g_intstack_alloc[INTSTACK_ALLOC >> 3]; const uint32_t g_cpu_intstack_top[CONFIG_SMP_NCPUS] = { - (uint32_t)g_intstack_alloc + INTSTACK_SIZE - 8, + (uint32_t)g_intstack_alloc + INTSTACK_SIZE, #if CONFIG_SMP_NCPUS > 1 - (uint32_t)g_intstack_alloc + (2 * INTSTACK_SIZE) - 8, + (uint32_t)g_intstack_alloc + (2 * INTSTACK_SIZE), #endif /* CONFIG_SMP_NCPUS > 1 */ }; #endif @@ -888,6 +888,6 @@ uintptr_t arm_intstack_base(void) #if defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7 uintptr_t arm_intstack_alloc(void) { - return g_cpu_intstack_top[up_cpu_index()] - (INTSTACK_SIZE - 8); + return g_cpu_intstack_top[up_cpu_index()] - INTSTACK_SIZE; } #endif