Exceptions Notifier patch
PATCH 1/4 Exceptions Notifier patch
Hi,
Below is [1/4] i386_exception_notifiers-268-rc4.patch.
This patch provides notifier for i386 architecture exceptions. This patch has been ported from x86_64 architecture as suggested by Andi Kleen.
Please let me know your comments.
Thanks
Prasanna
Signature · 5 lines
Prasanna S Panchamukhi Linux Technology Center India Software Labs, IBM Bangalore Ph: 91-80-25044636 <[email protected]>
This patch provides notifiers for i386 architecture exceptions. This patch has been ported from x86_64 architecture as suggested by Andi Kleen.
---
---
arch/i386/kernel/i386_ksyms.c renamed from arch/i386/kernel/i386_ksyms.c~i386_exception_notifiers-268-rc3 +2 -0
@@ -32,6 +32,7 @@#include <asm/tlbflush.h> #include <asm/nmi.h> #include <asm/ist.h> +#include <asm/kdebug.h> extern void dump_thread (struct pt_regs *,struct user *);extern spinlock_t rtc_lock;
@@ -177,6 +178,7 @@ EXPORT_SYMBOL_GPL(unset_nmi_callback);extern int memcmp (const void *,const void *,__kernel_size_t );EXPORT_SYMBOL_NOVERS (memcmp); +EXPORT_SYMBOL (register_die_chain_notify);#ifdef CONFIG_HAVE_DEC_LOCK EXPORT_SYMBOL (atomic_dec_and_lock);#endif
arch/i386/kernel/traps.c renamed from arch/i386/kernel/traps.c~i386_exception_notifiers-268-rc3 +38 -1
@@ -48,6 +48,7 @@#include <asm/smp.h> #include <asm/arch_hooks.h> +#include <asm/kdebug.h> #include <linux/irq.h> #include <linux/module.h>
@@ -92,6 +93,17 @@ asmlinkage void spurious_interrupt_bug(v asmlinkage void machine_check(void);static int kstack_depth_to_print =24 ; +struct notifier_block *i386die_chain; +static DECLARE_MUTEX (i386die_chain_mutex); + +int register_die_chain_notify (struct notifier_block *nb) +{ +int err =0 ; +down (&i386die_chain_mutex); + err =notifier_chain_register (&i386die_chain, nb); +up (&i386die_chain_mutex); +return err; +}static int valid_stack_ptr (struct task_struct *task,void *p) {
@@ -318,6 +330,7 @@ void die(const char * str, struct pt_reg#endif if (nl)printk ("\n" ); +notify_die (DIE_OOPS , (char *)str, regs, err,255 ,SIGSEGV );show_registers (regs);bust_spinlocks (0 );spin_unlock_irq (&die_lock);
@@ -387,6 +400,9 @@ static inline void do_trap(int trapnr, i#define DO_ERROR (trapnr, signr, str, name) \ asmlinkage void do_##name(struct pt_regs * regs, long error_code) \ { \ + if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ + == NOTIFY_OK) \ + return; \ do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \ }
@@ -398,12 +414,18 @@ asmlinkage void do_##name(struct pt_regs info.si_errno =0 ; \ info.si_code = sicode; \ info.si_addr = (void __user *)siaddr; \ +if (notify_die (DIE_TRAP , str, regs, error_code, trapnr, signr) \ + ==NOTIFY_BAD ) \ +return ; \do_trap (trapnr, signr, str,0 , regs, error_code, &info); \ }#define DO_VM86_ERROR (trapnr, signr, str, name) \ asmlinkage void do_##name(struct pt_regs * regs, long error_code) \ { \ + if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ + == NOTIFY_OK) \ + return; \ do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \ }
@@ -415,6 +437,9 @@ asmlinkage void do_##name(struct pt_regs info.si_errno =0 ; \ info.si_code = sicode; \ info.si_addr = (void __user *)siaddr; \ +if (notify_die (DIE_TRAP , str, regs, error_code, trapnr, signr) \ + ==NOTIFY_OK ) \ +return ; \do_trap (trapnr, signr, str,1 , regs, error_code, &info); \ }
@@ -451,8 +476,12 @@ gp_in_vm86:return ; gp_in_kernel: -if (!fixup_exception (regs)) +if (!fixup_exception (regs)) { +if (notify_die (DIE_GPF ,"general protection fault" , regs, + error_code,13 ,SIGSEGV ) ==NOTIFY_OK ); +return ;die ("general protection fault" , regs, error_code); + } }static void mem_parity_error (unsigned char reason,struct pt_regs * regs)
@@ -501,6 +530,9 @@ static void default_do_nmi(struct pt_regunsigned char reason =get_nmi_reason ();if (!(reason &0xc0 )) { +if (notify_die (DIE_NMI_IPI ,"nmi_ipi" , regs, reason,0 ,SIGINT ) + ==NOTIFY_BAD ) +return ;#ifdef CONFIG_X86_LOCAL_APIC /* * Ok, so this is none of the documented NMI sources,
@@ -514,6 +546,8 @@ static void default_do_nmi(struct pt_regunknown_nmi_error (reason, regs);return ; } +if (notify_die (DIE_NMI ,"nmi" , regs, reason,0 ,SIGINT ) ==NOTIFY_BAD ) +return ;if (reason &0x80 )mem_parity_error (reason, regs);if (reason &0x40 )
@@ -587,6 +621,9 @@ asmlinkage void do_debug(struct pt_regs __asm__ __volatile__("movl %%db6,%0" :"=r" (condition)); +if (notify_die (DIE_DEBUG ,"debug" , regs, condition, error_code, +SIGTRAP ) ==NOTIFY_OK ) +return ;/* It's safe to allow irq's after DR6 has been saved */ if (regs->eflags &X86_EFLAGS_IF )local_irq_enable ();
arch/i386/mm/fault.c renamed from arch/i386/mm/fault.c~i386_exception_notifiers-268-rc3 +4 -0
@@ -26,6 +26,7 @@#include <asm/uaccess.h> #include <asm/hardirq.h> #include <asm/desc.h> +#include <asm/kdebug.h> extern void die (const char *,struct pt_regs *,long );
@@ -226,6 +227,9 @@ asmlinkage void do_page_fault(struct pt_/* get the address */ __asm__("movl %%cr2,%0" :"=r" (address)); +if (notify_die (DIE_PAGE_FAULT ,"page fault" , regs, error_code,14 , +SIGSEGV ) ==NOTIFY_OK ) +return ;/* It's safe to allow irq's after cr2 has been saved */ if (regs->eflags & (X86_EFLAGS_IF |VM_MASK ))local_irq_enable ();
include/asm-i386/kdebug.h new file +50 -0
50 lines not on this page · raw message
_