Sebastian Huber 1c36971d92 sparc: Fix stack corruption
Fix a potential stack corruption in uniprocessor configurations during
start multitasking.

The system initialization uses the interrupt stack.  A first level
interrupt shall never interrupt a context which uses the interrupt
stack.  Such a use would lead to stack corruption and undefined system
behaviour.  Unfortunately, in uniprocessor configurations this was the
case.  Multiprocessing is started using _CPU_Context_restore().  The
caller of this function (_Thread_Start_multitasking()) uses the
interrupt stack.  Later we have in cpukit/score/cpu/sparc/cpu_asm.S:

        mov     %g1, %psr                     ! restore status register and
                                              ! **** ENABLE TRAPS ****

        ld      [%o1 + G5_OFFSET], %g5        ! restore the global registers
        ld      [%o1 + G7_OFFSET], %g7

        ! Load thread specific ISR dispatch prevention flag
        ld      [%o1 + ISR_DISPATCH_DISABLE_STACK_OFFSET], %o2
        ! Store it to memory later to use the cycles

        ldd     [%o1 + L0_OFFSET], %l0        ! restore the local registers
        ldd     [%o1 + L2_OFFSET], %l2
        ldd     [%o1 + L4_OFFSET], %l4
        ldd     [%o1 + L6_OFFSET], %l6

        ! Now restore thread specific ISR dispatch prevention flag
        st      %o2, [%g6 + PER_CPU_ISR_DISPATCH_DISABLE]

        ldd     [%o1 + I0_OFFSET], %i0        ! restore the input registers
        ldd     [%o1 + I2_OFFSET], %i2
        ldd     [%o1 + I4_OFFSET], %i4
        ldd     [%o1 + I6_FP_OFFSET], %i6

        ldd     [%o1 + O6_SP_OFFSET], %o6     ! restore the output registers

Between the ENABLE TRAPS and the restore of the output registers, we
still use the stack of the caller and interrupts may be enabled.  If an
interrupt happens in this code block, the interrupt stack is
concurrently used which may lead to a crash.

Fix this by adding a new function _SPARC_Start_multiprocessing() for
uniprocessor configurations.  This function first sets the stack pointer
to use the stack of the heir thread.

Close #4955.
2023-10-12 14:10:40 +02:00
2023-10-04 13:17:13 +11:00
2021-10-13 14:45:37 -05:00
2023-10-12 14:10:40 +02:00
2020-10-10 13:50:41 +02:00
2023-01-23 09:56:52 +01:00
2022-06-21 09:32:16 +02:00
2013-09-19 13:16:06 +02:00
2020-04-27 11:35:21 +10:00
2023-02-20 10:01:45 -06:00
2023-09-22 07:59:11 +02:00

Real-Time Executive for Multiprocessing Systems (RTEMS)
-------------------------------------------------------

RTEMS, Real-Time Executive for Multiprocessor Systems, is a real-time executive
(kernel) which provides a high performance environment for embedded
applications with the following features:

 - standards based user interfaces
 - multitasking capabilities
 - homogeneous and heterogeneous multiprocessor systems
 - event-driven, priority-based, preemptive scheduling
 - optional rate monotonic scheduling
 - intertask communication and synchronization
 - priority inheritance
 - responsive interrupt management
 - dynamic memory allocation
 - high level of user configurability
 - open source with a friendly user license

Project git repositories are located at https://git.rtems.org/

 RTEMS Kernel:        : https://git.rtems.org/rtems/
 RTEMS Source Builder : https://git.rtems.org/rtems-source-builder/
 RTEMS Tools          : https://git.rtems.org/rtems-tools/
 RTEMS Documentation  : https://git.rtems.org/rtems-docs/
 RTEMS FreeBSD        : https://git.rtems.org/rtems-libbsd/

Online documentation is available at https://docs.rtems.org/

 RTEMS User Manual : https://docs.rtems.org/branches/master/user/index.html
 RTEMS RSB Manual  : https://docs.rtems.org/branches/master/rsb/index.html
 RTEMS Classic API : https://docs.rtems.org/branches/master/c-user/index.html
 RTEMS POSIX API   : https://docs.rtems.org/branches/master/posix-users/index.html

RTEMS Doxygen for CPUKit : https://docs.rtems.org/doxygen/branches/master/

RTEMS POSIX 1003.1 Compliance Guide :
 https://docs.rtems.org/branches/master/posix-compliance/index.html

 - Details the standards base functionality and profiles RTEMS supportsXo

RTEMS Developers Wiki : http://devel.rtems.org

 - Bug reporting, community knowledge and tutorials.

RTEMS Mailing Lists : https://lists.rtems.org/mailman/listinfo

 - The RTEMS Project maintains mailing lists which are used for most
   discussions:

   * For general-purpose questions related to using RTEMS, use the rtems-users
     ml: https://lists.rtems.org/mailman/listinfo/users

   * For questions and discussion related to development of RTEMS, use the
     rtems-devel ml: https://lists.rtems.org/mailman/listinfo/devel

The version number for this software is indicated in the VERSION file.
Description
RTEMS is a ​real-time executive in use by embedded systems applications around the world and beyond
Readme 126 MiB
Languages
C 93.9%
Assembly 3.4%
Ada 1.4%
Python 0.3%
HTML 0.3%
Other 0.4%