[rtems commit] NIOS2: Fix register restore sequence in epilogue

Sebastian Huber sebh at rtems.org
Mon Jan 14 09:44:18 UTC 2013


Module:    rtems
Branch:    master
Commit:    0cce75e6960df9e53183be459b51ee7bef0ce4cc
Changeset: http://git.rtems.org/rtems/commit/?id=0cce75e6960df9e53183be459b51ee7bef0ce4cc

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jan 14 09:54:21 2013 +0100

NIOS2: Fix register restore sequence in epilogue

This fix is critical.  The previous implementation leads to system
corruption.

---

 cpukit/score/cpu/nios2/nios2-eic-il-low-level.S |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cpukit/score/cpu/nios2/nios2-eic-il-low-level.S b/cpukit/score/cpu/nios2/nios2-eic-il-low-level.S
index 42da434..f214f4d 100644
--- a/cpukit/score/cpu/nios2/nios2-eic-il-low-level.S
+++ b/cpukit/score/cpu/nios2/nios2-eic-il-low-level.S
@@ -160,7 +160,6 @@ do_thread_dispatch:
 	ldw	r10, FRAME_OFFSET_R10(sp)
 	ldw	r11, FRAME_OFFSET_R11(sp)
 	ldw	r12, FRAME_OFFSET_R12(sp)
-	ldw	r13, FRAME_OFFSET_R13(sp)
 
 	/*
 	 * Disable interrupts.
@@ -180,15 +179,16 @@ do_thread_dispatch:
 	wrctl	status, r15
 
 	/* Load thread dispatch necessary */
-	ldb	r12, %gprel(_Per_CPU_Information + PER_CPU_DISPATCH_NEEDED)(gp)
+	ldb	r13, %gprel(_Per_CPU_Information + PER_CPU_DISPATCH_NEEDED)(gp)
 
 	/* Is thread dispatch necessary? */
-	bne	r12, zero, enable_interrupts_before_thread_dispatch
+	bne	r13, zero, enable_interrupts_before_thread_dispatch
 
 	/* Enable Nios II specific thread dispatch */
 	stw	zero, %gprel(_Nios2_Thread_dispatch_disabled)(gp)
 
 	/* Restore remaining volatile register */
+	ldw	r13, FRAME_OFFSET_R13(sp)
 	ldw	r14, FRAME_OFFSET_R14(sp)
 	ldw	r15, FRAME_OFFSET_R15(sp)
 




More information about the vc mailing list