From 86f855a3e417d93976af42dde36f457e89524902 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 18 May 2014 14:17:26 +0800 Subject: [PATCH] Kernel/x86 - Fix not restoring registers in Proc_CloneInt --- KernelLand/Kernel/arch/x86/proc.asm | 2 +- KernelLand/Kernel/arch/x86/proc.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/KernelLand/Kernel/arch/x86/proc.asm b/KernelLand/Kernel/arch/x86/proc.asm index b8c01bcf..be4c10d3 100644 --- a/KernelLand/Kernel/arch/x86/proc.asm +++ b/KernelLand/Kernel/arch/x86/proc.asm @@ -38,7 +38,7 @@ Proc_CloneInt: mov esi, [esp+0x20+8] mov [esi], eax ; Undo the pusha - add esp, 0x20 + popa mov eax, .newTask ret .newTask: diff --git a/KernelLand/Kernel/arch/x86/proc.c b/KernelLand/Kernel/arch/x86/proc.c index 5637985f..460c920b 100644 --- a/KernelLand/Kernel/arch/x86/proc.c +++ b/KernelLand/Kernel/arch/x86/proc.c @@ -463,6 +463,14 @@ tTID Proc_NewKThread(void (*Fcn)(void*), void *Data) return newThread->TID; } +#if 0 +tPID Proc_NewProcess(Uint Flags, void (*Fcn)(void*), size_t SaveSize, const void *Data) +{ + tThread *newThread = Threads_CloneTCB(CLONE_VM); + return 0; +} +#endif + /** * \fn int Proc_Clone(Uint *Err, Uint Flags) * \brief Clone the current process @@ -473,6 +481,7 @@ tPID Proc_Clone(Uint Flags) tThread *cur = Proc_GetCurThread(); Uint eip; + Log_Warning("Proc", "Proc_Clone is deprecated"); // Sanity, please if( !(Flags & CLONE_VM) ) { Log_Error("Proc", "Proc_Clone: Don't leave CLONE_VM unset, use Proc_NewKThread instead"); @@ -482,6 +491,9 @@ tPID Proc_Clone(Uint Flags) // New thread newThread = Threads_CloneTCB(Flags); if(!newThread) return -1; + ASSERT(newThread->Process); + //ASSERT(CheckMem(newThread->Process, sizeof(tProcess))); + //LOG("newThread->Process = %p", newThread->Process); newThread->KernelStack = cur->KernelStack; @@ -490,6 +502,9 @@ tPID Proc_Clone(Uint Flags) if( eip == 0 ) { return 0; } + //ASSERT(newThread->Process); + //ASSERT(CheckMem(newThread->Process, sizeof(tProcess))); + //LOG("newThread->Process = %p", newThread->Process); newThread->SavedState.EIP = eip; newThread->SavedState.SSE = NULL; newThread->SavedState.bSSEModified = 0; -- 2.20.1