changeset 2125:fae1320c2db8

* src/context.S (hal_thread_switch_context): Close race condition that could cause corruption of the sp or lr registers.
author asl
date Wed, 08 Feb 2006 12:06:38 +0000
parents 272d1110cda1
children 0141a9e24d21
files packages/hal/arm/arch/current/ChangeLog packages/hal/arm/arch/current/src/context.S
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/arm/arch/current/ChangeLog
+++ b/packages/hal/arm/arch/current/ChangeLog
@@ -1,3 +1,8 @@
+2006-01-18  Jay Foster    <jay@systech.com>
+
+	* src/context.S (hal_thread_switch_context): Close race condition
+	that could cause corruption of the sp or lr registers.
+
 2005-04-21  Ian Campbell  <icampbell@arcom.com>
 
 	* src/redboot_linux_exec.c: Added -t option which takes the
--- a/packages/hal/arm/arch/current/src/context.S
+++ b/packages/hal/arm/arch/current/src/context.S
@@ -89,12 +89,13 @@
 // Need to save/restore R4..R12, R13 (sp), R14 (lr)
 
 // Note: this is a little wasteful since r0..r3 don't need to be saved.
-// They are saved here though so that the information can match the HAL_SavedRegisters
+// They are saved here though so that the information can match the
+// HAL_SavedRegisters
         
 FUNC_START_ARM(hal_thread_switch_context, r2)
-        sub     ip,sp,#20               // skip svc_sp, svc_lr, vector, cpsr, and pc
-        stmfd   ip!,{sp,lr}
-        mov     sp,ip
+        mov     ip,sp
+        sub     sp,sp,#(ARMREG_SIZE - armreg_lr - 4) // skip svc_sp, svc_lr, vector, cpsr, and pc
+        stmfd   sp!,{ip,lr}
         stmfd   sp!,{r0-r10,fp,ip}
         mrs     r2,cpsr
         str     r2,[sp,#armreg_cpsr]