^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_S390_KPROBES_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_S390_KPROBES_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Kernel Probes (KProbes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright IBM Corp. 2002, 2006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Probes initial implementation ( includes suggestions from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Rusty Russell).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * 2004-Nov Modified for PPC64 by Ananth N Mavinakayanahalli
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * <ananth@in.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * 2005-Dec Used as a template for s390 by Mike Grundy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * <grundym@us.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm-generic/kprobes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define BREAKPOINT_INSTRUCTION 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define FIXUP_PSW_NORMAL 0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define FIXUP_BRANCH_NOT_TAKEN 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define FIXUP_RETURN_REGISTER 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define FIXUP_NOT_REQUIRED 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int probe_is_prohibited_opcode(u16 *insn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int probe_get_fixup_type(u16 *insn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int probe_is_insn_relative_long(u16 *insn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #ifdef CONFIG_KPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/sched/task_stack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define __ARCH_WANT_KPROBES_INSN_SLOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct pt_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct kprobe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) typedef u16 kprobe_opcode_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* Maximum instruction size is 3 (16bit) halfwords: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define MAX_INSN_SIZE 0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define MAX_STACK_SIZE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) (((unsigned long)task_stack_page(current)) + THREAD_SIZE - (ADDR))) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ? (MAX_STACK_SIZE) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) : (((unsigned long)task_stack_page(current)) + THREAD_SIZE - (ADDR)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define kretprobe_blacklist_size 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* Architecture specific copy of original instruction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct arch_specific_insn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* copy of original instruction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) kprobe_opcode_t *insn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct prev_kprobe {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct kprobe *kp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) unsigned long status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /* per-cpu kprobe control block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct kprobe_ctlblk {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) unsigned long kprobe_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) unsigned long kprobe_saved_imask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) unsigned long kprobe_saved_ctl[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct prev_kprobe prev_kprobe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) void arch_remove_kprobe(struct kprobe *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) void kretprobe_trampoline(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int kprobe_exceptions_notify(struct notifier_block *self,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) unsigned long val, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define flush_insn_slot(p) do { } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #endif /* CONFIG_KPROBES */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #endif /* _ASM_S390_KPROBES_H */