Hello Kinsey,

I think the root cause is that this is not necessarily stack aligned:

On 01/03/2021 23:59, Kinsey Moore wrote:
thread_config->stack_area = _Stack_Allocate( size );

Also this (easy to fix):

/**
 * @ingroup RTEMSAPIClassicTasks
 *
 * @brief This constant defines the recommended alignment of a task storage
 *   area in bytes.
 *
 * @par Notes
 * Use it with RTEMS_ALIGNED() to define the alignment of a statically
 * allocated task storage area.
 */
#define RTEMS_TASK_STORAGE_ALIGNMENT CPU_HEAP_ALIGNMENT

We have currently only heap alignment. I think we have to account for a potential stack alignment in the allocation size and the task storage components:

/**
 *  @brief Size of floating point context area.
 *
 *  This constant defines the number of bytes required
 *  to store a full floating point context.
 */
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
  #define CONTEXT_FP_SIZE \
    ( ( CPU_CONTEXT_FP_SIZE + CPU_HEAP_ALIGNMENT - 1 ) \
      & ~( CPU_HEAP_ALIGNMENT - 1 ) )
#else
  #define CONTEXT_FP_SIZE 0
#endif

uintptr_t _TLS_Get_allocation_size( void )
{
  uintptr_t size;
  uintptr_t allocation_size;
  uintptr_t alignment;

  size = _TLS_Get_size();

  if ( size == 0 ) {
    return 0;
  }

  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 );

    /*
     * The stack allocator does not support aligned allocations. Allocate
     * enough to do the alignment manually.
     */
    if ( alignment > CPU_HEAP_ALIGNMENT ) {
      allocation_size += alignment;
    }

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to