[Fault-injection-developer] [PATCH 2/4] basic FITH patch against 2.5.47 + kprobes
Status: Alpha
Brought to you by:
rustyl
From: Zhuang, L. <lou...@in...> - 2002-11-25 10:11:06
|
Here are basic FITH patch to places several hooks in kernel. diff -Nur -X dontdiff linux-2.5-kp/linux-2.5.47/Makefile linux-2.5-kp-fi/linux-2.5.47/Makefile --- linux-2.5-kp/linux-2.5.47/Makefile Mon Nov 25 15:12:15 2002 +++ linux-2.5-kp-fi/linux-2.5.47/Makefile Mon Nov 25 15:15:38 2002 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 5 SUBLEVEL = 47 -EXTRAVERSION = +EXTRAVERSION =kp-fi # *DOCUMENTATION* # To see a list of typical targets execute "make help" diff -Nur -X dontdiff linux-2.5-kp/linux-2.5.47/arch/i386/Kconfig linux-2.5-kp-fi/linux-2.5.47/arch/i386/Kconfig --- linux-2.5-kp/linux-2.5.47/arch/i386/Kconfig Mon Nov 25 15:12:19 2002 +++ linux-2.5-kp-fi/linux-2.5.47/arch/i386/Kconfig Mon Nov 25 15:15:40 2002 @@ -1562,11 +1562,20 @@ config DEBUGREG bool "Global Debug Registers" - depend on DEBUG_KERNEL + depends on DEBUG_KERNEL + help config KWATCH bool "Kwatch points" - depend on DEBUGREG + depends on DEBUGREG + help + +config FI + bool "Fault Injection" + depends on KPROBES + help + Say Y here if you want to enable Fault Injection (FI) mechanism. + The FI can monitor MMIO/IO access in kernel. config DEBUG_STACKOVERFLOW bool "Check for stack overflows" diff -Nur -X dontdiff linux-2.5-kp/linux-2.5.47/arch/i386/kernel/i386_ksyms. c linux-2.5-kp-fi/linux-2.5.47/arch/i386/kernel/i386_ksyms.c --- linux-2.5-kp/linux-2.5.47/arch/i386/kernel/i386_ksyms.c Mon Nov 25 15:12:19 2002 +++ linux-2.5-kp-fi/linux-2.5.47/arch/i386/kernel/i386_ksyms.c Mon Nov 25 15:15:40 2002 @@ -32,6 +32,7 @@ #include <asm/tlbflush.h> #include <asm/nmi.h> #include <asm/edd.h> +#include <asm/fi.h> extern void dump_thread(struct pt_regs *, struct user *); extern spinlock_t rtc_lock; @@ -216,3 +217,9 @@ EXPORT_SYMBOL(edd); EXPORT_SYMBOL(eddnr); #endif + +#ifdef CONFIG_FI +EXPORT_SYMBOL(irq_desc); +EXPORT_SYMBOL(fi_page_fault); +EXPORT_SYMBOL(fi_post_page_fault); +#endif diff -Nur -X dontdiff linux-2.5-kp/linux-2.5.47/arch/i386/kernel/traps.c linux-2.5-kp-fi/linux-2.5.47/arch/i386/kernel/traps.c --- linux-2.5-kp/linux-2.5.47/arch/i386/kernel/traps.c Mon Nov 25 15:12:19 2002 +++ linux-2.5-kp-fi/linux-2.5.47/arch/i386/kernel/traps.c Mon Nov 25 15:15:41 2002 @@ -47,6 +47,7 @@ #include <asm/smp.h> #include <asm/pgalloc.h> #include <asm/arch_hooks.h> +#include <asm/fi.h> #include <linux/irq.h> #include <linux/module.h> @@ -564,6 +565,9 @@ return 0; } +int (*fi_post_page_fault) (unsigned long condition, + struct pt_regs *reg); + /* * Our handling of the processor debug registers is non-trivial. * We do not clear them on entry and exit from the kernel. Therefore @@ -599,7 +603,10 @@ if (kwatch_handler(condition, regs)) return 1; - +#ifdef CONFIG_FI + if (fi_post_page_fault && fi_post_page_fault(condition, regs)) + return 1; +#endif /* Interrupts not disabled for normal trap handling. */ restore_interrupts(regs); diff -Nur -X dontdiff linux-2.5-kp/linux-2.5.47/arch/i386/mm/fault.c linux-2.5-kp-fi/linux-2.5.47/arch/i386/mm/fault.c --- linux-2.5-kp/linux-2.5.47/arch/i386/mm/fault.c Mon Nov 25 15:12:20 2002 +++ linux-2.5-kp-fi/linux-2.5.47/arch/i386/mm/fault.c Mon Nov 25 15:15:41 2002 @@ -26,6 +26,7 @@ #include <asm/pgalloc.h> #include <asm/hardirq.h> #include <asm/desc.h> +#include <asm/fi.h> extern void die(const char *,struct pt_regs *,long); @@ -139,6 +140,7 @@ } asmlinkage void do_invalid_op(struct pt_regs *, unsigned long); +int (*fi_page_fault) ( struct pt_regs *regs, unsigned long address); /* * This routine handles page faults. It determines the address, @@ -166,7 +168,10 @@ if (kprobe_running() && kprobe_fault_handler(regs, 14)) return; - +#ifdef CONFIG_FI + if (fi_page_fault && fi_page_fault(regs, address)) + return; +#endif /* It's safe to allow irq's after cr2 has been saved */ if (regs->eflags & X86_EFLAGS_IF) local_irq_enable(); diff -Nur -X dontdiff linux-2.5-kp/linux-2.5.47/include/asm-i386/fi.h linux-2.5-kp-fi/linux-2.5.47/include/asm-i386/fi.h --- linux-2.5-kp/linux-2.5.47/include/asm-i386/fi.h Thu Jan 1 08:00:00 1970 +++ linux-2.5-kp-fi/linux-2.5.47/include/asm-i386/fi.h Mon Nov 25 15:16:18 2002 @@ -0,0 +1,8 @@ +#ifndef _ASM_FI_H +#define _ASM_FI_H +#ifdef CONFIG_FI +extern int (*fi_page_fault) ( struct pt_regs *regs, unsigned long address); +extern int (*fi_post_page_fault) (unsigned long condition, + struct pt_regs *reg); +#endif +#endif /* _ASM_FI_H */ diff -Nur -X dontdiff linux-2.5-kp/linux-2.5.47/kernel/ksyms.c linux-2.5-kp-fi/linux-2.5.47/kernel/ksyms.c --- linux-2.5-kp/linux-2.5.47/kernel/ksyms.c Mon Nov 25 15:13:04 2002 +++ linux-2.5-kp-fi/linux-2.5.47/kernel/ksyms.c Mon Nov 25 15:16:27 2002 @@ -601,3 +601,7 @@ /* debug */ EXPORT_SYMBOL(dump_stack); + +#ifdef CONFIG_FI +EXPORT_SYMBOL(module_list); +#endif |