From a6da3c2cb6a214b642fa09c48638f1442fdf9117 Mon Sep 17 00:00:00 2001 From: Ouss4 Date: Thu, 7 May 2020 18:50:07 +0100 Subject: [PATCH] arch/*/*_checkstack.c: Get aligned address only when CONFIG_TLS_ALIGNED is enabled. --- arch/arm/src/common/arm_checkstack.c | 1 + arch/or1k/src/common/up_checkstack.c | 5 +++++ arch/risc-v/src/common/riscv_checkstack.c | 5 +++++ arch/xtensa/src/common/xtensa_checkstack.c | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/arch/arm/src/common/arm_checkstack.c b/arch/arm/src/common/arm_checkstack.c index 5ac36fd06e..ebdab95e91 100644 --- a/arch/arm/src/common/arm_checkstack.c +++ b/arch/arm/src/common/arm_checkstack.c @@ -108,6 +108,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) UNUSED(int_stack); start = alloc & ~3; #endif + end = (alloc + size + 3) & ~3; /* Get the adjusted size based on the top and bottom of the stack */ diff --git a/arch/or1k/src/common/up_checkstack.c b/arch/or1k/src/common/up_checkstack.c index 964e60085e..e6f4cd9326 100644 --- a/arch/or1k/src/common/up_checkstack.c +++ b/arch/or1k/src/common/up_checkstack.c @@ -97,6 +97,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) /* Get aligned addresses of the top and bottom of the stack */ +#ifdef CONFIG_TLS_ALIGNED if (!int_stack) { /* Skip over the TLS data structure at the bottom of the stack */ @@ -108,6 +109,10 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) { start = alloc & ~3; } +#else + UNUSED(int_stack); + start = alloc & ~3; +#endif end = (alloc + size + 3) & ~3; diff --git a/arch/risc-v/src/common/riscv_checkstack.c b/arch/risc-v/src/common/riscv_checkstack.c index c42707afda..a8f28fa8db 100644 --- a/arch/risc-v/src/common/riscv_checkstack.c +++ b/arch/risc-v/src/common/riscv_checkstack.c @@ -91,6 +91,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) /* Get aligned addresses of the top and bottom of the stack */ +#ifdef CONFIG_TLS_ALIGNED if (!int_stack) { /* Skip over the TLS data structure at the bottom of the stack */ @@ -102,6 +103,10 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) { start = alloc & ~3; } +#else + UNUSED(int_stack); + start = alloc & ~3; +#endif end = (alloc + size + 3) & ~3; diff --git a/arch/xtensa/src/common/xtensa_checkstack.c b/arch/xtensa/src/common/xtensa_checkstack.c index d9509c9b3f..cbac16a0d2 100644 --- a/arch/xtensa/src/common/xtensa_checkstack.c +++ b/arch/xtensa/src/common/xtensa_checkstack.c @@ -91,10 +91,16 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) /* Get aligned addresses of the top and bottom of the stack */ +#ifdef CONFIG_TLS_ALIGNED + /* Skip over the TLS data structure at the bottom of the stack */ DEBUGASSERT((alloc & TLS_STACK_MASK) == 0); start = alloc + sizeof(struct tls_info_s); +#else + start = alloc & ~3; +#endif + end = (alloc + size + 3) & ~3; /* Get the adjusted size based on the top and bottom of the stack */