#1932 closed defect (fixed)

SMP: SPARC switch_to_first_task_smp creates bad window

Reported by: Daniel Hellstrom Owned by: Joel Sherrill
Priority: normal Milestone: 4.11
Component: score Version: 4.11
Severity: normal Keywords:
Cc: jennifer.averett@…, jiri@…, daniel@… Blocked By:
Blocking:

Description

I have got SMP the smphack01.exe test to successfully complete on a dual core LEON3 GR712RC ASIC today, the below patch is required.

At some point the interrupt trap handler causes a window-overflow and the window overflow trap handler crashes when writing to 0. I found that this is because the WIM was bad, to the window overflow handler uses a uninitialized stack pointer in a window never used. The below code is rewritten:

  • g3=CWP, not WIM
  • CWP is incremented by done_flushing no need doing that here also
  • I see no reason to create an additional stack frame (save)
  • Must turn off traps when updating WIM (maybe already done by caller?)

Daniel

Index: cpukit/score/cpu/sparc/cpu_asm.S
===================================================================
RCS file: /home/cvspserver/SMP_Repository/rtems-smp/cpukit/score/cpu/sparc/cpu_asm.S,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 cpu_asm.S
--- cpukit/score/cpu/sparc/cpu_asm.S 31 Mar 2011 18:32:59 -0000 1.1.1.1
+++ cpukit/score/cpu/sparc/cpu_asm.S 7 Oct 2011 11:28:05 -0000
@@ -336,22 +336,22 @@

*

  • This routine is only used to switch to the first task on a
  • secondary core in an SMP configuration. We do not need to
  • * flush all the windows and, in fact, this can be dangerous

+ * flush any windows and, in fact, this can be dangerous

  • as they may or may not be initialized properly. So we just
  • reinitialize the PSR and WIM. */

PUBLIC(_CPU_Context_switch_to_first_task_smp)

SYM(_CPU_Context_switch_to_first_task_smp):

  • save %sp, -CPU_MINIMUM_STACK_FRAME_SIZE, %sp

-

  • mov %psr, %g1 ! Initialize WIM
  • add %g1, 1, %g2
  • and %g2, 0x7, %g2
  • set 1, %g3
  • sll %g3, %g2, %g3
  • mov %g3, %wim
  • ba done_flushing
  • mov %i0, %o1 ! in the delay slot

+ mov %psr, %g1 ! Turn of traps when modifying WIM
+ andn %g1, SPARC_PSR_ET_MASK, %g1
+ mov %g1, %psr
+ /* WIM and PSR will be set in done_flushing, it need args:
+ * g1=PSR, g3=CWP, o1=Context
+ */
+ and %g1, SPARC_NUMBER_OF_REGISTER_WINDOWS - 1, %g3
+ nop
+ mov %o0, %o1 ! in the delay slot
+ ba,a done_flushing

#endif


/* end of file */

Attachments (1)

switch_first_task_smp1.patch (1.5 KB) - added by Daniel Hellstrom on Oct 7, 2011 at 10:46:42 AM.
_CPU_Context_switch_to_first_task_smp() WIM patch

Download all attachments as: .zip

Change History (5)

Changed on Oct 7, 2011 at 10:46:42 AM by Daniel Hellstrom

_CPU_Context_switch_to_first_task_smp() WIM patch

comment:1 Changed on Oct 7, 2011 at 10:47:06 AM by Daniel Hellstrom

Cc: daniel@… jennifer.averett@… jiri@… added

comment:2 Changed on Oct 7, 2011 at 1:33:21 PM by Joel Sherrill

Resolution: fixed
Status: newclosed

comment:3 Changed on Oct 9, 2011 at 12:01:23 PM by Daniel Hellstrom

Replying to comment:1:

I have applied this. Thanks.

FWIW smphack01.exe is indeed a hack that was only in the SMP working tree to
test pieces as they were developed. All the current SMP tests are in
testsuites/smptests.

Can't find them at all, I have a lot of subdirs (sptests, mptests ...) in rtems/testsuites, but not smptests. Am I using the wrong repository?

I am thrilled we are starting to see it run on real hardware. You are the
first. Up to now, it was grsim and qemu. :)

I was a bit wrong because the console output was scrambled. The test completes, but with an error, so investigation goes on. But boot process seems to work now.

Daniel

comment:4 Changed on Nov 24, 2014 at 6:58:28 PM by Gedare Bloom

Version: HEAD4.11

Replace Version=HEAD with Version=4.11 for the tickets with Milestone >= 4.11

Note: See TracTickets for help on using tickets.