Kernel/x86_64 - Unbroke user stack creation
authorJohn Hodge <[email protected]>
Sun, 16 Oct 2011 14:31:05 +0000 (22:31 +0800)
committerJohn Hodge <[email protected]>
Sun, 16 Oct 2011 14:31:05 +0000 (22:31 +0800)
Kernel/arch/x86_64/proc.c

index d05e9ae..e3d7e90 100644 (file)
@@ -594,16 +594,22 @@ Uint Proc_MakeUserStack(void)
 
 void Proc_StartUser(Uint Entrypoint, Uint Base, int ArgC, char **ArgV, int DataSize)
 {
-       Uint    *stack = (void*)Proc_MakeUserStack();
+       Uint    *stack;
        char    **envp;
         int    i;
        Uint    delta;
        Uint16  ss, cs;
        
-       LOG("stack = 0x%x", stack);
        
        // Copy Arguments
-       stack = (void*)( Proc_MakeUserStack() - DataSize );
+       stack = (void*)Proc_MakeUserStack();
+       if(!stack) {
+               Log_Error("Proc", "Unable to create user stack!");
+               Threads_Exit(0, -1);
+       }
+       stack -= (DataSize+7)/8;
+       LOG("stack = 0x%x", stack);
+       Log("stack = %p, DataSize = %i", stack, DataSize);
        memcpy( stack, ArgV, DataSize );
        free(ArgV);
        

UCC git Repository :: git.ucc.asn.au