mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
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>
This commit is contained in:
committed by
Ingo Molnar
parent
da07ab0375
commit
8533bbe9f8
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,6 @@
|
||||
#include <linux/kprobes.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/kdebug.h>
|
||||
#include <linux/kprobes.h>
|
||||
|
||||
#include <asm/system.h>
|
||||
#include <asm/desc.h>
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <linux/kprobes.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/kdebug.h>
|
||||
#include <linux/kprobes.h>
|
||||
|
||||
#include <asm/system.h>
|
||||
#include <asm/pgalloc.h>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define _ASM_KPROBES_H
|
||||
/*
|
||||
* Kernel Probes (KProbes)
|
||||
* include/asm-i386/kprobes.h
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,14 +22,17 @@
|
||||
* 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
|
||||
* Probes initial implementation ( includes suggestions from
|
||||
* Rusty Russell).
|
||||
* 2004-Oct Prasanna S Panchamukhi <prasanna@in.ibm.com> and Jim Keniston
|
||||
* kenistoj@us.ibm.com adopted from i386.
|
||||
*/
|
||||
#include <linux/types.h>
|
||||
#include <linux/ptrace.h>
|
||||
#include <linux/percpu.h>
|
||||
|
||||
#define __ARCH_WANT_KPROBES_INSN_SLOT
|
||||
|
||||
struct kprobe;
|
||||
struct pt_regs;
|
||||
struct kprobe;
|
||||
|
||||
typedef u8 kprobe_opcode_t;
|
||||
#define BREAKPOINT_INSTRUCTION 0xcc
|
||||
@@ -38,9 +40,11 @@ typedef u8 kprobe_opcode_t;
|
||||
#define MAX_INSN_SIZE 16
|
||||
#define MAX_STACK_SIZE 64
|
||||
#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
|
||||
(((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \
|
||||
(((unsigned long)current_thread_info()) + THREAD_SIZE \
|
||||
- (unsigned long)(ADDR))) \
|
||||
? (MAX_STACK_SIZE) \
|
||||
: (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
|
||||
: (((unsigned long)current_thread_info()) + THREAD_SIZE \
|
||||
- (unsigned long)(ADDR)))
|
||||
|
||||
#define ARCH_SUPPORTS_KRETPROBES
|
||||
#define flush_insn_slot(p) do { } while (0)
|
||||
@@ -55,8 +59,12 @@ struct arch_specific_insn {
|
||||
/* copy of the original instruction */
|
||||
kprobe_opcode_t *insn;
|
||||
/*
|
||||
* If this flag is not 0, this kprobe can be boost when its
|
||||
* post_handler and break_handler is not set.
|
||||
* boostable = -1: This instruction type is not boostable.
|
||||
* boostable = 0: This instruction type is boostable.
|
||||
* boostable = 1: This instruction has been boosted: we have
|
||||
* added a relative jump after the instruction copy in insn,
|
||||
* so no single-step and fixup are needed (unless there's
|
||||
* a post_handler or break_handler).
|
||||
*/
|
||||
int boostable;
|
||||
};
|
||||
@@ -64,16 +72,16 @@ struct arch_specific_insn {
|
||||
struct prev_kprobe {
|
||||
struct kprobe *kp;
|
||||
unsigned long status;
|
||||
unsigned long old_eflags;
|
||||
unsigned long saved_eflags;
|
||||
unsigned long old_flags;
|
||||
unsigned long saved_flags;
|
||||
};
|
||||
|
||||
/* per-cpu kprobe control block */
|
||||
struct kprobe_ctlblk {
|
||||
unsigned long kprobe_status;
|
||||
unsigned long kprobe_old_eflags;
|
||||
unsigned long kprobe_saved_eflags;
|
||||
unsigned long *jprobe_saved_esp;
|
||||
unsigned long kprobe_old_flags;
|
||||
unsigned long kprobe_saved_flags;
|
||||
unsigned long *jprobe_saved_sp;
|
||||
struct pt_regs jprobe_saved_regs;
|
||||
kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
|
||||
struct prev_kprobe prev_kprobe;
|
||||
@@ -88,7 +96,7 @@ static inline void restore_interrupts(struct pt_regs *regs)
|
||||
local_irq_enable();
|
||||
}
|
||||
|
||||
extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
|
||||
extern int kprobe_exceptions_notify(struct notifier_block *self,
|
||||
unsigned long val, void *data);
|
||||
extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
|
||||
#endif /* _ASM_KPROBES_H */
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define _ASM_KPROBES_H
|
||||
/*
|
||||
* Kernel Probes (KProbes)
|
||||
* include/asm-x86_64/kprobes.h
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,6 +19,9 @@
|
||||
*
|
||||
* Copyright (C) IBM Corporation, 2002, 2004
|
||||
*
|
||||
* 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
|
||||
* Probes initial implementation ( includes suggestions from
|
||||
* Rusty Russell).
|
||||
* 2004-Oct Prasanna S Panchamukhi <prasanna@in.ibm.com> and Jim Keniston
|
||||
* kenistoj@us.ibm.com adopted from i386.
|
||||
*/
|
||||
@@ -35,19 +37,22 @@ struct kprobe;
|
||||
typedef u8 kprobe_opcode_t;
|
||||
#define BREAKPOINT_INSTRUCTION 0xcc
|
||||
#define RELATIVEJUMP_INSTRUCTION 0xe9
|
||||
#define MAX_INSN_SIZE 15
|
||||
#define MAX_INSN_SIZE 16
|
||||
#define MAX_STACK_SIZE 64
|
||||
#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
|
||||
(((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \
|
||||
(((unsigned long)current_thread_info()) + THREAD_SIZE \
|
||||
- (unsigned long)(ADDR))) \
|
||||
? (MAX_STACK_SIZE) \
|
||||
: (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
|
||||
: (((unsigned long)current_thread_info()) + THREAD_SIZE \
|
||||
- (unsigned long)(ADDR)))
|
||||
|
||||
#define ARCH_SUPPORTS_KRETPROBES
|
||||
#define flush_insn_slot(p) do { } while (0)
|
||||
|
||||
extern const int kretprobe_blacklist_size;
|
||||
|
||||
void arch_remove_kprobe(struct kprobe *p);
|
||||
void kretprobe_trampoline(void);
|
||||
extern void arch_remove_kprobe(struct kprobe *p);
|
||||
#define flush_insn_slot(p) do { } while (0)
|
||||
|
||||
/* Architecture specific copy of original instruction*/
|
||||
struct arch_specific_insn {
|
||||
@@ -67,16 +72,16 @@ struct arch_specific_insn {
|
||||
struct prev_kprobe {
|
||||
struct kprobe *kp;
|
||||
unsigned long status;
|
||||
unsigned long old_rflags;
|
||||
unsigned long saved_rflags;
|
||||
unsigned long old_flags;
|
||||
unsigned long saved_flags;
|
||||
};
|
||||
|
||||
/* per-cpu kprobe control block */
|
||||
struct kprobe_ctlblk {
|
||||
unsigned long kprobe_status;
|
||||
unsigned long kprobe_old_rflags;
|
||||
unsigned long kprobe_saved_rflags;
|
||||
unsigned long *jprobe_saved_rsp;
|
||||
unsigned long kprobe_old_flags;
|
||||
unsigned long kprobe_saved_flags;
|
||||
unsigned long *jprobe_saved_sp;
|
||||
struct pt_regs jprobe_saved_regs;
|
||||
kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
|
||||
struct prev_kprobe prev_kprobe;
|
||||
@@ -91,10 +96,7 @@ static inline void restore_interrupts(struct pt_regs *regs)
|
||||
local_irq_enable();
|
||||
}
|
||||
|
||||
extern int post_kprobe_handler(struct pt_regs *regs);
|
||||
extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
|
||||
extern int kprobe_handler(struct pt_regs *regs);
|
||||
|
||||
extern int kprobe_exceptions_notify(struct notifier_block *self,
|
||||
unsigned long val, void *data);
|
||||
#endif /* _ASM_KPROBES_H */
|
||||
|
||||
Reference in New Issue
Block a user