From 524839568d8df72bb3d62d64cb1b927bc8dbbbf1 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 3 Mar 2021 09:23:20 +0100 Subject: score: Ensure stack alignment requirement Make sure that a user-provided stack size is the minimum size allocated for the stack. Make sure we meet the stack alignment requirement also for CPU ports with CPU_STACK_ALIGNMENT > CPU_HEAP_ALIGNMENT. --- cpukit/score/src/threadinitialize.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cpukit/score/src/threadinitialize.c') diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index 3a331ed269..f11e35dcf3 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -107,6 +107,7 @@ static bool _Thread_Try_initialize( size_t i; char *stack_begin; char *stack_end; + uintptr_t stack_align; Scheduler_Node *scheduler_node; #if defined(RTEMS_SMP) Scheduler_Node *scheduler_node_for_index; @@ -128,8 +129,12 @@ static bool _Thread_Try_initialize( (char *) the_thread + add_on->source_offset; } + /* Set up the properly aligned stack area begin and end */ stack_begin = config->stack_area; stack_end = stack_begin + config->stack_size; + stack_align = CPU_STACK_ALIGNMENT; + stack_begin = (char *) RTEMS_ALIGN_UP( (uintptr_t) stack_begin, stack_align ); + stack_end = (char *) RTEMS_ALIGN_DOWN( (uintptr_t) stack_end, stack_align ); /* Allocate floating-point context in stack area */ #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -- cgit v1.2.3