From: AceVest Date: Thu, 17 Jul 2014 00:56:32 +0000 (+0800) Subject: fix ring3 stack bug X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch05.html?a=commitdiff_plain;h=6b60fe67109d7a3ae12fe0cd766b3cdb0abaa2b9;p=kernel.git fix ring3 stack bug --- diff --git a/kernel/init.c b/kernel/init.c index debca5f..9cddcc2 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -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 } diff --git a/kernel/syscall.S b/kernel/syscall.S index ef7801e..b3abf9f 100644 --- a/kernel/syscall.S +++ b/kernel/syscall.S @@ -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