1c1bf207dSDavid Daney /* 2c1bf207dSDavid Daney * Kernel Probes (KProbes) 3c1bf207dSDavid Daney * include/asm-mips/kprobes.h 4c1bf207dSDavid Daney * 5c1bf207dSDavid Daney * Copyright 2006 Sony Corp. 6c1bf207dSDavid Daney * Copyright 2010 Cavium Networks 7c1bf207dSDavid Daney * 8c1bf207dSDavid Daney * This program is free software; you can redistribute it and/or modify 9c1bf207dSDavid Daney * it under the terms of the GNU General Public License as published by 10c1bf207dSDavid Daney * the Free Software Foundation; version 2 of the License. 11c1bf207dSDavid Daney * 12c1bf207dSDavid Daney * This program is distributed in the hope that it will be useful, 13c1bf207dSDavid Daney * but WITHOUT ANY WARRANTY; without even the implied warranty of 14c1bf207dSDavid Daney * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15c1bf207dSDavid Daney * GNU General Public License for more details. 16c1bf207dSDavid Daney * 17c1bf207dSDavid Daney * You should have received a copy of the GNU General Public License 18c1bf207dSDavid Daney * along with this program; if not, write to the Free Software 19c1bf207dSDavid Daney * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20c1bf207dSDavid Daney */ 21c1bf207dSDavid Daney 22c1bf207dSDavid Daney #ifndef _ASM_KPROBES_H 23c1bf207dSDavid Daney #define _ASM_KPROBES_H 24c1bf207dSDavid Daney 25c1bf207dSDavid Daney #include <linux/ptrace.h> 26c1bf207dSDavid Daney #include <linux/types.h> 27c1bf207dSDavid Daney 28c1bf207dSDavid Daney #include <asm/cacheflush.h> 29c1bf207dSDavid Daney #include <asm/kdebug.h> 30c1bf207dSDavid Daney #include <asm/inst.h> 31c1bf207dSDavid Daney 32c1bf207dSDavid Daney #define __ARCH_WANT_KPROBES_INSN_SLOT 33c1bf207dSDavid Daney 34c1bf207dSDavid Daney struct kprobe; 35c1bf207dSDavid Daney struct pt_regs; 36c1bf207dSDavid Daney 37c1bf207dSDavid Daney typedef union mips_instruction kprobe_opcode_t; 38c1bf207dSDavid Daney 39c1bf207dSDavid Daney #define MAX_INSN_SIZE 2 40c1bf207dSDavid Daney 41c1bf207dSDavid Daney #define flush_insn_slot(p) \ 42c1bf207dSDavid Daney do { \ 43c1bf207dSDavid Daney flush_icache_range((unsigned long)p->addr, \ 44c1bf207dSDavid Daney (unsigned long)p->addr + \ 45c1bf207dSDavid Daney (MAX_INSN_SIZE * sizeof(kprobe_opcode_t))); \ 46c1bf207dSDavid Daney } while (0) 47c1bf207dSDavid Daney 48c1bf207dSDavid Daney 49c1bf207dSDavid Daney #define kretprobe_blacklist_size 0 50c1bf207dSDavid Daney 51c1bf207dSDavid Daney void arch_remove_kprobe(struct kprobe *p); 52c1bf207dSDavid Daney 53c1bf207dSDavid Daney /* Architecture specific copy of original instruction*/ 54c1bf207dSDavid Daney struct arch_specific_insn { 55c1bf207dSDavid Daney /* copy of the original instruction */ 56c1bf207dSDavid Daney kprobe_opcode_t *insn; 57c1bf207dSDavid Daney }; 58c1bf207dSDavid Daney 59c1bf207dSDavid Daney struct prev_kprobe { 60c1bf207dSDavid Daney struct kprobe *kp; 61c1bf207dSDavid Daney unsigned long status; 62c1bf207dSDavid Daney unsigned long old_SR; 63c1bf207dSDavid Daney unsigned long saved_SR; 64c1bf207dSDavid Daney unsigned long saved_epc; 65c1bf207dSDavid Daney }; 66c1bf207dSDavid Daney 67c1bf207dSDavid Daney #define MAX_JPROBES_STACK_SIZE 128 68c1bf207dSDavid Daney #define MAX_JPROBES_STACK_ADDR \ 69c1bf207dSDavid Daney (((unsigned long)current_thread_info()) + THREAD_SIZE - 32 - sizeof(struct pt_regs)) 70c1bf207dSDavid Daney 71c1bf207dSDavid Daney #define MIN_JPROBES_STACK_SIZE(ADDR) \ 72c1bf207dSDavid Daney ((((ADDR) + MAX_JPROBES_STACK_SIZE) > MAX_JPROBES_STACK_ADDR) \ 73c1bf207dSDavid Daney ? MAX_JPROBES_STACK_ADDR - (ADDR) \ 74c1bf207dSDavid Daney : MAX_JPROBES_STACK_SIZE) 75c1bf207dSDavid Daney 76c1bf207dSDavid Daney 77*6457a396SManeesh Soni #define SKIP_DELAYSLOT 0x0001 78*6457a396SManeesh Soni 79c1bf207dSDavid Daney /* per-cpu kprobe control block */ 80c1bf207dSDavid Daney struct kprobe_ctlblk { 81c1bf207dSDavid Daney unsigned long kprobe_status; 82c1bf207dSDavid Daney unsigned long kprobe_old_SR; 83c1bf207dSDavid Daney unsigned long kprobe_saved_SR; 84c1bf207dSDavid Daney unsigned long kprobe_saved_epc; 85c1bf207dSDavid Daney unsigned long jprobe_saved_sp; 86c1bf207dSDavid Daney struct pt_regs jprobe_saved_regs; 87*6457a396SManeesh Soni /* Per-thread fields, used while emulating branches */ 88*6457a396SManeesh Soni unsigned long flags; 89*6457a396SManeesh Soni unsigned long target_epc; 90c1bf207dSDavid Daney u8 jprobes_stack[MAX_JPROBES_STACK_SIZE]; 91c1bf207dSDavid Daney struct prev_kprobe prev_kprobe; 92c1bf207dSDavid Daney }; 93c1bf207dSDavid Daney 94c1bf207dSDavid Daney extern int kprobe_exceptions_notify(struct notifier_block *self, 95c1bf207dSDavid Daney unsigned long val, void *data); 96c1bf207dSDavid Daney 97c1bf207dSDavid Daney #endif /* _ASM_KPROBES_H */ 98