aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2008-01-30 07:31:21 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:21 -0500
commit8533bbe9f87b01f49ff951f665ea1988252fa3c2 (patch)
tree5286298af37057c1086405a96e6dce0b0df1fb64 /include/asm-x86
parentda07ab0375897bb9e108b28129df140ecd3ee94e (diff)
x86: prepare kprobes code for x86 unification
This patch cleanup kprobes code on x86 for unification. This patch is based on Arjan's previous work. - Remove spurious whitespace changes - Add harmless includes - Make the 32/64 files more identical - Generalize structure fields' and local variable name. - Wrap accessing to stack address by macros. - Modify bitmap making macro. - Merge fixup code into is_riprel() and change its name to fix_riprel(). - Set MAX_INSN_SIZE to 16 on both arch. - Use u32 for bitmaps on both architectures. - Clarify some comments. Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Jim Keniston <jkenisto@us.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/asm-x86')
-rw-r--r--include/asm-x86/kprobes_32.h32
-rw-r--r--include/asm-x86/kprobes_64.h30
2 files changed, 36 insertions, 26 deletions
diff --git a/include/asm-x86/kprobes_32.h b/include/asm-x86/kprobes_32.h
index 2f38315bc39f..94dff09b2ebe 100644
--- a/include/asm-x86/kprobes_32.h
+++ b/include/asm-x86/kprobes_32.h
@@ -2,7 +2,6 @@
2#define _ASM_KPROBES_H 2#define _ASM_KPROBES_H
3/* 3/*
4 * Kernel Probes (KProbes) 4 * Kernel Probes (KProbes)
5 * include/asm-i386/kprobes.h
6 * 5 *
7 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -23,14 +22,17 @@
23 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel 22 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
24 * Probes initial implementation ( includes suggestions from 23 * Probes initial implementation ( includes suggestions from
25 * Rusty Russell). 24 * Rusty Russell).
25 * 2004-Oct Prasanna S Panchamukhi <prasanna@in.ibm.com> and Jim Keniston
26 * kenistoj@us.ibm.com adopted from i386.
26 */ 27 */
27#include <linux/types.h> 28#include <linux/types.h>
28#include <linux/ptrace.h> 29#include <linux/ptrace.h>
30#include <linux/percpu.h>
29 31
30#define __ARCH_WANT_KPROBES_INSN_SLOT 32#define __ARCH_WANT_KPROBES_INSN_SLOT
31 33
32struct kprobe;
33struct pt_regs; 34struct pt_regs;
35struct kprobe;
34 36
35typedef u8 kprobe_opcode_t; 37typedef u8 kprobe_opcode_t;
36#define BREAKPOINT_INSTRUCTION 0xcc 38#define BREAKPOINT_INSTRUCTION 0xcc
@@ -38,9 +40,11 @@ typedef u8 kprobe_opcode_t;
38#define MAX_INSN_SIZE 16 40#define MAX_INSN_SIZE 16
39#define MAX_STACK_SIZE 64 41#define MAX_STACK_SIZE 64
40#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \ 42#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
41 (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \ 43 (((unsigned long)current_thread_info()) + THREAD_SIZE \
44 - (unsigned long)(ADDR))) \
42 ? (MAX_STACK_SIZE) \ 45 ? (MAX_STACK_SIZE) \
43 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) 46 : (((unsigned long)current_thread_info()) + THREAD_SIZE \
47 - (unsigned long)(ADDR)))
44 48
45#define ARCH_SUPPORTS_KRETPROBES 49#define ARCH_SUPPORTS_KRETPROBES
46#define flush_insn_slot(p) do { } while (0) 50#define flush_insn_slot(p) do { } while (0)
@@ -55,8 +59,12 @@ struct arch_specific_insn {
55 /* copy of the original instruction */ 59 /* copy of the original instruction */
56 kprobe_opcode_t *insn; 60 kprobe_opcode_t *insn;
57 /* 61 /*
58 * If this flag is not 0, this kprobe can be boost when its 62 * boostable = -1: This instruction type is not boostable.
59 * post_handler and break_handler is not set. 63 * boostable = 0: This instruction type is boostable.
64 * boostable = 1: This instruction has been boosted: we have
65 * added a relative jump after the instruction copy in insn,
66 * so no single-step and fixup are needed (unless there's
67 * a post_handler or break_handler).
60 */ 68 */
61 int boostable; 69 int boostable;
62}; 70};
@@ -64,16 +72,16 @@ struct arch_specific_insn {
64struct prev_kprobe { 72struct prev_kprobe {
65 struct kprobe *kp; 73 struct kprobe *kp;
66 unsigned long status; 74 unsigned long status;
67 unsigned long old_eflags; 75 unsigned long old_flags;
68 unsigned long saved_eflags; 76 unsigned long saved_flags;
69}; 77};
70 78
71/* per-cpu kprobe control block */ 79/* per-cpu kprobe control block */
72struct kprobe_ctlblk { 80struct kprobe_ctlblk {
73 unsigned long kprobe_status; 81 unsigned long kprobe_status;
74 unsigned long kprobe_old_eflags; 82 unsigned long kprobe_old_flags;
75 unsigned long kprobe_saved_eflags; 83 unsigned long kprobe_saved_flags;
76 unsigned long *jprobe_saved_esp; 84 unsigned long *jprobe_saved_sp;
77 struct pt_regs jprobe_saved_regs; 85 struct pt_regs jprobe_saved_regs;
78 kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE]; 86 kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
79 struct prev_kprobe prev_kprobe; 87 struct prev_kprobe prev_kprobe;
@@ -88,7 +96,7 @@ static inline void restore_interrupts(struct pt_regs *regs)
88 local_irq_enable(); 96 local_irq_enable();
89} 97}
90 98
99extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
91extern int kprobe_exceptions_notify(struct notifier_block *self, 100extern int kprobe_exceptions_notify(struct notifier_block *self,
92 unsigned long val, void *data); 101 unsigned long val, void *data);
93extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
94#endif /* _ASM_KPROBES_H */ 102#endif /* _ASM_KPROBES_H */
diff --git a/include/asm-x86/kprobes_64.h b/include/asm-x86/kprobes_64.h
index e7e921dac7c2..94dff09b2ebe 100644
--- a/include/asm-x86/kprobes_64.h
+++ b/include/asm-x86/kprobes_64.h
@@ -2,7 +2,6 @@
2#define _ASM_KPROBES_H 2#define _ASM_KPROBES_H
3/* 3/*
4 * Kernel Probes (KProbes) 4 * Kernel Probes (KProbes)
5 * include/asm-x86_64/kprobes.h
6 * 5 *
7 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -20,6 +19,9 @@
20 * 19 *
21 * Copyright (C) IBM Corporation, 2002, 2004 20 * Copyright (C) IBM Corporation, 2002, 2004
22 * 21 *
22 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
23 * Probes initial implementation ( includes suggestions from
24 * Rusty Russell).
23 * 2004-Oct Prasanna S Panchamukhi <prasanna@in.ibm.com> and Jim Keniston 25 * 2004-Oct Prasanna S Panchamukhi <prasanna@in.ibm.com> and Jim Keniston
24 * kenistoj@us.ibm.com adopted from i386. 26 * kenistoj@us.ibm.com adopted from i386.
25 */ 27 */
@@ -35,19 +37,22 @@ struct kprobe;
35typedef u8 kprobe_opcode_t; 37typedef u8 kprobe_opcode_t;
36#define BREAKPOINT_INSTRUCTION 0xcc 38#define BREAKPOINT_INSTRUCTION 0xcc
37#define RELATIVEJUMP_INSTRUCTION 0xe9 39#define RELATIVEJUMP_INSTRUCTION 0xe9
38#define MAX_INSN_SIZE 15 40#define MAX_INSN_SIZE 16
39#define MAX_STACK_SIZE 64 41#define MAX_STACK_SIZE 64
40#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \ 42#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
41 (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \ 43 (((unsigned long)current_thread_info()) + THREAD_SIZE \
44 - (unsigned long)(ADDR))) \
42 ? (MAX_STACK_SIZE) \ 45 ? (MAX_STACK_SIZE) \
43 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) 46 : (((unsigned long)current_thread_info()) + THREAD_SIZE \
47 - (unsigned long)(ADDR)))
44 48
45#define ARCH_SUPPORTS_KRETPROBES 49#define ARCH_SUPPORTS_KRETPROBES
50#define flush_insn_slot(p) do { } while (0)
51
46extern const int kretprobe_blacklist_size; 52extern const int kretprobe_blacklist_size;
47 53
54void arch_remove_kprobe(struct kprobe *p);
48void kretprobe_trampoline(void); 55void kretprobe_trampoline(void);
49extern void arch_remove_kprobe(struct kprobe *p);
50#define flush_insn_slot(p) do { } while (0)
51 56
52/* Architecture specific copy of original instruction*/ 57/* Architecture specific copy of original instruction*/
53struct arch_specific_insn { 58struct arch_specific_insn {
@@ -67,16 +72,16 @@ struct arch_specific_insn {
67struct prev_kprobe { 72struct prev_kprobe {
68 struct kprobe *kp; 73 struct kprobe *kp;
69 unsigned long status; 74 unsigned long status;
70 unsigned long old_rflags; 75 unsigned long old_flags;
71 unsigned long saved_rflags; 76 unsigned long saved_flags;
72}; 77};
73 78
74/* per-cpu kprobe control block */ 79/* per-cpu kprobe control block */
75struct kprobe_ctlblk { 80struct kprobe_ctlblk {
76 unsigned long kprobe_status; 81 unsigned long kprobe_status;
77 unsigned long kprobe_old_rflags; 82 unsigned long kprobe_old_flags;
78 unsigned long kprobe_saved_rflags; 83 unsigned long kprobe_saved_flags;
79 unsigned long *jprobe_saved_rsp; 84 unsigned long *jprobe_saved_sp;
80 struct pt_regs jprobe_saved_regs; 85 struct pt_regs jprobe_saved_regs;
81 kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE]; 86 kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
82 struct prev_kprobe prev_kprobe; 87 struct prev_kprobe prev_kprobe;
@@ -91,10 +96,7 @@ static inline void restore_interrupts(struct pt_regs *regs)
91 local_irq_enable(); 96 local_irq_enable();
92} 97}
93 98
94extern int post_kprobe_handler(struct pt_regs *regs);
95extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr); 99extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
96extern int kprobe_handler(struct pt_regs *regs);
97
98extern int kprobe_exceptions_notify(struct notifier_block *self, 100extern int kprobe_exceptions_notify(struct notifier_block *self,
99 unsigned long val, void *data); 101 unsigned long val, void *data);
100#endif /* _ASM_KPROBES_H */ 102#endif /* _ASM_KPROBES_H */