xref: /openbmc/linux/arch/mips/include/asm/uprobes.h (revision 40e084a5)
140e084a5SRalf Baechle /*
240e084a5SRalf Baechle  * This file is subject to the terms and conditions of the GNU General Public
340e084a5SRalf Baechle  * License.  See the file "COPYING" in the main directory of this archive
440e084a5SRalf Baechle  * for more details.
540e084a5SRalf Baechle  */
640e084a5SRalf Baechle #ifndef __ASM_UPROBES_H
740e084a5SRalf Baechle #define __ASM_UPROBES_H
840e084a5SRalf Baechle 
940e084a5SRalf Baechle #include <linux/notifier.h>
1040e084a5SRalf Baechle #include <linux/types.h>
1140e084a5SRalf Baechle 
1240e084a5SRalf Baechle #include <asm/break.h>
1340e084a5SRalf Baechle #include <asm/inst.h>
1440e084a5SRalf Baechle 
1540e084a5SRalf Baechle /*
1640e084a5SRalf Baechle  * We want this to be defined as union mips_instruction but that makes the
1740e084a5SRalf Baechle  * generic code blow up.
1840e084a5SRalf Baechle  */
1940e084a5SRalf Baechle typedef u32 uprobe_opcode_t;
2040e084a5SRalf Baechle 
2140e084a5SRalf Baechle /*
2240e084a5SRalf Baechle  * Classic MIPS (note this implementation doesn't consider microMIPS yet)
2340e084a5SRalf Baechle  * instructions are always 4 bytes but in order to deal with branches and
2440e084a5SRalf Baechle  * their delay slots, we treat instructions as having 8 bytes maximum.
2540e084a5SRalf Baechle  */
2640e084a5SRalf Baechle #define MAX_UINSN_BYTES			8
2740e084a5SRalf Baechle #define UPROBE_XOL_SLOT_BYTES		128	/* Max. cache line size */
2840e084a5SRalf Baechle 
2940e084a5SRalf Baechle #define UPROBE_BRK_UPROBE		0x000d000d	/* break 13 */
3040e084a5SRalf Baechle #define UPROBE_BRK_UPROBE_XOL		0x000e000d	/* break 14 */
3140e084a5SRalf Baechle 
3240e084a5SRalf Baechle #define UPROBE_SWBP_INSN		UPROBE_BRK_UPROBE
3340e084a5SRalf Baechle #define UPROBE_SWBP_INSN_SIZE		4
3440e084a5SRalf Baechle 
3540e084a5SRalf Baechle struct arch_uprobe {
3640e084a5SRalf Baechle 	unsigned long	resume_epc;
3740e084a5SRalf Baechle 	u32	insn[2];
3840e084a5SRalf Baechle 	u32	ixol[2];
3940e084a5SRalf Baechle 	union	mips_instruction orig_inst[MAX_UINSN_BYTES / 4];
4040e084a5SRalf Baechle };
4140e084a5SRalf Baechle 
4240e084a5SRalf Baechle struct arch_uprobe_task {
4340e084a5SRalf Baechle 	unsigned long saved_trap_nr;
4440e084a5SRalf Baechle };
4540e084a5SRalf Baechle 
4640e084a5SRalf Baechle extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup,
4740e084a5SRalf Baechle 	struct mm_struct *mm, unsigned long addr);
4840e084a5SRalf Baechle extern int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs);
4940e084a5SRalf Baechle extern int arch_uprobe_post_xol(struct arch_uprobe *aup, struct pt_regs *regs);
5040e084a5SRalf Baechle extern bool arch_uprobe_xol_was_trapped(struct task_struct *tsk);
5140e084a5SRalf Baechle extern int arch_uprobe_exception_notify(struct notifier_block *self,
5240e084a5SRalf Baechle 	unsigned long val, void *data);
5340e084a5SRalf Baechle extern void arch_uprobe_abort_xol(struct arch_uprobe *aup,
5440e084a5SRalf Baechle 	struct pt_regs *regs);
5540e084a5SRalf Baechle extern unsigned long arch_uretprobe_hijack_return_addr(
5640e084a5SRalf Baechle 	unsigned long trampoline_vaddr, struct pt_regs *regs);
5740e084a5SRalf Baechle 
5840e084a5SRalf Baechle #endif /* __ASM_UPROBES_H */
59