[PATCH v1 1/2] score: Enforce stack_end alignment
Kinsey Moore
kinsey.moore at oarcorp.com
Thu Feb 18 18:59:04 UTC 2021
The size of the reserved TLS space is not guaranteed to adhere to stack
alignment requirements which can cause stack_end to become misaligned.
This enforces the alignment of stack_end.
---
cpukit/score/src/threadinitialize.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 05c30c3d43..ad5dccbbb2 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -108,6 +108,10 @@ bool _Thread_Initialize(
( ( (uintptr_t) stack_end + tls_align - 1 ) & ~( tls_align - 1 ) );
}
+ /* Enforce stack alignment */
+ stack_end = (char *)((uintptr_t) stack_end &
+ ~( (uintptr_t) CPU_STACK_ALIGNMENT - 1 ));
+
_Stack_Initialize(
&the_thread->Start.Initial_stack,
stack_begin,
--
2.20.1
More information about the devel
mailing list