]> Zhao Yanbai Git Server - kernel.git/commitdiff
fix ring3 stack bug
authorAceVest <zhaoyanbai@126.com>
Thu, 17 Jul 2014 00:56:32 +0000 (08:56 +0800)
committerAceVest <zhaoyanbai@126.com>
Thu, 17 Jul 2014 00:56:32 +0000 (08:56 +0800)
kernel/init.c
kernel/syscall.S

index debca5f280bd79d048946d11f994e7840b0e9ec1..9cddcc2e5f47dc7e809d4a245f79298d4b613b2c 100644 (file)
@@ -23,25 +23,11 @@ char __initdata kernel_init_stack[KRNL_INIT_STACK_SIZE] __attribute__ ((__aligne
 
 int debug_wait_queue_get();
 
-#if 0
-void ring3()
-{
-    int i = 0;
-    while(1)
-    {
-        i++;
-//        printk("fuck\n");
-        systest();
-    }
-}
-#else
 void ring3();
-#endif
-static char user_task_stack[PAGE_SIZE] __attribute__ ((__aligned__(PAGE_SIZE)));
+extern void *ring3_stack_top;
 void user_task_entry()
 {
-    printk("user_task_entry\n");
-    //while(1);
+    printk("user_task_entry: %08x %08x\n", ring3_stack_top, &ring3_stack_top);
 #if 1
     asm("cli;");
     asm("movl $0x23,%%eax;  \
@@ -55,16 +41,8 @@ void user_task_entry()
     pushl $0x1B;            \
     leal ring3,%%eax;       \
     pushl %%eax;            \
-    iret;"::"b"(user_task_stack+PAGE_SIZE));
+    iret;"::"b"(&ring3_stack_top));
 #else
-    asm("xorl   %eax,%eax;  \
-        sti;                \
-        pushfl;             \
-        movw    %cs,%ax;    \
-        pushl   %eax;       \
-        leal    ring3,%eax; \
-        pushl   %eax;       \
-        iret;");
 #endif
 }
 
index ef7801e09557478e71c804b0491da4d9ab1f2dde..b3abf9fbdf0b2e7bafd0714c89cb065a7185548a 100644 (file)
@@ -96,11 +96,12 @@ sysexit:
     ret
 
 .global ring3
+.global ring3_stack_top
 ring3:
     nop;
     nop;
 
-    movl $(ring3_stack+100), %esp
+    #movl $(ring3_stack+100), %esp
 
     movl $11, %eax;
 
@@ -118,4 +119,9 @@ ring3:
     jmp ring3
 
 ring3_stack:
-    .byte   200
+    .long   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+    .long   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+    .long   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+    .long   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+ring3_stack_top:
+    .long   0x12345678