18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __ASM_SH_KPROBES_H
38c2ecf20Sopenharmony_ci#define __ASM_SH_KPROBES_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm-generic/kprobes.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#define BREAKPOINT_INSTRUCTION	0xc33a
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifdef CONFIG_KPROBES
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci#include <linux/ptrace.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_citypedef insn_size_t kprobe_opcode_t;
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define MAX_INSN_SIZE 16
178c2ecf20Sopenharmony_ci#define MAX_STACK_SIZE 64
188c2ecf20Sopenharmony_ci#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
198c2ecf20Sopenharmony_ci	(((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \
208c2ecf20Sopenharmony_ci	? (MAX_STACK_SIZE) \
218c2ecf20Sopenharmony_ci	: (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define flush_insn_slot(p)		do { } while (0)
248c2ecf20Sopenharmony_ci#define kretprobe_blacklist_size	0
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistruct kprobe;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_civoid arch_remove_kprobe(struct kprobe *);
298c2ecf20Sopenharmony_civoid kretprobe_trampoline(void);
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/* Architecture specific copy of original instruction*/
328c2ecf20Sopenharmony_cistruct arch_specific_insn {
338c2ecf20Sopenharmony_ci	/* copy of the original instruction */
348c2ecf20Sopenharmony_ci	kprobe_opcode_t insn[MAX_INSN_SIZE];
358c2ecf20Sopenharmony_ci};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cistruct prev_kprobe {
388c2ecf20Sopenharmony_ci	struct kprobe *kp;
398c2ecf20Sopenharmony_ci	unsigned long status;
408c2ecf20Sopenharmony_ci};
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/* per-cpu kprobe control block */
438c2ecf20Sopenharmony_cistruct kprobe_ctlblk {
448c2ecf20Sopenharmony_ci	unsigned long kprobe_status;
458c2ecf20Sopenharmony_ci	struct prev_kprobe prev_kprobe;
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciextern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
498c2ecf20Sopenharmony_ciextern int kprobe_exceptions_notify(struct notifier_block *self,
508c2ecf20Sopenharmony_ci				    unsigned long val, void *data);
518c2ecf20Sopenharmony_ciextern int kprobe_handle_illslot(unsigned long pc);
528c2ecf20Sopenharmony_ci#else
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define kprobe_handle_illslot(pc)	(-1)
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#endif /* CONFIG_KPROBES */
578c2ecf20Sopenharmony_ci#endif /* __ASM_SH_KPROBES_H */
58