Call in to xen for privileged aspects of context switching

MFC after:	1 month
This commit is contained in:
Kip Macy 2008-08-16 21:38:46 +00:00
parent 337b89a0e0
commit 2139b228e3

View File

@ -88,7 +88,7 @@ ENTRY(cpu_throw)
movl 8(%esp),%ecx /* New thread */ movl 8(%esp),%ecx /* New thread */
movl TD_PCB(%ecx),%edx movl TD_PCB(%ecx),%edx
movl PCB_CR3(%edx),%eax movl PCB_CR3(%edx),%eax
movl %eax,%cr3 /* new address space */ LOAD_CR3(%eax)
/* set bit in new pm_active */ /* set bit in new pm_active */
movl TD_PROC(%ecx),%eax movl TD_PROC(%ecx),%eax
movl P_VMSPACE(%eax), %ebx movl P_VMSPACE(%eax), %ebx
@ -181,10 +181,10 @@ ENTRY(cpu_switch)
cmpl %eax,IdlePTD /* Kernel address space? */ cmpl %eax,IdlePTD /* Kernel address space? */
#endif #endif
je sw0 je sw0
movl %cr3,%ebx /* The same address space? */ READ_CR3(%ebx) /* The same address space? */
cmpl %ebx,%eax cmpl %ebx,%eax
je sw0 je sw0
movl %eax,%cr3 /* new address space */ LOAD_CR3(%eax) /* new address space */
movl %esi,%eax movl %esi,%eax
movl PCPU(CPUID),%esi movl PCPU(CPUID),%esi
SETOP %eax,TD_LOCK(%edi) /* Switchout td_lock */ SETOP %eax,TD_LOCK(%edi) /* Switchout td_lock */
@ -211,6 +211,18 @@ sw0:
SETOP %esi,TD_LOCK(%edi) /* Switchout td_lock */ SETOP %esi,TD_LOCK(%edi) /* Switchout td_lock */
sw1: sw1:
BLOCK_SPIN(%ecx) BLOCK_SPIN(%ecx)
#ifdef XEN
pushl %eax
pushl %ecx
pushl %edx
call xen_handle_thread_switch
popl %edx
popl %ecx
popl %eax
/*
* XXX set IOPL
*/
#else
/* /*
* At this point, we've switched address spaces and are ready * At this point, we've switched address spaces and are ready
* to load up the rest of the next context. * to load up the rest of the next context.
@ -259,7 +271,7 @@ sw1:
movl 12(%esi), %ebx movl 12(%esi), %ebx
movl %eax, 8(%edi) movl %eax, 8(%edi)
movl %ebx, 12(%edi) movl %ebx, 12(%edi)
#endif
/* Restore context. */ /* Restore context. */
movl PCB_EBX(%edx),%ebx movl PCB_EBX(%edx),%ebx
movl PCB_ESP(%edx),%esp movl PCB_ESP(%edx),%esp
@ -285,7 +297,7 @@ sw1:
movl _default_ldt,%eax movl _default_ldt,%eax
cmpl PCPU(CURRENTLDT),%eax cmpl PCPU(CURRENTLDT),%eax
je 2f je 2f
lldt _default_ldt LLDT(_default_ldt)
movl %eax,PCPU(CURRENTLDT) movl %eax,PCPU(CURRENTLDT)
jmp 2f jmp 2f
1: 1:
@ -389,7 +401,7 @@ ENTRY(savectx)
* parent's npx state for forks by forgetting to reload. * parent's npx state for forks by forgetting to reload.
*/ */
pushfl pushfl
cli CLI
movl PCPU(FPCURTHREAD),%eax movl PCPU(FPCURTHREAD),%eax
testl %eax,%eax testl %eax,%eax
je 1f je 1f