This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix race in the ARM IRQ handler.


The patch below disables FIQ in IRQ handler to fix race condition
that may result in recursive entry into IRQ handler through FIQ
handler.

-- Sergei.

Index: packages/hal/arm/arch/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/ChangeLog,v
retrieving revision 1.104
diff -a -u -r1.104 ChangeLog
--- packages/hal/arm/arch/current/ChangeLog	21 Apr 2005 18:17:54 -0000	1.104
+++ packages/hal/arm/arch/current/ChangeLog	6 Feb 2006 18:27:06 -0000
@@ -1,3 +1,9 @@
+2006-02-06  Sergei Organov  <osv@javad.com>
+
+	* 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.
+
 2005-04-21  Ian Campbell  <icampbell@arcom.com>
 
 	* src/redboot_linux_exec.c: Added -t option which takes the
Index: packages/hal/arm/arch/current/src/vectors.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/src/vectors.S,v
retrieving revision 1.55
diff -a -u -r1.55 vectors.S
--- packages/hal/arm/arch/current/src/vectors.S	23 Nov 2004 14:11:19 -0000	1.55
+++ packages/hal/arm/arch/current/src/vectors.S	6 Feb 2006 18:27:09 -0000
@@ -787,11 +787,14 @@
         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
+        // We must disable FIQ here (IRQ is already disabled) as switching 
+        // from IRQ to SVC mode will cheat FIQ handler and it will pass through 
+        // the control back to us (should FIQ happen after the statement below) 
+        // resulting in recursion that we aren't ready to handle, e.g., what 
+        // we have saved on the exception stack will be clobbered.
+        orr     r4,r4,#CPSR_SUPERVISOR_MODE|CPSR_FIQ_DISABLE
         msr     cpsr,r4
 
         mov     r5,sp                   // save original svc sp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]