diff options
author | Jim Keniston <jkenisto@us.ibm.com> | 2008-11-03 14:47:12 -0800 |
---|---|---|
committer | Jim Keniston <jkenisto@us.ibm.com> | 2008-11-03 14:47:12 -0800 |
commit | 904b272c43bf358300719d01836bcd10c04aa356 (patch) | |
tree | c6fdb97c5643780ad37001a421080ff30ec76a5b /runtime/uprobes2/uprobes_x86.h | |
parent | b8aa3fa820c059f0f8abb4025f464d90d1f9cb9e (diff) | |
download | systemtap-steved-904b272c43bf358300719d01836bcd10c04aa356.tar.gz systemtap-steved-904b272c43bf358300719d01836bcd10c04aa356.tar.xz systemtap-steved-904b272c43bf358300719d01836bcd10c04aa356.zip |
Add a version of uprobes that works with the 2.6.27 version of utrace.
Diffstat (limited to 'runtime/uprobes2/uprobes_x86.h')
-rw-r--r-- | runtime/uprobes2/uprobes_x86.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/runtime/uprobes2/uprobes_x86.h b/runtime/uprobes2/uprobes_x86.h new file mode 100644 index 00000000..ca3f4873 --- /dev/null +++ b/runtime/uprobes2/uprobes_x86.h @@ -0,0 +1,107 @@ +#ifndef _ASM_UPROBES_H +#define _ASM_UPROBES_H +/* + * Userspace Probes (UProbes) + * uprobes.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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright (C) IBM Corporation, 2008 + */ +#include <linux/types.h> +#include <linux/ptrace.h> +#include <linux/sched.h> +#include <asm/thread_info.h> + +/* Normally defined in Kconfig */ +#define CONFIG_URETPROBES 1 +#define CONFIG_UPROBES_SSOL 1 + +typedef u8 uprobe_opcode_t; +#define BREAKPOINT_INSTRUCTION 0xcc +#define BP_INSN_SIZE 1 +#define MAX_UINSN_BYTES 16 + +// SLOT_IP should be 16 for 64-bit apps (include/asm-x86_64/elf.h) +// but 12 for 32-bit apps (arch/x86_64/ia32/ia32_binfmt.c) +#ifdef CONFIG_X86_32 +#define SLOT_IP(tsk) 12 +#else +#define SLOT_IP(tsk) (test_tsk_thread_flag(tsk, TIF_IA32) ? 12 : 16) +#endif + +#define BREAKPOINT_SIGNAL SIGTRAP +#define SSTEP_SIGNAL SIGTRAP + +/* Architecture specific switch for where the IP points after a bp hit */ +#define ARCH_BP_INST_PTR(inst_ptr) (inst_ptr - BP_INSN_SIZE) + +#define UPFIX_RIP_RAX 0x1 /* (%rip) insn rewritten to use (%rax) */ +#define UPFIX_RIP_RCX 0x2 /* (%rip) insn rewritten to use (%rcx) */ + +#ifdef CONFIG_X86_64 +struct uprobe_probept_arch_info { + unsigned long flags; + unsigned long rip_target_address; +}; + +struct uprobe_task_arch_info { + unsigned long saved_scratch_register; +}; +#else +struct uprobe_probept_arch_info {}; +struct uprobe_task_arch_info {}; +#endif + +struct uprobe_probept; +struct uprobe_task; + +static int arch_validate_probed_insn(struct uprobe_probept *ppt, + struct task_struct *tsk); + +/* On x86, the int3 traps leaves ip pointing past the int3 instruction. */ +static inline unsigned long arch_get_probept(struct pt_regs *regs) +{ + return (unsigned long) (regs->ip - BP_INSN_SIZE); +} + +static inline void arch_reset_ip_for_sstep(struct pt_regs *regs) +{ + regs->ip -= BP_INSN_SIZE; +} + +static inline void arch_restore_uret_addr(unsigned long ret_addr, + struct pt_regs *regs) +{ + regs->ip = ret_addr; +} + +static inline unsigned long arch_get_cur_sp(struct pt_regs *regs) +{ + return (unsigned long) regs->sp; +} + +static inline unsigned long arch_predict_sp_at_ret(struct pt_regs *regs, + struct task_struct *tsk) +{ + if (test_tsk_thread_flag(tsk, TIF_IA32)) + return (unsigned long) (regs->sp + 4); + else + return (unsigned long) (regs->sp + 8); +} + +static unsigned long arch_hijack_uret_addr(unsigned long trampoline_addr, + struct pt_regs*, struct uprobe_task*); +#endif /* _ASM_UPROBES_H */ |