Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/sommerfeld_i386mp_1]: src/sys/arch/i386/i386 Move call to sched_unlock_i...
details: https://anonhg.NetBSD.org/src/rev/340cb06b8412
branches: sommerfeld_i386mp_1
changeset: 482520:340cb06b8412
user: sommerfeld <sommerfeld%NetBSD.org@localhost>
date: Tue Apr 30 14:15:14 2002 +0000
description:
Move call to sched_unlock_idle to later in the context switch to
eliminate a race where another processor could grab the outgoing
process before we were done saving our state into it, with predictable
results.
Bug spotted by Frank van der Linden <fvdl%wasabisystems.com@localhost>
Along for the ride:
clean up register use during switch-to-idle.
clean up comments regarding register use during context switch.
diffstat:
sys/arch/i386/i386/locore.s | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diffs (102 lines):
diff -r 82cc7382124c -r 340cb06b8412 sys/arch/i386/i386/locore.s
--- a/sys/arch/i386/i386/locore.s Tue Apr 30 14:09:07 2002 +0000
+++ b/sys/arch/i386/i386/locore.s Tue Apr 30 14:15:14 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.215.2.31 2002/04/27 20:24:46 sommerfeld Exp $ */
+/* $NetBSD: locore.s,v 1.215.2.32 2002/04/30 14:15:14 sommerfeld Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -1894,7 +1894,7 @@
* Registers:
* %eax, %ecx - scratch
* %esi - old process, then old pcb
- * %edi - new process
+ * %edi - idle pcb
*/
pushl %esi
@@ -1910,10 +1910,10 @@
/* Find idle PCB for this CPU */
#ifndef MULTIPROCESSOR
movl $_C_LABEL(proc0),%ebx
- movl P_ADDR(%ebx),%esi
+ movl P_ADDR(%ebx),%edi
movl P_MD_TSS_SEL(%ebx),%edx
#else
- movl CPUVAR(IDLE_PCB),%esi
+ movl CPUVAR(IDLE_PCB),%edi
movl CPUVAR(IDLE_TSS_SEL),%edx
#endif
movl $0,CPUVAR(CURPROC) /* In case we fault... */
@@ -1922,12 +1922,12 @@
cli
/* Restore stack pointers. */
- movl PCB_ESP(%esi),%esp
- movl PCB_EBP(%esi),%ebp
+ movl PCB_ESP(%edi),%esp
+ movl PCB_EBP(%edi),%ebp
/* Switch address space. */
- movl PCB_CR3(%esi),%ecx
+ movl PCB_CR3(%edi),%ecx
movl %ecx,%cr3
/* Switch TSS. Reset "task busy" flag before loading. */
@@ -1942,11 +1942,11 @@
/* We're always in the kernel, so we don't need the LDT. */
/* Restore cr0 (including FPU state). */
- movl PCB_CR0(%esi),%ecx
+ movl PCB_CR0(%edi),%ecx
movl %ecx,%cr0
/* Record new pcb. */
- SET_CURPCB(%esi)
+ SET_CURPCB(%edi)
xorl %esi,%esi
sti
@@ -2026,10 +2026,6 @@
movb $SONPROC,P_STAT(%edi) # p->p_stat = SONPROC
SET_CURPROC(%edi,%ecx)
-#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
- call _C_LABEL(sched_unlock_idle)
-#endif
-
/* Skip context switch if same process. */
cmpl %edi,%esi
je switch_return
@@ -2062,7 +2058,7 @@
* Third phase: restore saved context.
*
* Registers:
- * %eax, %ecx, %edx - scratch
+ * %eax, %ebx, %ecx, %edx - scratch
* %esi - new pcb
* %edi - new process
*/
@@ -2097,7 +2093,9 @@
call _C_LABEL(pmap_activate) # pmap_activate(p)
addl $4,%esp
+#if 0
switch_restored:
+#endif
/* Restore cr0 (including FPU state). */
movl PCB_CR0(%esi),%ecx
#ifdef MULTIPROCESSOR
@@ -2120,6 +2118,10 @@
sti
switch_return:
+#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
+ call _C_LABEL(sched_unlock_idle)
+#endif
+
movl $0,CPL # spl0()
call _C_LABEL(Xspllower) # process pending interrupts
movl $IPL_HIGH,CPL # splhigh()
Home |
Main Index |
Thread Index |
Old Index