public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH,rs6000] fix interrupt safety issue on E500 targets
@ 2007-10-03 14:18 Nathan Froyd
  2007-10-03 15:42 ` Andrew Pinski
  0 siblings, 1 reply; 13+ messages in thread
From: Nathan Froyd @ 2007-10-03 14:18 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]

The attached patch fixes an interrupt safety problem on E500 targets;
this problem was introduced by the ABI fixes that were committed several
months ago.  On SPE targets we would generate the following code for a
function epilogue:

    point r11 into the stack frame
    restore registers
    restore stack pointer
    return

and the instruction scheduler, being clever, would turn this into:

    point r11 into the stack frame
    restore a few registers
    restore stack pointer
    restore remaining registers		(XXX)
    return

Which causes problems if an interrupt happens during XXX because the OS
will clobber the space from which we are restoring registers, believing
it to be unused.

The fix is simple.  We just have to tell the scheduler that we
have a blocking insn just before the restore of the stack pointer.

Tested on powerpc-none-linux-gnuspe with no regressions.  OK to commit?

-Nathan

2007-10-03  Nathan Froyd  <froydnj@codesourcery.com>

	gcc/
	* config/rs6000/rs6000.c (rs6000_emit_epilogue): Emit a stack tie
	when compiling for SPE targets due to r11 pointing into the frame.


[-- Attachment #2: r14-add-insn.patch --]
[-- Type: text/x-diff, Size: 999 bytes --]

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 128981)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -16329,13 +16329,18 @@ rs6000_emit_epilogue (int sibcall)
 	    }
     }
 
+  if (frame_reg_rtx != sp_reg_rtx
+      || (TARGET_SPE_ABI
+          && info->spe_64bit_regs_used != 0
+          && info->first_gp_reg_save != 32))
+    /* This blockage is needed so that sched doesn't decide to move
+       the sp change before the register restores.  */
+    rs6000_emit_stack_tie ();
+    
   /* If this is V.4, unwind the stack pointer after all of the loads
      have been done.  */
   if (frame_reg_rtx != sp_reg_rtx)
     {
-      /* This blockage is needed so that sched doesn't decide to move
-	 the sp change before the register restores.  */
-      rs6000_emit_stack_tie ();
       if (TARGET_SPE_ABI
           && info->spe_64bit_regs_used != 0
           && info->first_gp_reg_save != 32)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-10-16 19:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-03 14:18 [PATCH,rs6000] fix interrupt safety issue on E500 targets Nathan Froyd
2007-10-03 15:42 ` Andrew Pinski
2007-10-03 15:45   ` Andrew Pinski
2007-10-03 19:12     ` Nathan Froyd
2007-10-03 19:17       ` Daniel Jacobowitz
2007-10-03 19:17       ` Andrew Pinski
2007-10-03 20:10         ` Nathan Froyd
2007-10-04  1:43   ` Alan Modra
2007-10-05  8:30     ` Alan Modra
2007-10-05 15:02       ` Nathan Froyd
2007-10-06  1:01         ` Nathan Froyd
2007-10-16  9:01       ` Alan Modra
2007-10-16 20:31       ` David Edelsohn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).