This patch set started with an 8 byte overwrite of the interrupt stack while porting an application from RTEMS 5 to 6.
The overwrite was due to a mismatch of the size returned by _TLS_Get_allocation_size() and the actual usage of the area. To fix this issue it was necessary to add a new CPU port option: CPU_THREAD_LOCAL_STORAGE_VARIANT. I checked also the glibc implementations. It seems that on some architectures (for example powerpc) the TCB is used for a couple of more things. For RTEMS, we don't really need the DTV and TCB. It could be useful for debuggers, however, then we probably need also some glibc compatibility. Add a new fatal error to catch a failing idle thread initialization: INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED. This can only happen if a thread create extension fails for an idle thread. By default, allocate the IDLE task storage areas from the RTEMS Workspace. This avoids having to estimate the thread-local storage size in the default configuration. Add the application configuration option CONFIGURE_IDLE_TASK_STORAGE_SIZE to request a static allocation of the task storage area for IDLE tasks. v2: * Add CONFIGURE_IDLE_TASK_STORAGE_SIZE instead of CONFIGURE_IDLE_TASK_MINIMUM_STACK_SIZE. Sebastian Huber (13): sptls0*: Enable stack checker sptls01: Disable file system and Newlib reentrancy sptls02: Fix alignment check score: Require power of two CPU_STACK_MINIMUM_SIZE config: Changeable size for IDLE stack allocator score: Add CPU_THREAD_LOCAL_STORAGE_VARIANT score: Simplify casts score: INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED stackchk: Avoid internal header file stackchk: Add rtems_stack_checker_iterate() stackchk01: Check CPU_STACK_MINIMUM_SIZE config: Add CONFIGURE_IDLE_TASK_STORAGE_SIZE score: INTERNAL_ERROR_IDLE_THREAD_STACK_TOO_SMALL bsps/powerpc/shared/cpu.c | 2 +- cpukit/doxygen/appl-config.h | 95 +++++++- cpukit/include/rtems/confdefs/percpu.h | 14 -- cpukit/include/rtems/confdefs/threads.h | 4 + cpukit/include/rtems/confdefs/wkspace.h | 50 ++++- cpukit/include/rtems/score/interr.h | 3 + cpukit/include/rtems/score/stack.h | 75 ++++++- cpukit/include/rtems/score/thread.h | 7 - cpukit/include/rtems/score/tls.h | 210 +++++++----------- cpukit/include/rtems/stackchk.h | 89 +++++++- cpukit/libmisc/stackchk/check.c | 158 +++++++------ cpukit/sapi/src/interrtext.c | 5 +- cpukit/score/cpu/aarch64/cpu.c | 2 +- .../cpu/aarch64/include/rtems/score/cpu.h | 2 +- .../cpu/aarch64/include/rtems/score/cpuimpl.h | 3 + cpukit/score/cpu/arm/__aeabi_read_tp.c | 6 +- cpukit/score/cpu/arm/__tls_get_addr.c | 6 +- .../score/cpu/arm/armv7m-context-initialize.c | 2 +- cpukit/score/cpu/arm/cpu.c | 17 +- .../score/cpu/arm/include/rtems/score/cpu.h | 10 +- .../cpu/arm/include/rtems/score/cpuimpl.h | 2 + .../cpu/bfin/include/rtems/score/cpuimpl.h | 2 + cpukit/score/cpu/i386/cpu.c | 2 +- .../cpu/i386/include/rtems/score/cpuimpl.h | 2 + .../cpu/lm32/include/rtems/score/cpuimpl.h | 2 + cpukit/score/cpu/m68k/__m68k_read_tp.c | 4 +- cpukit/score/cpu/m68k/cpu.c | 5 +- .../score/cpu/m68k/include/rtems/score/cpu.h | 1 + .../cpu/m68k/include/rtems/score/cpuimpl.h | 2 + cpukit/score/cpu/microblaze/__tls_get_addr.c | 10 +- cpukit/score/cpu/microblaze/cpu.c | 2 +- .../cpu/microblaze/include/rtems/score/cpu.h | 1 + .../microblaze/include/rtems/score/cpuimpl.h | 3 + .../cpu/mips/include/rtems/score/cpuimpl.h | 2 + .../score/cpu/moxie/include/rtems/score/cpu.h | 2 +- .../cpu/moxie/include/rtems/score/cpuimpl.h | 2 + .../cpu/nios2/include/rtems/score/cpuimpl.h | 2 + .../cpu/nios2/nios2-context-initialize.c | 5 +- .../cpu/no_cpu/include/rtems/score/cpu.h | 3 +- .../cpu/no_cpu/include/rtems/score/cpuimpl.h | 18 ++ .../cpu/or1k/include/rtems/score/cpuimpl.h | 2 + .../cpu/powerpc/include/rtems/score/cpuimpl.h | 2 + .../cpu/riscv/include/rtems/score/cpuimpl.h | 2 + .../cpu/riscv/riscv-context-initialize.c | 2 +- .../cpu/sh/include/rtems/score/cpuimpl.h | 2 + cpukit/score/cpu/sparc/cpu.c | 2 +- .../cpu/sparc/include/rtems/score/cpuimpl.h | 2 + cpukit/score/cpu/sparc64/cpu.c | 2 +- .../cpu/sparc64/include/rtems/score/cpuimpl.h | 2 + .../cpu/v850/include/rtems/score/cpuimpl.h | 2 + .../cpu/x86_64/include/rtems/score/cpuimpl.h | 2 + cpukit/score/src/percpuasm.c | 7 +- cpukit/score/src/stackallocatorforidle.c | 44 ++-- .../score/src/stackallocatorforidlewkspace.c | 60 +++++ cpukit/score/src/threadcreateidle.c | 43 +++- cpukit/score/src/threadinitialize.c | 6 +- cpukit/score/src/tlsallocsize.c | 44 ++-- spec/build/cpukit/librtemscpu.yml | 1 + spec/build/testsuites/sptests/grp.yml | 2 + spec/build/testsuites/sptests/spfatal36.yml | 19 ++ .../fatal-idle-thread-create-failed.yml | 20 ++ .../fatal-idle-thread-stack-too-small.yml | 20 ++ spec/build/testsuites/validation/grp.yml | 4 + testsuites/libtests/stackchk01/init.c | 30 ++- testsuites/libtests/stackchk01/stackchk01.doc | 12 +- testsuites/sptests/spfatal36/init.c | 62 ++++++ testsuites/sptests/spfatal36/spfatal36.doc | 11 + testsuites/sptests/spinternalerror02/init.c | 2 +- testsuites/sptests/spstkalloc03/init.c | 4 +- testsuites/sptests/spstkalloc04/init.c | 4 +- testsuites/sptests/sptls01/init.c | 39 +++- testsuites/sptests/sptls02/init.cc | 18 +- testsuites/sptests/sptls03/init.c | 4 + .../tr-fatal-idle-thread-create-failed.c | 158 +++++++++++++ .../tr-fatal-idle-thread-create-failed.h | 84 +++++++ .../tr-fatal-idle-thread-stack-too-small.c | 175 +++++++++++++++ .../tr-fatal-idle-thread-stack-too-small.h | 84 +++++++ testsuites/validation/ts-config.h | 2 +- testsuites/validation/ts-default.h | 9 +- .../ts-fatal-idle-thread-create-failed.c | 90 ++++++++ .../ts-fatal-idle-thread-stack-too-small.c | 97 ++++++++ testsuites/validation/ts-fatal-sysinit.h | 9 + testsuites/validation/ts-idle.h | 4 + testsuites/validation/ts-validation-acfg-0.c | 2 + testsuites/validation/ts-validation-acfg-1.c | 2 + .../validation/ts-validation-io-kernel.c | 2 + testsuites/validation/ts-validation-tls-1.c | 3 + 87 files changed, 1660 insertions(+), 371 deletions(-) create mode 100644 cpukit/score/src/stackallocatorforidlewkspace.c create mode 100644 spec/build/testsuites/sptests/spfatal36.yml create mode 100644 spec/build/testsuites/validation/fatal-idle-thread-create-failed.yml create mode 100644 spec/build/testsuites/validation/fatal-idle-thread-stack-too-small.yml create mode 100644 testsuites/sptests/spfatal36/init.c create mode 100644 testsuites/sptests/spfatal36/spfatal36.doc create mode 100644 testsuites/validation/tr-fatal-idle-thread-create-failed.c create mode 100644 testsuites/validation/tr-fatal-idle-thread-create-failed.h create mode 100644 testsuites/validation/tr-fatal-idle-thread-stack-too-small.c create mode 100644 testsuites/validation/tr-fatal-idle-thread-stack-too-small.h create mode 100644 testsuites/validation/ts-fatal-idle-thread-create-failed.c create mode 100644 testsuites/validation/ts-fatal-idle-thread-stack-too-small.c -- 2.35.3 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel