From: John Hodge Date: Tue, 25 Jan 2011 13:38:44 +0000 (+0800) Subject: Kernel - Fixed page fault Proc_ReturnToUser X-Git-Tag: rel0.07~19 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=8a998da38a4eecface76749701079c833d64a7d8;p=tpg%2Facess2.git Kernel - Fixed page fault Proc_ReturnToUser --- diff --git a/Kernel/arch/x86/proc.asm b/Kernel/arch/x86/proc.asm index fd372dbf..a07bdad8 100644 --- a/Kernel/arch/x86/proc.asm +++ b/Kernel/arch/x86/proc.asm @@ -158,14 +158,16 @@ SpawnTask: Proc_ReturnToUser: push ebp mov ebp, esp - ; [EBP+4]: handler to use - ; [EBP+8]: parameter + ; [EBP+8]: handler to use + ; [EBP+12]: parameter + ; [EBP+16]: kernel stack top - call Proc_GetCurThread + ;call Proc_GetCurThread ; EAX is the current thread - mov ebx, eax - mov eax, [ebx+12*4] ; Get Kernel Stack + ;mov ebx, eax + ;mov eax, [ebx+12*4] ; Get Kernel Stack + mov eax, [ebp+16] ; Get Kernel Stack sub eax, KSTACK_USERSTATE_SIZE ; @@ -208,7 +210,7 @@ Proc_ReturnToUser: ; Get and alter User SP mov edi, edx - mov edx, [ebp+8] ; Get parameter + mov edx, [ebp+12] ; Get parameter mov [edi+4], edx ; save to user stack mov [edi], DWORD User_Syscall_RetAndExit ; Return Address @@ -223,7 +225,7 @@ Proc_ReturnToUser: push edi ; ESP push 0x202 ; EFLAGS (IP and Rsvd) push 0x1B ; CS - mov eax, [ebp+4] ; Method to call + mov eax, [ebp+8] ; Method to call push eax ; EIP iret diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index ad83c991..d3c4ab47 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -49,7 +49,7 @@ extern int giNextTID; extern tThread gThreadZero; extern tThread *Threads_CloneTCB(Uint *Err, Uint Flags); extern void Isr8(void); // Double Fault -extern void Proc_ReturnToUser(tVAddr Handler, Uint Argument); +extern void Proc_ReturnToUser(tVAddr Handler, Uint Argument, tVAddr KernelStack); // === PROTOTYPES === void ArchThreads_Init(void); @@ -833,7 +833,7 @@ void Proc_CallFaultHandler(tThread *Thread) { // Rewinds the stack and calls the user function // Never returns - Proc_ReturnToUser( Thread->FaultHandler, Thread->CurFaultNum ); + Proc_ReturnToUser( Thread->FaultHandler, Thread->CurFaultNum, Thread->KernelStack ); for(;;); }