Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

#3659 closed defect (fixed)

LEON3 kernel entry point is overwritten - secondary processors may enter into spurious handler

Reported by: Martin Aberg Owned by:
Priority: normal Milestone: 6.1
Component: arch/sparc Version: 5
Severity: normal Keywords: qualification
Cc: Blocked By:
Blocking:

Description

When linking a LEON3 RTEMS SMP application, the entry point in the ELF output file is set to the symbol "start".

"start" is the first entry in the trap table and directly jumps to "hard_reset".

The boot CPU does the following in the boot_card():

  1. Release other CPUs from power-down (but does not wait here)
  2. Some other initializations
  3. Overwrite trap entry 0 with spurious interrupt handler
  4. The rest

It means that the entry point is guaranteed to be valid for the first CPU entering the RTEMS kernel. But 1. and 3. above gives a race. non-first CPU:s will either enter the kernel properly or end up in the spurious interrupt handler depending on how quick it reaches the "start" label.

One example where this has been an issue is when secondary processors run for some time (self-tests) in a ROM boot loader before entering the RTEMS (ELF) entry point. It is convenient to use the ELF file entry point for all processors.

Possible solutions:

a.
Do not install spurious handler on trap table entry 0. For example by changing bsps/sparc/leon3/start/spurious.c:

    -  for ( trap=1 ; trap<256 ; trap++ ) {
    +  for ( trap=0 ; trap<256 ; trap++ ) {

(This changes address 0 on GR740. So following a null function pointer may not end up in spurious trap anymore.)

b.
Change the SPARC ELF entry point. For example to the symbol hard_reset.

c.
Document that the entry point for boot processor is "start" and entry point for other processors is "hard_reset".

Change History (3)

comment:1 Changed on 06/18/21 at 09:24:45 by Sebastian Huber

Keywords: qualification added

comment:2 Changed on 09/02/21 at 05:57:51 by Sebastian Huber

Milestone: 6.1

This was fixed by #4459. The trap table is now read-only.

comment:3 Changed on 09/29/21 at 13:28:14 by Sebastian Huber

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.