2 * @file uprobe/arch/asm-x86/swap_uprobes.h
3 * @author Alexey Gerenkov <a.gerenkov@samsung.com> User-Space Probes initial
4 * implementation; Support x86/ARM/MIPS for both user and kernel spaces.
5 * @author Ekaterina Gorelkina <e.gorelkina@samsung.com>: redesign module for
6 * separating core and arch parts
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * Copyright (C) Samsung Electronics, 2006-2010
28 * @section DESCRIPTION
30 * Arch-dependent uprobe interface declaration.
33 #ifndef _X86_SWAP_UPROBES_H
34 #define _X86_SWAP_UPROBES_H
39 struct uretprobe_instance;
42 * @struct arch_specific_tramp
43 * @brief Stores x86 trampoline
45 struct arch_specific_tramp {
46 u8 tramp[UPROBES_TRAMP_LEN + BP_INSN_SIZE]; /**< BP for uretprobe */
50 static inline u32 swap_get_urp_float(struct pt_regs *regs)
54 asm volatile ("fstps %0" : "=m" (st0));
59 static inline u64 swap_get_urp_double(struct pt_regs *regs)
63 asm volatile ("fstpl %0" : "=m" (st1));
68 static inline void arch_ujprobe_return(void)
72 int arch_prepare_uprobe(struct uprobe *up);
73 int setjmp_upre_handler(struct kprobe *p, struct pt_regs *regs);
74 static inline int longjmp_break_uhandler(struct kprobe *p, struct pt_regs *regs)
79 static inline int arch_opcode_analysis_uretprobe(struct uretprobe *rp)
84 void arch_prepare_uretprobe(struct uretprobe_instance *ri, struct pt_regs *regs);
85 int arch_disarm_urp_inst(struct uretprobe_instance *ri,
86 struct task_struct *task);
87 unsigned long arch_get_trampoline_addr(struct kprobe *p, struct pt_regs *regs);
88 void arch_set_orig_ret_addr(unsigned long orig_ret_addr, struct pt_regs *regs);
89 void arch_remove_uprobe(struct uprobe *up);
91 static inline unsigned long swap_get_uarg(struct pt_regs *regs, unsigned long n)
95 /* 1 - return address saved on top of the stack */
96 ptr = (u32 *)regs->sp + n + 1;
97 if (get_user(addr, ptr))
98 printk("failed to dereference a pointer, ptr=%p\n", ptr);
103 int swap_arch_init_uprobes(void);
104 void swap_arch_exit_uprobes(void);
106 #endif /* _X86_SWAP_UPROBES_H */