^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __ASM_SH_KPROBES_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __ASM_SH_KPROBES_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <asm-generic/kprobes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define BREAKPOINT_INSTRUCTION 0xc33a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifdef CONFIG_KPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) typedef insn_size_t kprobe_opcode_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define MAX_INSN_SIZE 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define MAX_STACK_SIZE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) ? (MAX_STACK_SIZE) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define flush_insn_slot(p) do { } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define kretprobe_blacklist_size 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct kprobe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) void arch_remove_kprobe(struct kprobe *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) void kretprobe_trampoline(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /* Architecture specific copy of original instruction*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct arch_specific_insn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* copy of the original instruction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) kprobe_opcode_t insn[MAX_INSN_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct prev_kprobe {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct kprobe *kp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) unsigned long status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* per-cpu kprobe control block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct kprobe_ctlblk {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned long kprobe_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct prev_kprobe prev_kprobe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) extern int kprobe_exceptions_notify(struct notifier_block *self,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned long val, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extern int kprobe_handle_illslot(unsigned long pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define kprobe_handle_illslot(pc) (-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #endif /* CONFIG_KPROBES */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #endif /* __ASM_SH_KPROBES_H */