Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: insn: decouple patching from insn code

Currently, <asm/insn.h> includes <asm/patching.h>. We intend that
<asm/insn.h> will be usable from userspace, so it doesn't make sense to
include headers for kernel-only features such as the patching routines,
and we'd intended to restrict <asm/insn.h> to instruction encoding
details.

Let's decouple the patching code from <asm/insn.h>, and explicitly
include <asm/patching.h> where it is needed. Since <asm/patching.h>
isn't included from assembly, we can drop the __ASSEMBLY__ guards.

At the same time, sort the kprobes includes so that it's easier to see
what is and isn't incldued.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20210609102301.17332-2-mark.rutland@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Mark Rutland and committed by
Will Deacon
78b92c73 71766b81

+18 -14
-1
arch/arm64/include/asm/insn.h
··· 11 11 #include <linux/types.h> 12 12 13 13 #include <asm/alternative.h> 14 - #include <asm/patching.h> 15 14 16 15 #ifndef __ASSEMBLY__ 17 16 /*
-2
arch/arm64/include/asm/patching.h
··· 4 4 5 5 #include <linux/types.h> 6 6 7 - #ifndef __ASSEMBLY__ 8 7 int aarch64_insn_read(void *addr, u32 *insnp); 9 8 int aarch64_insn_write(void *addr, u32 insn); 10 9 11 10 int aarch64_insn_patch_text_nosync(void *addr, u32 insn); 12 11 int aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt); 13 - #endif /* __ASSEMBLY__ */ 14 12 15 13 #endif /* __ASM_PATCHING_H */
+1
arch/arm64/kernel/ftrace.c
··· 15 15 #include <asm/debug-monitors.h> 16 16 #include <asm/ftrace.h> 17 17 #include <asm/insn.h> 18 + #include <asm/patching.h> 18 19 19 20 #ifdef CONFIG_DYNAMIC_FTRACE 20 21 /*
+1
arch/arm64/kernel/jump_label.c
··· 8 8 #include <linux/kernel.h> 9 9 #include <linux/jump_label.h> 10 10 #include <asm/insn.h> 11 + #include <asm/patching.h> 11 12 12 13 void arch_jump_label_transform(struct jump_entry *entry, 13 14 enum jump_label_type type)
+1
arch/arm64/kernel/kgdb.c
··· 17 17 18 18 #include <asm/debug-monitors.h> 19 19 #include <asm/insn.h> 20 + #include <asm/patching.h> 20 21 #include <asm/traps.h> 21 22 22 23 struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {
+1
arch/arm64/kernel/patching.c
··· 9 9 #include <asm/cacheflush.h> 10 10 #include <asm/fixmap.h> 11 11 #include <asm/kprobes.h> 12 + #include <asm/patching.h> 12 13 #include <asm/sections.h> 13 14 14 15 static DEFINE_RAW_SPINLOCK(patch_lock);
+13 -11
arch/arm64/kernel/probes/kprobes.c
··· 7 7 * Copyright (C) 2013 Linaro Limited. 8 8 * Author: Sandeepa Prabhu <sandeepa.prabhu@linaro.org> 9 9 */ 10 + #include <linux/extable.h> 10 11 #include <linux/kasan.h> 11 12 #include <linux/kernel.h> 12 13 #include <linux/kprobes.h> 13 - #include <linux/extable.h> 14 - #include <linux/slab.h> 15 - #include <linux/stop_machine.h> 16 14 #include <linux/sched/debug.h> 17 15 #include <linux/set_memory.h> 16 + #include <linux/slab.h> 17 + #include <linux/stop_machine.h> 18 18 #include <linux/stringify.h> 19 - #include <linux/vmalloc.h> 20 - #include <asm/traps.h> 21 - #include <asm/ptrace.h> 22 - #include <asm/cacheflush.h> 23 - #include <asm/debug-monitors.h> 24 - #include <asm/daifflags.h> 25 - #include <asm/system_misc.h> 26 - #include <asm/insn.h> 27 19 #include <linux/uaccess.h> 20 + #include <linux/vmalloc.h> 21 + 22 + #include <asm/cacheflush.h> 23 + #include <asm/daifflags.h> 24 + #include <asm/debug-monitors.h> 25 + #include <asm/insn.h> 28 26 #include <asm/irq.h> 27 + #include <asm/patching.h> 28 + #include <asm/ptrace.h> 29 29 #include <asm/sections.h> 30 + #include <asm/system_misc.h> 31 + #include <asm/traps.h> 30 32 31 33 #include "decode-insn.h" 32 34
+1
arch/arm64/kernel/traps.c
··· 37 37 #include <asm/exception.h> 38 38 #include <asm/extable.h> 39 39 #include <asm/kprobes.h> 40 + #include <asm/patching.h> 40 41 #include <asm/traps.h> 41 42 #include <asm/smp.h> 42 43 #include <asm/stack_pointer.h>