--- linux/kernel/traps.c 2018/04/24 18:03:12 1.1.1.3 +++ linux/kernel/traps.c 2018/04/24 18:07:50 1.1.1.5 @@ -10,7 +10,7 @@ * to mainly kill the offending process (probably by giving it a signal, * but possibly by killing it outright if necessary). */ -#include +#include #include #include @@ -18,6 +18,8 @@ #include #include #include +#include + #define get_seg_byte(seg,addr) ({ \ register char __res; \ @@ -65,11 +67,12 @@ static void die(char * str,long esp_ptr, int i; printk("%s: %04x\n\r",str,nr&0xffff); - printk("EIP:\t%04x:%p\nEFLAGS:\t%p\nESP:\t%04x:%p\n", - esp[1],esp[0],esp[2],esp[4],esp[3]); + printk("EIP: %04x:%p\nEFLAGS: %p\n", 0xffff & esp[1],esp[0],esp[2]); + if ((0xffff & esp[1]) == 0xf) + printk("ESP: %04x:%p\n",0xffff & esp[4],esp[3]); printk("fs: %04x\n",_fs()); printk("base: %p, limit: %p\n",get_base(current->ldt[1]),get_limit(0x17)); - if (esp[4] == 0x17) { + if ((0xffff & esp[1]) == 0xf) { printk("Stack: "); for (i=0;i<4;i++) printk("%p ",get_seg_long(0x17,i+(long *)esp[3])); @@ -80,7 +83,10 @@ static void die(char * str,long esp_ptr, for(i=0;i<10;i++) printk("%02x ",0xff & get_seg_byte(esp[1],(i+(char *)esp[0]))); printk("\n\r"); - do_exit(11); /* play segment exception */ + if ((0xffff & esp[1]) == 0xf) + send_sig(SIGSEGV, current, 0); + else + do_exit(SIGSEGV); } void do_double_fault(long esp, long error_code) @@ -95,7 +101,7 @@ void do_general_protection(long esp, lon void do_alignment_check(long esp, long error_code) { - die("alignment check",esp,error_code); + die("alignment check",esp,error_code); } void do_divide_error(long esp, long error_code) @@ -103,21 +109,9 @@ void do_divide_error(long esp, long erro die("divide error",esp,error_code); } -void do_int3(long * esp, long error_code, - long fs,long es,long ds, - long ebp,long esi,long edi, - long edx,long ecx,long ebx,long eax) -{ - int tr; - - __asm__("str %%ax":"=a" (tr):"0" (0)); - printk("eax\t\tebx\t\tecx\t\tedx\n\r%8x\t%8x\t%8x\t%8x\n\r", - eax,ebx,ecx,edx); - printk("esi\t\tedi\t\tebp\t\tesp\n\r%8x\t%8x\t%8x\t%8x\n\r", - esi,edi,ebp,(long) esp); - printk("\n\rds\tes\tfs\ttr\n\r%4x\t%4x\t%4x\t%4x\n\r", - ds,es,fs,tr); - printk("EIP: %8x CS: %4x EFLAGS: %8x\n\r",esp[0],esp[1],esp[2]); +void do_int3(long esp, long error_code) +{ + send_sig(SIGTRAP, current, 0); } void do_nmi(long esp, long error_code) @@ -127,7 +121,7 @@ void do_nmi(long esp, long error_code) void do_debug(long esp, long error_code) { - die("debug",esp,error_code); + send_sig(SIGTRAP, current, 0); } void do_overflow(long esp, long error_code)