Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _ASM_X86_KPROBES_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _ASM_X86_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 (C) IBM Corporation, 2002, 2004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * See arch/x86/kernel/kprobes.c for x86 kprobes history.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <asm-generic/kprobes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #ifdef CONFIG_KPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <asm/text-patching.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <asm/insn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define  __ARCH_WANT_KPROBES_INSN_SLOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct pt_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) struct kprobe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) typedef u8 kprobe_opcode_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define MAX_STACK_SIZE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define CUR_STACK_SIZE(ADDR) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	(current_top_of_stack() - (unsigned long)(ADDR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define MIN_STACK_SIZE(ADDR)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	(MAX_STACK_SIZE < CUR_STACK_SIZE(ADDR) ?	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	 MAX_STACK_SIZE : CUR_STACK_SIZE(ADDR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define flush_insn_slot(p)	do { } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) /* optinsn template addresses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) extern __visible kprobe_opcode_t optprobe_template_entry[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) extern __visible kprobe_opcode_t optprobe_template_clac[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) extern __visible kprobe_opcode_t optprobe_template_val[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) extern __visible kprobe_opcode_t optprobe_template_call[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) extern __visible kprobe_opcode_t optprobe_template_end[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + DISP32_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define MAX_OPTINSN_SIZE 				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	(((unsigned long)optprobe_template_end -	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	  (unsigned long)optprobe_template_entry) +	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	 MAX_OPTIMIZED_LENGTH + JMP32_INSN_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) extern const int kretprobe_blacklist_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) void arch_remove_kprobe(struct kprobe *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) asmlinkage void kretprobe_trampoline(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) extern void arch_kprobe_override_function(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) /* Architecture specific copy of original instruction*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) struct arch_specific_insn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	/* copy of the original instruction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	kprobe_opcode_t *insn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	 * boostable = false: This instruction type is not boostable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	 * boostable = true: This instruction has been boosted: we have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	 * added a relative jump after the instruction copy in insn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	 * so no single-step and fixup are needed (unless there's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	 * a post_handler).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	bool boostable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	bool if_modifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	/* Number of bytes of text poked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	int tp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) struct arch_optimized_insn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	/* copy of the original instructions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	kprobe_opcode_t copied_insn[DISP32_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	/* detour code buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	kprobe_opcode_t *insn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	/* the size of instructions copied to detour code buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	size_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) /* Return true (!0) if optinsn is prepared for optimization. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) static inline int arch_prepared_optinsn(struct arch_optimized_insn *optinsn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return optinsn->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) struct prev_kprobe {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct kprobe *kp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	unsigned long status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	unsigned long old_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	unsigned long saved_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) /* per-cpu kprobe control block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) struct kprobe_ctlblk {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	unsigned long kprobe_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	unsigned long kprobe_old_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	unsigned long kprobe_saved_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct prev_kprobe prev_kprobe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) extern int kprobe_exceptions_notify(struct notifier_block *self,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 				    unsigned long val, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) extern int kprobe_int3_handler(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) extern int kprobe_debug_handler(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static inline int kprobe_debug_handler(struct pt_regs *regs) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #endif /* CONFIG_KPROBES */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #endif /* _ASM_X86_KPROBES_H */