x86: Simple changes to make traps_32.c and traps_64.c more similar
PATCH 1/1 x86: Simple changes to make traps_32.c and traps_64.c more similar
Tiny first step at unification of traps_32.c and traps_64.c. All changes are meant to be trivial.
- mostly whitespace changes
- chose one of obviously equivalent pieces of code:
- reordering of declarations
- simple renaming of local variables
- if (cond) { ... } -> if (!cond) goto end_of_block ...
- local caching of current, cpu, etc...
This makes the diff between traps_32.c and traps_64.c smaller:
from:
1474 +++++++++++++++++++++++++++++--------------------------------
1 file changed, 722 insertions(+), 752 deletions(-)
to:
1052 +++++++++++++++++++++++++++++--------------------------------
1 file changed, 512 insertions(+), 540 deletions(-)
---
arch/x86/kernel/traps_32.c | 141 +++++++------- arch/x86/kernel/traps_64.c | 469 ++++++++++++++++++++++---------------------- 2 files changed, 309 insertions(+), 301 deletions(-)
Hi,
This did not have much testing. The result compiles fine and boots to userspace on qemu, though. Patch is against recent -tip.
Greetings,
Alexander
arch/x86/kernel/traps_32.c +72 -69
@@ -1,5 +1,6 @@/* * Copyright (C) 1991, 1992 Linus Torvalds +* Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs * * Pentium III FXSR, SSE support * Gareth Hughes <[email protected]>, May 2000
@@ -61,8 +62,6 @@#include "mach_traps.h" -int panic_on_unrecovered_nmi; -DECLARE_BITMAP (used_vectors,NR_VECTORS );EXPORT_SYMBOL_GPL (used_vectors);
@@ -96,22 +95,26 @@ asmlinkage void page_fault(void); asmlinkage void coprocessor_error(void); asmlinkage void simd_coprocessor_error(void); asmlinkage void alignment_check(void); -asmlinkage void spurious_interrupt_bug(void); asmlinkage void machine_check(void); +asmlinkage void spurious_interrupt_bug(void); +int panic_on_unrecovered_nmi;int kstack_depth_to_print =24 ;static unsigned int code_bytes =64 ; +static int ignore_nmis; + +//#define MSG(txt) ops->warning(data, txt) void printk_address (unsigned long address,int reliable) {#ifdef CONFIG_KALLSYMS -char namebuf[KSYM_NAME_LEN ];unsigned long offset =0 ;unsigned long symsize;const char *symname; -char reliab[4 ] ="" ; -char *delim =":" ;char *modname; +char *delim =":" ; +char namebuf[KSYM_NAME_LEN ]; +char reliab[4 ] ="" ; symname =kallsyms_lookup (address, &symsize, &offset, &modname, namebuf);
@@ -131,16 +134,17 @@ void printk_address(unsigned long address, int reliable)#endif } -static inline int valid_stack_ptr (struct thread_info *tinfo,void *p,unsigned size) +static inline int valid_stack_ptr (struct thread_info *tinfo, +void *p,unsigned int size) { -return p > (void *)tinfo && - p <= (void *)tinfo +THREAD_SIZE - size; +void *t = tinfo; +return p > t && p <= t +THREAD_SIZE - size; }/* The form of the top of the frame on the stack */ struct stack_frame { -struct stack_frame *next_frame; -unsigned long return_address; +struct stack_frame *next_frame; +unsigned long return_address; }; static inline unsigned long
@@ -168,8 +172,6 @@ print_context_stack(struct thread_info *tinfo,return bp; } -#define MSG (msg) ops->warning(data, msg) -void dump_trace (struct task_struct *task,struct pt_regs *regs,unsigned long *stack,unsigned long bp,const struct stacktrace_ops *ops,void *data)
@@ -179,7 +181,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,if (!stack) {unsigned long dummy; - stack = &dummy;if (task != current) stack = (unsigned long *)task->thread.sp;
@@ -197,7 +198,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, }#endif -while (1 ) { +for (;;) {struct thread_info *context; context = (struct thread_info *)
@@ -249,10 +250,10 @@ static void print_trace_address(void *data, unsigned long addr, int reliable) }static const struct stacktrace_ops print_trace_ops = { - .warning = print_trace_warning, - .warning_symbol = print_trace_warning_symbol, - .stack = print_trace_stack, - .address = print_trace_address, + .warning = print_trace_warning, + .warning_symbol = print_trace_warning_symbol, + .stack = print_trace_stack, + .address = print_trace_address, }; static void
@@ -352,15 +353,14 @@ void show_registers(struct pt_regs *regs)printk (KERN_EMERG "Code: " ); ip = (u8 *)regs->ip - code_prologue; -if (ip < (u8 *)PAGE_OFFSET || -probe_kernel_address (ip, c)) { +if (ip < (u8 *)PAGE_OFFSET ||probe_kernel_address (ip, c)) {/* try starting at EIP */ ip = (u8 *)regs->ip; code_len = code_len - code_prologue +1 ; }for (i =0 ; i < code_len; i++, ip++) {if (ip < (u8 *)PAGE_OFFSET || -probe_kernel_address (ip, c)) { +probe_kernel_address (ip, c)) {printk (" Bad EIP value." );break ; }
@@ -405,24 +405,22 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)printk ("\n" );if (notify_die (DIE_OOPS , str, regs, err, - current->thread.trap_no,SIGSEGV ) !=NOTIFY_STOP ) { - -show_registers (regs); -/* Executive summary in case the oops scrolled away */ - sp = (unsigned long ) (®s->sp); -savesegment (ss, ss); -if (user_mode (regs)) { - sp = regs->sp; - ss = regs->ss &0xffff ; - } -printk (KERN_EMERG "EIP: [<%08lx>] " , regs->ip); -print_symbol ("%s" , regs->ip); -printk (" SS:ESP %04x:%08lx\n" , ss, sp); + current->thread.trap_no,SIGSEGV ) ==NOTIFY_STOP ) +return 1 ; -return 0 ; +show_registers (regs); +/* Executive summary in case the oops scrolled away */ + sp = (unsigned long ) (®s->sp); +savesegment (ss, ss); +if (user_mode (regs)) { + sp = regs->sp; + ss = regs->ss &0xffff ; } +printk (KERN_EMERG "EIP: [<%08lx>] " , regs->ip); +print_symbol ("%s" , regs->ip); +printk (" SS:ESP %04x:%08lx\n" , ss, sp); -return 1 ; +return 0 ; }/*
@@ -611,6 +609,7 @@ DO_ERROR_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1)void __kprobes do_general_protection (struct pt_regs *regs,long error_code) { +struct task_struct *tsk;struct thread_struct *thread;struct tss_struct *tss;int cpu;
@@ -651,23 +650,24 @@ void __kprobes do_general_protection(struct pt_regs *regs, long error_code)if (regs->flags &X86_VM_MASK ) goto gp_in_vm86; + tsk = current;if (!user_mode (regs)) goto gp_in_kernel; - current->thread.error_code = error_code; - current->thread.trap_no =13 ; + tsk->thread.error_code = error_code; + tsk->thread.trap_no =13 ; -if (show_unhandled_signals &&unhandled_signal (current,SIGSEGV ) && +if (show_unhandled_signals &&unhandled_signal (tsk,SIGSEGV ) &&printk_ratelimit ()) {printk (KERN_INFO "%s[%d] general protection ip:%lx sp:%lx error:%lx" , - current->comm,task_pid_nr (current), + tsk->comm,task_pid_nr (tsk), regs->ip, regs->sp, error_code);print_vma_addr (" in " , regs->ip);printk ("\n" ); } -force_sig (SIGSEGV , current); +force_sig (SIGSEGV , tsk);return ; gp_in_vm86:
@@ -676,14 +676,15 @@ gp_in_vm86:return ; gp_in_kernel: -if (!fixup_exception (regs)) { - current->thread.error_code = error_code; - current->thread.trap_no =13 ; -if (notify_die (DIE_GPF ,"general protection fault" , regs, +if (fixup_exception (regs)) +return ; + + tsk->thread.error_code = error_code; + tsk->thread.trap_no =13 ; +if (notify_die (DIE_GPF ,"general protection fault" , regs, error_code,13 ,SIGSEGV ) ==NOTIFY_STOP ) -return ; -die ("general protection fault" , regs, error_code); - } +return ; +die ("general protection fault" , regs, error_code); }static notrace __kprobes void
@@ -796,14 +797,17 @@ void notrace __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic) static notrace __kprobes void default_do_nmi(struct pt_regs *regs) {unsigned char reason =0 ; +int cpu; -/* Only the BSP gets external NMIs from the system: */ -if (!smp_processor_id ()) + cpu =smp_processor_id (); + +/* Only the BSP gets external NMIs from the system. */ +if (!cpu) reason =get_nmi_reason ();if (!(reason &0xc0 )) {if (notify_die (DIE_NMI_IPI ,"nmi_ipi" , regs, reason,2 ,SIGINT ) - ==NOTIFY_STOP ) + ==NOTIFY_STOP )return ;#ifdef CONFIG_X86_LOCAL_APIC /*
@@ -812,7 +816,7 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)*/ if (nmi_watchdog_tick (regs, reason))return ; -if (!do_nmi_callback (regs,smp_processor_id ())) +if (!do_nmi_callback (regs, cpu))unknown_nmi_error (reason, regs);#else unknown_nmi_error (reason, regs);
@@ -822,6 +826,8 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs) }if (notify_die (DIE_NMI ,"nmi" , regs, reason,2 ,SIGINT ) ==NOTIFY_STOP )return ; + +/* AK: following checks seem to be broken on modern chipsets. FIXME */ if (reason &0x80 )mem_parity_error (reason, regs);if (reason &0x40 )
@@ -833,8 +839,6 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)reassert_nmi (); } -static int ignore_nmis; - notrace __kprobes void do_nmi(struct pt_regs *regs, long error_code) {int cpu;
@@ -927,7 +931,7 @@ void __kprobes do_debug(struct pt_regs *regs, long error_code) tsk->thread.debugctlmsr =0 ;if (notify_die (DIE_DEBUG ,"debug" , regs, condition, error_code, -SIGTRAP ) ==NOTIFY_STOP ) +SIGTRAP ) ==NOTIFY_STOP )return ;/* It's safe to allow irq's after DR6 has been saved */ if (regs->flags &X86_EFLAGS_IF )
@@ -988,9 +992,8 @@ clear_TF_reenable:void math_error (void __user *ip) {struct task_struct *task; -unsigned short cwd; -unsigned short swd;siginfo_t info; +unsigned short cwd, swd;/* * Save the info for the exception handler and clear the error.
@@ -1009,7 +1012,7 @@ void math_error(void __user *ip)* C1 reg you need in case of a stack fault, 0x040 is the stack * fault bit. We should only be taking one exception at a time, * so if this combination doesn't produce any single exception, -* then we have a bad program that isn't syncronizing its FPU usage +* then we have a bad program that isn't synchronizing its FPU usage * and it will suffer the consequences since we won't be able to * fully reproduce the context of the exception */
@@ -1018,7 +1021,7 @@ void math_error(void __user *ip)switch (swd & ~cwd &0x3f ) {case 0x000 :/* No unmasked exception */ return ; -default :/* Multiple exceptions */ +default :/* Multiple exceptions */ break ;case 0x001 :/* Invalid Op */ /*
@@ -1054,8 +1057,8 @@ void do_coprocessor_error(struct pt_regs *regs, long error_code)static void simd_math_error (void __user *ip) {struct task_struct *task; -unsigned short mxcsr;siginfo_t info; +unsigned short mxcsr;/* * Save the info for the exception handler and clear the error.
@@ -1213,16 +1216,16 @@ void __init trap_init(void)#ifdef CONFIG_X86_LOCAL_APIC init_apic_mappings ();#endif -set_trap_gate (0 , ÷_error); -set_intr_gate (1 , &debug); -set_intr_gate (2 , &nmi); +set_trap_gate (0 , ÷_error); +set_intr_gate (1 , &debug); +set_intr_gate (2 , &nmi);set_system_intr_gate (3 , &int3);/* int3/4 can be called from all */ set_system_gate (4 , &overflow); -set_trap_gate (5 , &bounds); -set_trap_gate (6 , &invalid_op); -set_trap_gate (7 , &device_not_available); -set_task_gate (8 ,GDT_ENTRY_DOUBLEFAULT_TSS ); -set_trap_gate (9 , &coprocessor_segment_overrun); +set_trap_gate (5 , &bounds); +set_trap_gate (6 , &invalid_op); +set_trap_gate (7 , &device_not_available); +set_task_gate (8 ,GDT_ENTRY_DOUBLEFAULT_TSS ); +set_trap_gate (9 , &coprocessor_segment_overrun);set_trap_gate (10 , &invalid_TSS);set_trap_gate (11 , &segment_not_present);set_trap_gate (12 , &stack_segment);
arch/x86/kernel/traps_64.c +237 -232
826 lines not on this page · raw message
Quoted 11 lines · Alexander van Heukelum
Tiny first step at unification of
traps_32.candtraps_64.c. All changes are meant to be trivial.
- mostly whitespace changes
- chose one of obviously equivalent pieces of code:
- reordering of declarations
- simple renaming of local variables
- if (cond) { ... } -> if (!cond) gotoend_of_block...
- local caching of current, cpu, etc...This makes the diff between
traps_32.candtraps_64.csmaller:
Quoted 7 lines
from:
1474 +++++++++++++++++++++++++++++--------------------------------1 file changed, 722 insertions(+), 752 deletions(-)to:
1052 +++++++++++++++++++++++++++++--------------------------------1 file changed, 512 insertions(+), 540 deletions(-)
nice. In terms of functionality, it is supposed to be a pure no-changes-intended commit, correct?
In that case it makes sense to split it in two: in the first (larger) bit put the things that are provably invariant on the .o and can be verified that way.
In the second one, put the things that change the .o output slightly (variable reordering can do that) - this we have to check more closely.
(One can normally do such a splitup by editing the raw diff and splitting it in half that way - by sorting each chunk into the appropriate target patch - and then making sure the end result is still the same.)
Ingo
Quoted 7 lines · Ingo Molnar
nice. In terms of functionality, it is supposed to be a pure no-changes-intended commit, correct?
In that case it makes sense to split it in two: in the first (larger) bit put the things that are provably invariant on the .o and can be verified that way.
Quoted 7 lines
In the second one, put the things that change the .o output slightly (variable reordering can do that) - this we have to check more closely.
(One can normally do such a splitup by editing the raw diff and splitting it in half that way - by sorting each chunk into the appropriate target patch - and then making sure the end result is still the same.)
Hi,
I ended up redoing it. The first patch has no influence on the generated code; the second one does not change code size and the others are more or less single logical changes.
I sent the patches as a reply to the original patch (replying to this one would have been more logical... I need some sleep now). I tested compilation and using qemu after patch 1, 2, and 7. They all run fine.
Greetings,
Alexander
Quoted 1 line
Ingo
PATCH 2/7 x86: traps_xx: shuffle headers and globals
In reply to Alexander van HeukelumReorder headers and collect globals in traps_32.c and traps_64.c
Code size and data size are unaffected by the changes. Code itself is changed due to different ordering of data and bss. The bss segment changed size due to a change in the packing of the variables.
--- arch/x86/kernel/traps_32.c | 9 ++---- arch/x86/kernel/traps_64.c | 63 +++++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 38 deletions(-)
arch/x86/kernel/traps_32.c +3 -6
@@ -62,8 +62,6 @@#include "mach_traps.h" -int panic_on_unrecovered_nmi; -DECLARE_BITMAP (used_vectors,NR_VECTORS );EXPORT_SYMBOL_GPL (used_vectors);
@@ -100,8 +98,11 @@ asmlinkage void alignment_check(void); asmlinkage void spurious_interrupt_bug(void); asmlinkage void machine_check(void); +int panic_on_unrecovered_nmi;int kstack_depth_to_print =24 ;static unsigned int code_bytes =64 ; +static int ignore_nmis; +static int die_counter;void printk_address (unsigned long address,int reliable) {
@@ -383,8 +384,6 @@ int is_valid_bugaddr(unsigned long ip)return ud2 ==0x0b0f ; } -static int die_counter; -int __kprobes __die (const char *str,struct pt_regs *regs,long err) {unsigned short ss;
@@ -833,8 +832,6 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)reassert_nmi (); } -static int ignore_nmis; - notrace __kprobes void do_nmi(struct pt_regs *regs, long error_code) {int cpu;
arch/x86/kernel/traps_64.c +31 -32
108 lines not on this page · raw message
Signature · 1 line
1.5.4.3
PATCH 3/7 x86: traps_xx: modify __die
In reply to Alexander van Heukelumif (cond) block -> if (!cond) goto end_of_block
--- arch/x86/kernel/traps_32.c | 32 ++++++++++++++------------------ arch/x86/kernel/traps_64.c | 4 ++-- 2 files changed, 16 insertions(+), 20 deletions(-)
arch/x86/kernel/traps_32.c +13 -17
@@ -400,26 +400,22 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)printk ("DEBUG_PAGEALLOC" );#endif printk ("\n" ); -if (notify_die (DIE_OOPS , str, regs, err, - current->thread.trap_no,SIGSEGV ) !=NOTIFY_STOP ) { - -show_registers (regs); -/* Executive summary in case the oops scrolled away */ - sp = (unsigned long ) (®s->sp); -savesegment (ss, ss); -if (user_mode (regs)) { - sp = regs->sp; - ss = regs->ss &0xffff ; - } -printk (KERN_EMERG "EIP: [<%08lx>] " , regs->ip); -print_symbol ("%s" , regs->ip); -printk (" SS:ESP %04x:%08lx\n" , ss, sp); + current->thread.trap_no,SIGSEGV ) ==NOTIFY_STOP ) +return 1 ; -return 0 ; +show_registers (regs); +/* Executive summary in case the oops scrolled away */ + sp = (unsigned long ) (®s->sp); +savesegment (ss, ss); +if (user_mode (regs)) { + sp = regs->sp; + ss = regs->ss &0xffff ; } - -return 1 ; +printk (KERN_EMERG "EIP: [<%08lx>] " , regs->ip); +print_symbol ("%s" , regs->ip); +printk (" SS:ESP %04x:%08lx\n" , ss, sp); +return 0 ; }/*
arch/x86/kernel/traps_64.c +2 -2
@@ -562,9 +562,9 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)do_exit (signr); } -int __kprobes __die (const char * str,struct pt_regs * regs,long err) +int __kprobes __die (const char *str,struct pt_regs *regs,long err) { -printk (KERN_EMERG "%s: %04lx [%u] " , str, err &0xffff ,++die_counter); +printk (KERN_EMERG "%s: %04lx [%u] " , str, err &0xffff , ++die_counter);#ifdef CONFIG_PREEMPT printk ("PREEMPT " );#endif
Signature · 1 line
1.5.4.3
PATCH 4/7 x86: traps_xx: modify do_trap
In reply to Alexander van Heukelumif (cond) block -> if (!cond) goto end_of_block
--- arch/x86/kernel/traps_64.c | 56 ++++++++++++++++++++++---------------------- 1 files changed, 28 insertions(+), 28 deletions(-)
arch/x86/kernel/traps_64.c +28 -28
@@ -635,38 +635,38 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs, {struct task_struct *tsk = current; -if (user_mode (regs)) { -/* -* We want error_code and trap_no set for userspace -* faults and kernelspace faults which result in -* die(), but not kernelspace faults which are fixed -* up. die() gives the process no chance to handle -* the signal and notice the kernel fault information, -* so that won't result in polluting the information -* about previously queued, but not yet delivered, -* faults. See also do_general_protection below. -*/ - tsk->thread.error_code = error_code; - tsk->thread.trap_no = trapnr; - -if (show_unhandled_signals &&unhandled_signal (tsk, signr) && -printk_ratelimit ()) { -printk (KERN_INFO -"%s[%d] trap %s ip:%lx sp:%lx error:%lx" , - tsk->comm, tsk->pid, str, - regs->ip, regs->sp, error_code); -print_vma_addr (" in " , regs->ip); -printk ("\n" ); - } +if (!user_mode (regs)) + goto kernel_trap; -if (info) -force_sig_info (signr, info, tsk); -else -force_sig (signr, tsk); -return ; +/* +* We want error_code and trap_no set for userspace faults and +* kernelspace faults which result in die(), but not +* kernelspace faults which are fixed up. die() gives the +* process no chance to handle the signal and notice the +* kernel fault information, so that won't result in polluting +* the information about previously queued, but not yet +* delivered, faults. See also do_general_protection below. +*/ + tsk->thread.error_code = error_code; + tsk->thread.trap_no = trapnr; + +if (show_unhandled_signals &&unhandled_signal (tsk, signr) && +printk_ratelimit ()) { +printk (KERN_INFO +"%s[%d] trap %s ip:%lx sp:%lx error:%lx" , + tsk->comm, tsk->pid, str, + regs->ip, regs->sp, error_code); +print_vma_addr (" in " , regs->ip); +printk ("\n" ); } +if (info) +force_sig_info (signr, info, tsk); +else +force_sig (signr, tsk); +return ; +kernel_trap:if (!fixup_exception (regs)) { tsk->thread.error_code = error_code; tsk->thread.trap_no = trapnr;
Signature · 1 line
1.5.4.3
PATCH 1/1 x86: initial changes to unify traps_32.c and traps_64.c
In reply to Alexander van HeukelumThis patch does not change the generated object files.
--- arch/x86/kernel/traps_32.c | 78 ++++++------ arch/x86/kernel/traps_64.c | 309 ++++++++++++++++++++++---------------------- 2 files changed, 191 insertions(+), 196 deletions(-)
arch/x86/kernel/traps_32.c +39 -39
@@ -1,5 +1,6 @@/* * Copyright (C) 1991, 1992 Linus Torvalds +* Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs * * Pentium III FXSR, SSE support * Gareth Hughes <[email protected]>, May 2000
@@ -131,7 +132,8 @@ void printk_address(unsigned long address, int reliable)#endif } -static inline int valid_stack_ptr (struct thread_info *tinfo,void *p,unsigned size) +static inline int valid_stack_ptr (struct thread_info *tinfo, +void *p,unsigned int size) {return p > (void *)tinfo && p <= (void *)tinfo +THREAD_SIZE - size;
@@ -139,14 +141,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo, void *p, unsigned s/* The form of the top of the frame on the stack */ struct stack_frame { -struct stack_frame *next_frame; -unsigned long return_address; +struct stack_frame *next_frame; +unsigned long return_address; };static inline unsigned long print_context_stack (struct thread_info *tinfo, -unsigned long *stack,unsigned long bp, -const struct stacktrace_ops *ops,void *data) +unsigned long *stack,unsigned long bp, +const struct stacktrace_ops *ops,void *data) {struct stack_frame *frame = (struct stack_frame *)bp;
@@ -168,8 +170,6 @@ print_context_stack(struct thread_info *tinfo,return bp; } -#define MSG (msg) ops->warning(data, msg) -void dump_trace (struct task_struct *task,struct pt_regs *regs,unsigned long *stack,unsigned long bp,const struct stacktrace_ops *ops,void *data)
@@ -179,7 +179,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,if (!stack) {unsigned long dummy; - stack = &dummy;if (task != current) stack = (unsigned long *)task->thread.sp;
@@ -197,7 +196,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, }#endif -while (1 ) { +for (;;) {struct thread_info *context; context = (struct thread_info *)
@@ -249,10 +248,10 @@ static void print_trace_address(void *data, unsigned long addr, int reliable) }static const struct stacktrace_ops print_trace_ops = { - .warning = print_trace_warning, - .warning_symbol = print_trace_warning_symbol, - .stack = print_trace_stack, - .address = print_trace_address, + .warning = print_trace_warning, + .warning_symbol = print_trace_warning_symbol, + .stack = print_trace_stack, + .address = print_trace_address, }; static void
@@ -352,15 +351,14 @@ void show_registers(struct pt_regs *regs)printk (KERN_EMERG "Code: " ); ip = (u8 *)regs->ip - code_prologue; -if (ip < (u8 *)PAGE_OFFSET || -probe_kernel_address (ip, c)) { +if (ip < (u8 *)PAGE_OFFSET ||probe_kernel_address (ip, c)) {/* try starting at EIP */ ip = (u8 *)regs->ip; code_len = code_len - code_prologue +1 ; }for (i =0 ; i < code_len; i++, ip++) {if (ip < (u8 *)PAGE_OFFSET || -probe_kernel_address (ip, c)) { +probe_kernel_address (ip, c)) {printk (" Bad EIP value." );break ; }
@@ -550,7 +548,7 @@ void do_##name(struct pt_regs *regs, long error_code) \ { \trace_hardirqs_fixup (); \if (notify_die (DIE_TRAP , str, regs, error_code, trapnr, signr) \ - ==NOTIFY_STOP ) \ + ==NOTIFY_STOP ) \return ; \do_trap (trapnr, signr, str,0 , regs, error_code,NULL ); \ }
@@ -566,7 +564,7 @@ void do_##name(struct pt_regs *regs, long error_code) \ info.si_code = sicode; \ info.si_addr = (void __user *)siaddr; \if (notify_die (DIE_TRAP , str, regs, error_code, trapnr, signr) \ - ==NOTIFY_STOP ) \ + ==NOTIFY_STOP ) \return ; \do_trap (trapnr, signr, str,0 , regs, error_code, &info); \ }
@@ -575,7 +573,7 @@ void do_##name(struct pt_regs *regs, long error_code) \ void do_##name(struct pt_regs *regs, long error_code) \ { \ if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ - == NOTIFY_STOP) \ + == NOTIFY_STOP) \ return; \ do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \ }
@@ -590,22 +588,22 @@ void do_##name(struct pt_regs *regs, long error_code) \ info.si_addr = (void __user *)siaddr; \trace_hardirqs_fixup (); \if (notify_die (DIE_TRAP , str, regs, error_code, trapnr, signr) \ - ==NOTIFY_STOP ) \ + ==NOTIFY_STOP ) \return ; \do_trap (trapnr, signr, str,1 , regs, error_code, &info); \ } -DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip) +DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)#if !defined(CONFIG_KPROBES ) && !defined(CONFIG_IMMEDIATE ) DO_VM86_ERROR(3, SIGTRAP, "int3", int3)#endif DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow) DO_VM86_ERROR(5, SIGSEGV, "bounds", bounds) -DO_ERROR_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0) -DO_ERROR(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun) +DO_ERROR_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0) +DO_ERROR(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun) DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS) -DO_ERROR(11, SIGBUS, "segment not present", segment_not_present) -DO_ERROR(12, SIGBUS, "stack segment", stack_segment) +DO_ERROR(11, SIGBUS, "segment not present", segment_not_present) +DO_ERROR(12, SIGBUS, "stack segment", stack_segment) DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0)DO_ERROR_INFO (32 ,SIGILL ,"iret exception" , iret_error,ILL_BADSTK ,0 ,1 )
@@ -803,7 +801,7 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)if (!(reason &0xc0 )) {if (notify_die (DIE_NMI_IPI ,"nmi_ipi" , regs, reason,2 ,SIGINT ) - ==NOTIFY_STOP ) + ==NOTIFY_STOP )return ;#ifdef CONFIG_X86_LOCAL_APIC /*
@@ -822,6 +820,8 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs) }if (notify_die (DIE_NMI ,"nmi" , regs, reason,2 ,SIGINT ) ==NOTIFY_STOP )return ; + +/* AK: following checks seem to be broken on modern chipsets. FIXME */ if (reason &0x80 )mem_parity_error (reason, regs);if (reason &0x40 )
@@ -927,7 +927,7 @@ void __kprobes do_debug(struct pt_regs *regs, long error_code) tsk->thread.debugctlmsr =0 ;if (notify_die (DIE_DEBUG ,"debug" , regs, condition, error_code, -SIGTRAP ) ==NOTIFY_STOP ) +SIGTRAP ) ==NOTIFY_STOP )return ;/* It's safe to allow irq's after DR6 has been saved */ if (regs->flags &X86_EFLAGS_IF )
@@ -1009,7 +1009,7 @@ void math_error(void __user *ip)* C1 reg you need in case of a stack fault, 0x040 is the stack * fault bit. We should only be taking one exception at a time, * so if this combination doesn't produce any single exception, -* then we have a bad program that isn't syncronizing its FPU usage +* then we have a bad program that isn't synchronizing its FPU usage * and it will suffer the consequences since we won't be able to * fully reproduce the context of the exception */
@@ -1018,7 +1018,7 @@ void math_error(void __user *ip)switch (swd & ~cwd &0x3f ) {case 0x000 :/* No unmasked exception */ return ; -default :/* Multiple exceptions */ +default :/* Multiple exceptions */ break ;case 0x001 :/* Invalid Op */ /*
@@ -1213,16 +1213,16 @@ void __init trap_init(void)#ifdef CONFIG_X86_LOCAL_APIC init_apic_mappings ();#endif -set_trap_gate (0 , ÷_error); -set_intr_gate (1 , &debug); -set_intr_gate (2 , &nmi); -set_system_intr_gate (3 , &int3);/* int3/4 can be called from all */ -set_system_gate (4 , &overflow); -set_trap_gate (5 , &bounds); -set_trap_gate (6 , &invalid_op); -set_trap_gate (7 , &device_not_available); -set_task_gate (8 ,GDT_ENTRY_DOUBLEFAULT_TSS ); -set_trap_gate (9 , &coprocessor_segment_overrun); +set_trap_gate (0 , ÷_error); +set_intr_gate (1 , &debug); +set_intr_gate (2 , &nmi); +set_system_intr_gate (3 , &int3);/* int3 can be called from all */ +set_system_gate (4 , &overflow);/* int4 can be called from all */ +set_trap_gate (5 , &bounds); +set_trap_gate (6 , &invalid_op); +set_trap_gate (7 , &device_not_available); +set_task_gate (8 ,GDT_ENTRY_DOUBLEFAULT_TSS ); +set_trap_gate (9 , &coprocessor_segment_overrun);set_trap_gate (10 , &invalid_TSS);set_trap_gate (11 , &segment_not_present);set_trap_gate (12 , &stack_segment);
arch/x86/kernel/traps_64.c +152 -157
600 lines not on this page · raw message
Signature · 1 line
1.5.4.3
PATCH 1/1 x86: traps_xx: modify default_do_nmi
In reply to Alexander van Heukelum - local caching of smp_processor_id()
--- arch/x86/kernel/traps_32.c | 12 ++++++++---- arch/x86/kernel/traps_64.c | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-)
arch/x86/kernel/traps_32.c +8 -4
@@ -790,12 +790,16 @@ void notrace __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic)do_exit (SIGSEGV ); } -static notrace __kprobes void default_do_nmi(struct pt_regs *regs) +static notrace __kprobes void +default_do_nmi (struct pt_regs *regs) {unsigned char reason =0 ; +int cpu; + + cpu =smp_processor_id (); -/* Only the BSP gets external NMIs from the system: */ -if (!smp_processor_id ()) +/* Only the BSP gets external NMIs from the system. */ +if (!cpu) reason =get_nmi_reason ();if (!(reason &0xc0 )) {
@@ -809,7 +813,7 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)*/ if (nmi_watchdog_tick (regs, reason))return ; -if (!do_nmi_callback (regs,smp_processor_id ())) +if (!do_nmi_callback (regs, cpu))unknown_nmi_error (reason, regs);#else unknown_nmi_error (reason, regs);
arch/x86/kernel/traps_64.c +2 -1
@@ -832,7 +832,8 @@ unknown_nmi_error(unsigned char reason, struct pt_regs * regs)/* Runs on IST stack. This code must keep interrupts off all the time. Nested NMIs are prevented by the CPU. */ -asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs) +asmlinkage notrace __kprobes void +default_do_nmi (struct pt_regs *regs) {unsigned char reason =0 ;int cpu;
Signature · 1 line
1.5.4.3
Re: [PATCH] x86: traps_xx: modify default_do_nmi
[Alexander van Heukelum - Wed, Jul 02, 2008 at 01:32:28AM +0200]
| - local caching of smp_processor_id() | | Signed-off-by: Alexander van Heukelum <[email protected]> | --- | arch/x86/kernel/traps_32.c | 12 ++++++++---- | arch/x86/kernel/traps_64.c | 3 ++- | 2 files changed, 10 insertions(+), 5 deletions(-) | | diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c | index 68e800f..14fe3cd 100644 | --- a/arch/x86/kernel/traps_32.c | +++ b/arch/x86/kernel/traps_32.c | @@ -790,12 +790,16 @@ void notrace __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic) | do_exit(SIGSEGV); | } | | -static notrace __kprobes void default_do_nmi(struct pt_regs *regs) | +static notrace __kprobes void | +default_do_nmi(struct pt_regs *regs) | { | unsigned char reason = 0; | + int cpu; | + | + cpu = smp_processor_id(); | | - /* Only the BSP gets external NMIs from the system: */ | - if (!smp_processor_id()) | + /* Only the BSP gets external NMIs from the system. */ | + if (!cpu) | reason = get_nmi_reason(); | | if (!(reason & 0xc0)) { | @@ -809,7 +813,7 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs) | */ | if (nmi_watchdog_tick(regs, reason)) | return; | - if (!do_nmi_callback(regs, smp_processor_id())) | + if (!do_nmi_callback(regs, cpu)) | unknown_nmi_error(reason, regs); | #else | unknown_nmi_error(reason, regs); | diff --git a/arch/x86/kernel/traps_64.c b/arch/x86/kernel/traps_64.c | index 677b4e5..2f8d87d 100644 | --- a/arch/x86/kernel/traps_64.c | +++ b/arch/x86/kernel/traps_64.c | @@ -832,7 +832,8 @@ unknown_nmi_error(unsigned char reason, struct pt_regs * regs) | | /* Runs on IST stack. This code must keep interrupts off all the time. | Nested NMIs are prevented by the CPU. */ | -asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs) | +asmlinkage notrace __kprobes void | +default_do_nmi(struct pt_regs *regs) | { | unsigned char reason = 0; | int cpu; | -- | 1.5.4.3 | |
Hi Alexander, good done, thanks! But why did you split default_do_nmi definition by two lines? I think it would be better to keep them as it was before, ie by a single line
static notrace __kprobes void default_do_nmi(struct pt_regs *regs)
- Cyrill -
PATCH v2 6/7 x86: traps_xx: modify default_do_nmi
- local caching of smp_processor_id() in default_do_nmi()
- v2: do not split default_do_nmi over two lines
---
Quoted 8 lines · Cyrill Gorcunov
| -static notrace __kprobes void default_do_nmi(struct pt_regs *regs) | +static notrace __kprobes void | +default_do_nmi(struct pt_regs *regs) | [ ... ] | -asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs) | +asmlinkage notrace __kprobes void | +default_do_nmi(struct pt_regs *regs)
Quoted 5 lines
Hi Alexander, good done, thanks! But why did you split
default_do_nmidefinition by two lines? I think it would be better to keep them as it was before, ie by a single linestatic notrace
__kprobesvoiddefault_do_nmi(struct pt_regs *regs)
Thanks! Here is the replacement patch with default_do_nmi left on a single line. Patch 7 applies with 1 line fuzz.
Greetings,
Alexander
Quoted 1 line
- Cyrill -
arch/x86/kernel/traps_32.c +6 -3
@@ -793,9 +793,12 @@ void notrace __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic) static notrace __kprobes void default_do_nmi(struct pt_regs *regs) {unsigned char reason =0 ; +int cpu; + + cpu =smp_processor_id (); -/* Only the BSP gets external NMIs from the system: */ -if (!smp_processor_id ()) +/* Only the BSP gets external NMIs from the system. */ +if (!cpu) reason =get_nmi_reason ();if (!(reason &0xc0 )) {
@@ -809,7 +812,7 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)*/ if (nmi_watchdog_tick (regs, reason))return ; -if (!do_nmi_callback (regs,smp_processor_id ())) +if (!do_nmi_callback (regs, cpu))unknown_nmi_error (reason, regs);#else unknown_nmi_error (reason, regs);
arch/x86/kernel/traps_64.c +1 -1
@@ -832,7 +832,7 @@ unknown_nmi_error(unsigned char reason, struct pt_regs * regs)/* Runs on IST stack. This code must keep interrupts off all the time. Nested NMIs are prevented by the CPU. */ -asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs) +asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs) {unsigned char reason =0 ;int cpu;
Re: [PATCHv2 6/7] x86: traps_xx: modify default_do_nmi
[Alexander van Heukelum - Wed, Jul 02, 2008 at 06:39:01PM +0200]
| - local caching of smp_processor_id() in default_do_nmi() | - v2: do not split default_do_nmi over two lines | | Signed-off-by: Alexander van Heukelum <[email protected]> | | --- | | On Wed, Jul 02, 2008 at 08:12:20PM +0400, Cyrill Gorcunov wrote: | > | -static notrace __kprobes void default_do_nmi(struct pt_regs *regs) | > | +static notrace __kprobes void | > | +default_do_nmi(struct pt_regs *regs) | > | [ ... ] | > | -asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs) | > | +asmlinkage notrace __kprobes void | > | +default_do_nmi(struct pt_regs *regs) | > | > Hi Alexander, good done, thanks! But why did you split default_do_nmi | > definition by two lines? I think it would be better to keep them as it | > was before, ie by a single line | > | > static notrace __kprobes void default_do_nmi(struct pt_regs *regs) | | Thanks! Here is the replacement patch with default_do_nmi left on | a single line. Patch 7 applies with 1 line fuzz. | | Greetings, | Alexander |
Thanks, Alexander, this looks good to me. Feel free to add my Signed-off if you need it.
- Cyrill -
Re: [PATCHv2 6/7] x86: traps_xx: modify default_do_nmi
Quoted 30 lines · Cyrill Gorcunov
[Alexander van Heukelum - Wed, Jul 02, 2008 at 06:39:01PM +0200]
| - local caching of smp_processor_id() in default_do_nmi() | - v2: do not split default_do_nmi over two lines | | Signed-off-by: Alexander van Heukelum <[email protected]> | | --- | | On Wed, Jul 02, 2008 at 08:12:20PM +0400, Cyrill Gorcunov wrote: | > | -static notrace __kprobes void default_do_nmi(struct pt_regs *regs) | > | +static notrace __kprobes void | > | +default_do_nmi(struct pt_regs *regs) | > | [ ... ] | > | -asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs) | > | +asmlinkage notrace __kprobes void | > | +default_do_nmi(struct pt_regs *regs) | > | > Hi Alexander, good done, thanks! But why did you split default_do_nmi | > definition by two lines? I think it would be better to keep them as it | > was before, ie by a single line | > | > static notrace __kprobes void default_do_nmi(struct pt_regs *regs) | | Thanks! Here is the replacement patch with default_do_nmi left on | a single line. Patch 7 applies with 1 line fuzz. | | Greetings, | Alexander |
Quoted 2 lines
Thanks, Alexander, this looks good to me. Feel free to add my Signed-off if you need it.
Thanks Alexander, i've picked them up into tip/x86/core:
Alexander van Heukelum (7):
x86: initial changes to unify traps_32.c and traps_64.c
x86: traps_xx: shuffle headers and globals
x86: traps_xx: modify __die
x86: traps_xx: modify do_trap
x86: traps_xx: restructure do_general_protection()
x86: traps_xx: modify default_do_nmi
x86: traps_xx: various small changes
i've added Cyrill's Acked-by lines as well. (We use Signed-off is when routing patches)
Ingo
PATCH 5/7 x86: traps_xx: restructure do_general_protection()
In reply to Alexander van Heukelum - if (cond) block -> if (!cond) goto end_of_block
- local caching of current
--- arch/x86/kernel/traps_32.c | 36 ++++++++++++++++++++---------------- arch/x86/kernel/traps_64.c | 41 ++++++++++++++++++++++------------------- 2 files changed, 42 insertions(+), 35 deletions(-)
arch/x86/kernel/traps_32.c +20 -16
@@ -602,8 +602,10 @@ DO_ERROR(12, SIGBUS, "stack segment", stack_segment) DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0) DO_ERROR_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1) -void __kprobes do_general_protection (struct pt_regs *regs,long error_code) +void __kprobes +do_general_protection (struct pt_regs *regs,long error_code) { +struct task_struct *tsk;struct thread_struct *thread;struct tss_struct *tss;int cpu;
@@ -644,23 +646,24 @@ void __kprobes do_general_protection(struct pt_regs *regs, long error_code)if (regs->flags &X86_VM_MASK ) goto gp_in_vm86; + tsk = current;if (!user_mode (regs)) goto gp_in_kernel; - current->thread.error_code = error_code; - current->thread.trap_no =13 ; + tsk->thread.error_code = error_code; + tsk->thread.trap_no =13 ; -if (show_unhandled_signals &&unhandled_signal (current,SIGSEGV ) && -printk_ratelimit ()) { +if (show_unhandled_signals &&unhandled_signal (tsk,SIGSEGV ) && +printk_ratelimit ()) {printk (KERN_INFO -"%s[%d] general protection ip:%lx sp:%lx error:%lx" , - current->comm,task_pid_nr (current), - regs->ip, regs->sp, error_code); +"%s[%d] general protection ip:%lx sp:%lx error:%lx" , + tsk->comm,task_pid_nr (tsk), + regs->ip, regs->sp, error_code);print_vma_addr (" in " , regs->ip);printk ("\n" ); } -force_sig (SIGSEGV , current); +force_sig (SIGSEGV , tsk);return ; gp_in_vm86:
@@ -669,14 +672,15 @@ gp_in_vm86:return ; gp_in_kernel: -if (!fixup_exception (regs)) { - current->thread.error_code = error_code; - current->thread.trap_no =13 ; -if (notify_die (DIE_GPF ,"general protection fault" , regs, +if (fixup_exception (regs)) +return ; + + tsk->thread.error_code = error_code; + tsk->thread.trap_no =13 ; +if (notify_die (DIE_GPF ,"general protection fault" , regs, error_code,13 ,SIGSEGV ) ==NOTIFY_STOP ) -return ; -die ("general protection fault" , regs, error_code); - } +return ; +die ("general protection fault" , regs, error_code); }static notrace __kprobes void
arch/x86/kernel/traps_64.c +22 -19
53 lines not on this page · raw message
Signature · 1 line
1.5.4.3
PATCH 7/7 x86: traps_xx: various small changes
In reply to Alexander van Heukelum - order of local variable declarations
- minor code changes
--- arch/x86/kernel/traps_32.c | 15 +++++++-------- arch/x86/kernel/traps_64.c | 23 +++++++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-)
arch/x86/kernel/traps_32.c +7 -8
@@ -107,13 +107,13 @@ static int die_counter;void printk_address (unsigned long address,int reliable) {#ifdef CONFIG_KALLSYMS -char namebuf[KSYM_NAME_LEN ];unsigned long offset =0 ;unsigned long symsize;const char *symname; -char reliab[4 ] ="" ; -char *delim =":" ;char *modname; +char *delim =":" ; +char namebuf[KSYM_NAME_LEN ]; +char reliab[4 ] ="" ; symname =kallsyms_lookup (address, &symsize, &offset, &modname, namebuf);
@@ -136,8 +136,8 @@ void printk_address(unsigned long address, int reliable)static inline int valid_stack_ptr (struct thread_info *tinfo,void *p,unsigned int size) { -return p > (void *)tinfo && - p <= (void *)tinfo +THREAD_SIZE - size; +void *t = tinfo; +return p > t && p <= t +THREAD_SIZE - size; }/* The form of the top of the frame on the stack */
@@ -989,9 +989,8 @@ clear_TF_reenable:void math_error (void __user *ip) {struct task_struct *task; -unsigned short cwd; -unsigned short swd;siginfo_t info; +unsigned short cwd, swd;/* * Save the info for the exception handler and clear the error.
@@ -1055,8 +1054,8 @@ void do_coprocessor_error(struct pt_regs *regs, long error_code)static void simd_math_error (void __user *ip) {struct task_struct *task; -unsigned short mxcsr;siginfo_t info; +unsigned short mxcsr;/* * Save the info for the exception handler and clear the error.
arch/x86/kernel/traps_64.c +13 -10
@@ -107,7 +107,8 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)void printk_address (unsigned long address,int reliable) {#ifdef CONFIG_KALLSYMS -unsigned long offset =0 , symsize; +unsigned long offset =0 ; +unsigned long symsize;const char *symname;char *modname;char *delim =":" ;
@@ -269,7 +270,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,if (!task) task = current; - tinfo =task_thread_info (task);if (!stack) {unsigned long dummy;
@@ -295,6 +295,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,* current stack address. If the stacks consist of nested * exceptions */ + tinfo =task_thread_info (task);for (;;) {char *id;unsigned long *estack_end;
@@ -436,8 +437,8 @@ void show_stack(struct task_struct *task, unsigned long *sp)*/ void dump_stack (void ) { -unsigned long stack;unsigned long bp =0 ; +unsigned long stack;#ifdef CONFIG_FRAME_POINTER if (!bp)
@@ -460,12 +461,8 @@ void show_registers(struct pt_regs *regs)unsigned long sp;const int cpu =smp_processor_id ();struct task_struct *cur =cpu_pda (cpu)->pcurrent; -u8 *ip; -unsigned int code_prologue = code_bytes *43 /64 ; -unsigned int code_len = code_bytes; sp = regs->sp; - ip = (u8 *) regs->ip - code_prologue;printk ("CPU %d " , cpu);__show_regs (regs,1 ); printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
@@ -476,12 +473,18 @@ void show_registers(struct pt_regs *regs)* time of the fault.. */ if (!user_mode (regs)) { +unsigned int code_prologue = code_bytes *43 /64 ; +unsigned int code_len = code_bytes;unsigned char c; +u8 *ip; +printk ("Stack: " );_show_stack (NULL , regs, (unsigned long *)sp, regs->bp);printk ("\n" );printk (KERN_EMERG "Code: " ); + + ip = (u8 *)regs->ip - code_prologue;if (ip < (u8 *)PAGE_OFFSET ||probe_kernel_address (ip, c)) {/* try starting at RIP */ ip = (u8 *)regs->ip;
@@ -590,7 +593,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)return 0 ; } -void die (const char * str,struct pt_regs *regs,long err) +void die (const char *str,struct pt_regs *regs,long err) {unsigned long flags =oops_begin ();
@@ -933,8 +936,8 @@ asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs) asmlinkage void __kprobes do_debug(struct pt_regs * regs,unsigned long error_code) { -unsigned long condition;struct task_struct *tsk = current; +unsigned long condition;siginfo_t info;trace_hardirqs_fixup ();
@@ -1215,7 +1218,7 @@ void __init trap_init(void)/* * initialize the per thread extended state: */ -init_thread_xstate (); +init_thread_xstate ();/* * Should be a barrier for any external CPU state: */
Signature · 1 line
1.5.4.3