Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * arch/arm/include/asm/kprobes.h
0004  *
0005  * Copyright (C) 2006, 2007 Motorola Inc.
0006  */
0007 
0008 #ifndef _ARM_KPROBES_H
0009 #define _ARM_KPROBES_H
0010 
0011 #include <asm-generic/kprobes.h>
0012 
0013 #ifdef CONFIG_KPROBES
0014 #include <linux/types.h>
0015 #include <linux/ptrace.h>
0016 #include <linux/notifier.h>
0017 
0018 #define __ARCH_WANT_KPROBES_INSN_SLOT
0019 #define MAX_INSN_SIZE           2
0020 
0021 #define flush_insn_slot(p)      do { } while (0)
0022 #define kretprobe_blacklist_size    0
0023 
0024 typedef u32 kprobe_opcode_t;
0025 struct kprobe;
0026 #include <asm/probes.h>
0027 
0028 #define arch_specific_insn  arch_probes_insn
0029 
0030 struct prev_kprobe {
0031     struct kprobe *kp;
0032     unsigned int status;
0033 };
0034 
0035 /* per-cpu kprobe control block */
0036 struct kprobe_ctlblk {
0037     unsigned int kprobe_status;
0038     struct prev_kprobe prev_kprobe;
0039 };
0040 
0041 void arch_remove_kprobe(struct kprobe *);
0042 int kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr);
0043 int kprobe_exceptions_notify(struct notifier_block *self,
0044                  unsigned long val, void *data);
0045 
0046 /* optinsn template addresses */
0047 extern __visible kprobe_opcode_t optprobe_template_entry[];
0048 extern __visible kprobe_opcode_t optprobe_template_val[];
0049 extern __visible kprobe_opcode_t optprobe_template_call[];
0050 extern __visible kprobe_opcode_t optprobe_template_end[];
0051 extern __visible kprobe_opcode_t optprobe_template_sub_sp[];
0052 extern __visible kprobe_opcode_t optprobe_template_add_sp[];
0053 extern __visible kprobe_opcode_t optprobe_template_restore_begin[];
0054 extern __visible kprobe_opcode_t optprobe_template_restore_orig_insn[];
0055 extern __visible kprobe_opcode_t optprobe_template_restore_end[];
0056 
0057 #define MAX_OPTIMIZED_LENGTH    4
0058 #define MAX_OPTINSN_SIZE                \
0059     ((unsigned long)optprobe_template_end - \
0060      (unsigned long)optprobe_template_entry)
0061 #define RELATIVEJUMP_SIZE   4
0062 
0063 struct arch_optimized_insn {
0064     /*
0065      * copy of the original instructions.
0066      * Different from x86, ARM kprobe_opcode_t is u32.
0067      */
0068 #define MAX_COPIED_INSN DIV_ROUND_UP(RELATIVEJUMP_SIZE, sizeof(kprobe_opcode_t))
0069     kprobe_opcode_t copied_insn[MAX_COPIED_INSN];
0070     /* detour code buffer */
0071     kprobe_opcode_t *insn;
0072     /*
0073      * We always copy one instruction on ARM,
0074      * so size will always be 4, and unlike x86, there is no
0075      * need for a size field.
0076      */
0077 };
0078 
0079 #endif /* CONFIG_KPROBES */
0080 #endif /* _ARM_KPROBES_H */