Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef _ASM_POWERPC_KPROBES_H
0003 #define _ASM_POWERPC_KPROBES_H
0004 
0005 #include <asm-generic/kprobes.h>
0006 
0007 #ifdef __KERNEL__
0008 /*
0009  *  Kernel Probes (KProbes)
0010  *
0011  * Copyright (C) IBM Corporation, 2002, 2004
0012  *
0013  * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
0014  *      Probes initial implementation ( includes suggestions from
0015  *      Rusty Russell).
0016  * 2004-Nov Modified for PPC64 by Ananth N Mavinakayanahalli
0017  *      <ananth@in.ibm.com>
0018  */
0019 #include <linux/types.h>
0020 #include <linux/ptrace.h>
0021 #include <linux/percpu.h>
0022 #include <linux/module.h>
0023 #include <asm/probes.h>
0024 #include <asm/code-patching.h>
0025 
0026 #ifdef CONFIG_KPROBES
0027 #define  __ARCH_WANT_KPROBES_INSN_SLOT
0028 
0029 struct pt_regs;
0030 struct kprobe;
0031 
0032 typedef u32 kprobe_opcode_t;
0033 
0034 extern kprobe_opcode_t optinsn_slot;
0035 
0036 /* Optinsn template address */
0037 extern kprobe_opcode_t optprobe_template_entry[];
0038 extern kprobe_opcode_t optprobe_template_op_address[];
0039 extern kprobe_opcode_t optprobe_template_call_handler[];
0040 extern kprobe_opcode_t optprobe_template_insn[];
0041 extern kprobe_opcode_t optprobe_template_call_emulate[];
0042 extern kprobe_opcode_t optprobe_template_ret[];
0043 extern kprobe_opcode_t optprobe_template_end[];
0044 
0045 /* Fixed instruction size for powerpc */
0046 #define MAX_INSN_SIZE       2
0047 #define MAX_OPTIMIZED_LENGTH    sizeof(kprobe_opcode_t) /* 4 bytes */
0048 #define MAX_OPTINSN_SIZE    (optprobe_template_end - optprobe_template_entry)
0049 #define RELATIVEJUMP_SIZE   sizeof(kprobe_opcode_t) /* 4 bytes */
0050 
0051 #define flush_insn_slot(p)  do { } while (0)
0052 #define kretprobe_blacklist_size 0
0053 
0054 void __kretprobe_trampoline(void);
0055 extern void arch_remove_kprobe(struct kprobe *p);
0056 
0057 /* Architecture specific copy of original instruction */
0058 struct arch_specific_insn {
0059     /* copy of original instruction */
0060     kprobe_opcode_t *insn;
0061     /*
0062      * Set in kprobes code, initially to 0. If the instruction can be
0063      * eumulated, this is set to 1, if not, to -1.
0064      */
0065     int boostable;
0066 };
0067 
0068 struct prev_kprobe {
0069     struct kprobe *kp;
0070     unsigned long status;
0071     unsigned long saved_msr;
0072 };
0073 
0074 /* per-cpu kprobe control block */
0075 struct kprobe_ctlblk {
0076     unsigned long kprobe_status;
0077     unsigned long kprobe_saved_msr;
0078     struct prev_kprobe prev_kprobe;
0079 };
0080 
0081 struct arch_optimized_insn {
0082     kprobe_opcode_t copied_insn[1];
0083     /* detour buffer */
0084     kprobe_opcode_t *insn;
0085 };
0086 
0087 extern int kprobe_exceptions_notify(struct notifier_block *self,
0088                     unsigned long val, void *data);
0089 extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
0090 extern int kprobe_handler(struct pt_regs *regs);
0091 extern int kprobe_post_handler(struct pt_regs *regs);
0092 #else
0093 static inline int kprobe_handler(struct pt_regs *regs) { return 0; }
0094 static inline int kprobe_post_handler(struct pt_regs *regs) { return 0; }
0095 #endif /* CONFIG_KPROBES */
0096 #endif /* __KERNEL__ */
0097 #endif  /* _ASM_POWERPC_KPROBES_H */