[PATCH 4/4] score: Ensure stack alignment requirement

Kinsey Moore kinsey.moore at oarcorp.com
Wed Mar 3 19:51:59 UTC 2021


-----Original Message-----
From: devel <devel-bounces at rtems.org> On Behalf Of Sebastian Huber
Sent: Wednesday, March 3, 2021 02:40
To: devel at rtems.org
Subject: [PATCH 4/4] score: Ensure stack alignment requirement

> diff --git a/cpukit/score/src/tlsallocsize.c b/cpukit/score/src/tlsallocsize.c
> index e7854c677a..cba5bdcfba 100644
> --- a/cpukit/score/src/tlsallocsize.c
> +++ b/cpukit/score/src/tlsallocsize.c
> @@ -59,14 +59,16 @@ uintptr_t _TLS_Get_allocation_size( void )
>    allocation_size = _TLS_Allocation_size;
>
>    if ( allocation_size == 0 ) {
> -    allocation_size = _TLS_Heap_align_up( size );
> -    alignment = _TLS_Heap_align_up( (uintptr_t) _TLS_Alignment );
> +    uintptr_t stack_alignment;
> +
> +    stack_alignment = CPU_STACK_ALIGNMENT;
> +    alignment = RTEMS_ALIGN_UP( (uintptr_t) _TLS_Alignment, stack_alignment );
>
>      /*
>       * The stack allocator does not support aligned allocations.  Allocate
>       * enough to do the alignment manually.
>       */
> -    if ( alignment > CPU_HEAP_ALIGNMENT ) {
> +    if ( alignment > stack_alignment ) {
>        allocation_size += alignment;
>      }
>
> @@ -76,6 +78,12 @@ uintptr_t _TLS_Get_allocation_size( void )
>      allocation_size += sizeof(TLS_Dynamic_thread_vector);
>  #endif
>
> +    /*
> +     * The TLS area is allocated in the thread storage area.  Each allocation
> +     * shall meet the stack alignment requirement.
> +     */
> +    allocation_size = RTEMS_ALIGN_UP( allocation_size, stack_alignment );
> +
>      if ( _Thread_Maximum_TLS_size != 0 ) {
>        if ( allocation_size <= _Thread_Maximum_TLS_size ) {
>          allocation_size = _Thread_Maximum_TLS_size;

This change drops use of size from the top of the function in calculating allocation_size; is that intentional? It seems to be causing me some problems when testing with the AArch64 code.

Kinsey


More information about the devel mailing list