From 86400a252dcbe6e4aef3ecca000b469a0fe96b67 Mon Sep 17 00:00:00 2001 From: David Cabecinhas Date: Tue, 14 Mar 2017 18:22:18 +0800 Subject: [PATCH] ARM: Fix off-by-one interrupt stack allocation in 8-byte aligned architectures --- arch/arm/src/armv7-m/gnu/up_exception.S | 2 +- arch/arm/src/armv7-m/gnu/up_lazyexception.S | 4 ++-- arch/arm/src/common/up_initialize.c | 2 +- arch/arm/src/kinetis/kinetis_vectors.S | 2 +- arch/arm/src/lpc17xx/lpc17_vectors.S | 4 ++-- arch/arm/src/sam34/sam_vectors.S | 4 ++-- arch/arm/src/stm32/gnu/stm32_vectors.S | 2 +- arch/arm/src/stm32/iar/stm32_vectors.S | 2 +- arch/arm/src/tiva/tiva_vectors.S | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/arm/src/armv7-m/gnu/up_exception.S b/arch/arm/src/armv7-m/gnu/up_exception.S index 0010136b03..4f2927b421 100644 --- a/arch/arm/src/armv7-m/gnu/up_exception.S +++ b/arch/arm/src/armv7-m/gnu/up_exception.S @@ -323,7 +323,7 @@ exception_common: .global g_intstackbase .align 8 g_intstackalloc: - .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: .size g_intstackalloc, .-g_intstackalloc #endif diff --git a/arch/arm/src/armv7-m/gnu/up_lazyexception.S b/arch/arm/src/armv7-m/gnu/up_lazyexception.S index 08ce8be75c..eb3e27057b 100644 --- a/arch/arm/src/armv7-m/gnu/up_lazyexception.S +++ b/arch/arm/src/armv7-m/gnu/up_lazyexception.S @@ -235,7 +235,7 @@ exception_common: * * Here: * r0 = Address of the register save area - + * NOTE: It is a requirement that up_restorefpu() preserve the value of * r0! */ @@ -355,7 +355,7 @@ exception_common: .global g_intstackbase .align 8 g_intstackalloc: - .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: .size g_intstackalloc, .-g_intstackalloc #endif diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index 267f5e1c59..ff11e45170 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -106,7 +106,7 @@ static inline void up_color_intstack(void) uint32_t *ptr = (uint32_t *)&g_intstackalloc; ssize_t size; - for (size = (CONFIG_ARCH_INTERRUPTSTACK & ~7); + for (size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); size > 0; size -= sizeof(uint32_t)) { diff --git a/arch/arm/src/kinetis/kinetis_vectors.S b/arch/arm/src/kinetis/kinetis_vectors.S index 48c74c7059..30940199af 100644 --- a/arch/arm/src/kinetis/kinetis_vectors.S +++ b/arch/arm/src/kinetis/kinetis_vectors.S @@ -484,7 +484,7 @@ exception_common: .global g_intstackbase .align 8 g_intstackalloc: - .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: .size g_intstackalloc, .-g_intstackalloc #endif diff --git a/arch/arm/src/lpc17xx/lpc17_vectors.S b/arch/arm/src/lpc17xx/lpc17_vectors.S index 6cee7d9731..988147263e 100644 --- a/arch/arm/src/lpc17xx/lpc17_vectors.S +++ b/arch/arm/src/lpc17xx/lpc17_vectors.S @@ -348,7 +348,7 @@ exception_common: * * Here: * r0 = Address of the register save area - + * NOTE: It is a requirement that up_restorefpu() preserve the value of * r0! */ @@ -468,7 +468,7 @@ exception_common: .global g_intstackbase .align 8 g_intstackalloc: - .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: .size g_intstackalloc, .-g_intstackalloc #endif diff --git a/arch/arm/src/sam34/sam_vectors.S b/arch/arm/src/sam34/sam_vectors.S index 9765f61474..9de7d247a9 100644 --- a/arch/arm/src/sam34/sam_vectors.S +++ b/arch/arm/src/sam34/sam_vectors.S @@ -362,7 +362,7 @@ exception_common: * * Here: * r0 = Address of the register save area - + * NOTE: It is a requirement that up_restorefpu() preserve the value of * r0! */ @@ -482,7 +482,7 @@ exception_common: .global g_intstackbase .align 8 g_intstackalloc: - .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: .size g_intstackalloc, .-g_intstackalloc #endif diff --git a/arch/arm/src/stm32/gnu/stm32_vectors.S b/arch/arm/src/stm32/gnu/stm32_vectors.S index 31f62c8d11..c961781f33 100644 --- a/arch/arm/src/stm32/gnu/stm32_vectors.S +++ b/arch/arm/src/stm32/gnu/stm32_vectors.S @@ -497,7 +497,7 @@ exception_common: .global g_intstackbase .align 8 g_intstackalloc: - .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: .size g_intstackalloc, .-g_intstackalloc #endif diff --git a/arch/arm/src/stm32/iar/stm32_vectors.S b/arch/arm/src/stm32/iar/stm32_vectors.S index cf83e7b8bf..f46cb7c57b 100644 --- a/arch/arm/src/stm32/iar/stm32_vectors.S +++ b/arch/arm/src/stm32/iar/stm32_vectors.S @@ -1055,7 +1055,7 @@ l5: .global g_intstackbase .align 8 g_intstackalloc: - .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: .size g_intstackalloc, .-g_intstackalloc #endif diff --git a/arch/arm/src/tiva/tiva_vectors.S b/arch/arm/src/tiva/tiva_vectors.S index 4f56269ba4..943581c2e1 100644 --- a/arch/arm/src/tiva/tiva_vectors.S +++ b/arch/arm/src/tiva/tiva_vectors.S @@ -339,7 +339,7 @@ exception_common: * * Here: * r0 = Address of the register save area - + * NOTE: It is a requirement that up_restorefpu() preserve the value of * r0! */ @@ -459,7 +459,7 @@ exception_common: .global g_intstackbase .align 8 g_intstackalloc: - .skip (CONFIG_ARCH_INTERRUPTSTACK & ~7) + .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) g_intstackbase: .size g_intstackalloc, .-g_intstackalloc #endif