changeset 2126:0141a9e24d21

* src/vectors.S: disable FIQ in IRQ handler to fix race condition recursively entering IRQ handler through FIQ handler. Remove unreferenced handle_IRQ_or_FIQ label.
author asl
date Thu, 09 Feb 2006 16:47:39 +0000
parents fae1320c2db8
children 0e1e2bf4be93
files packages/hal/arm/arch/current/ChangeLog packages/hal/arm/arch/current/src/vectors.S
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/arm/arch/current/ChangeLog
+++ b/packages/hal/arm/arch/current/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-06  Sergei Organov  <osv@javad.com>
+
+	* src/vectors.S: disable FIQ in IRQ handler to fix race condition
+	of recursively entering IRQ handler through FIQ handler. Remove
+	unreferenced handle_IRQ_or_FIQ label.
+	
 2006-01-18  Jay Foster    <jay@systech.com>
 
 	* src/context.S (hal_thread_switch_context): Close race condition
--- a/packages/hal/arm/arch/current/src/vectors.S
+++ b/packages/hal/arm/arch/current/src/vectors.S
@@ -787,11 +787,16 @@ IRQ:
         mov     r2,#CYGNUM_HAL_VECTOR_IRQ
         mov     r3,sp
 	
-handle_IRQ_or_FIQ:
-
         mrs     r4,cpsr                 // switch to Supervisor Mode
         bic     r4,r4,#CPSR_MODE_BITS
-        orr     r4,r4,#CPSR_SUPERVISOR_MODE
+        // When handling an IRQ we must disable FIQ unless the current 
+        // mode in CPSR is IRQ. If we were to get a FIQ while in another 
+        // mode, the FIQ handling code would transform the FIQ into an 
+        // IRQ and call the non-reentrant IRQ handler again. As a result, 
+        // for example, the stack pointer would be set to the beginning 
+        // of the exception_stack clobbering the registers we have just 
+        // saved.
+        orr     r4,r4,#CPSR_SUPERVISOR_MODE|CPSR_FIQ_DISABLE
         msr     cpsr,r4
 
         mov     r5,sp                   // save original svc sp