arm64: insn: decouple patching from insn code
authorMark Rutland <mark.rutland@arm.com>
Wed, 9 Jun 2021 10:23:00 +0000 (11:23 +0100)
committerWill Deacon <will@kernel.org>
Fri, 11 Jun 2021 10:19:27 +0000 (11:19 +0100)
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>
arch/arm64/include/asm/insn.h
arch/arm64/include/asm/patching.h
arch/arm64/kernel/ftrace.c
arch/arm64/kernel/jump_label.c
arch/arm64/kernel/kgdb.c
arch/arm64/kernel/patching.c
arch/arm64/kernel/probes/kprobes.c
arch/arm64/kernel/traps.c

index 1ea9611545bb496d3f464fa025c5b25912c176bd..a6f3f45fc46f016eb3282984c4306146036429d5 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/types.h>
 
 #include <asm/alternative.h>
-#include <asm/patching.h>
 
 #ifndef __ASSEMBLY__
 /*
index 5ebab129222f490af47b68cfb824d0845a3b90b5..6bf5adc5629504e19698823b7b5513e9d1d6e5d5 100644 (file)
@@ -4,12 +4,10 @@
 
 #include <linux/types.h>
 
-#ifndef __ASSEMBLY__
 int aarch64_insn_read(void *addr, u32 *insnp);
 int aarch64_insn_write(void *addr, u32 insn);
 
 int aarch64_insn_patch_text_nosync(void *addr, u32 insn);
 int aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt);
-#endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_PATCHING_H */
index b5d3ddaf69d9e9b0c58c5ae1bf21fdb80b364b99..7f467bd9db7a3ea0a977eddfcd11186586a1d4e0 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/debug-monitors.h>
 #include <asm/ftrace.h>
 #include <asm/insn.h>
+#include <asm/patching.h>
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 /*
index 9a8a0ae1e75f89b9a42ff941b48f3976179d992d..fc98037e122056057b15693f647d4628feb8229a 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/kernel.h>
 #include <linux/jump_label.h>
 #include <asm/insn.h>
+#include <asm/patching.h>
 
 void arch_jump_label_transform(struct jump_entry *entry,
                               enum jump_label_type type)
index 1a157ca33262d11de7d74eaf4d994cb9bf3ceeca..2aede780fb80c50f4636e830c99b786d4a1e9970 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <asm/debug-monitors.h>
 #include <asm/insn.h>
+#include <asm/patching.h>
 #include <asm/traps.h>
 
 struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {
index 9d050e33901b7427af59a4f9c4a52901dcd964c6..7aa55b33c8c7512bf4fc33476eebe29ce1fb1545 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/cacheflush.h>
 #include <asm/fixmap.h>
 #include <asm/kprobes.h>
+#include <asm/patching.h>
 #include <asm/sections.h>
 
 static DEFINE_RAW_SPINLOCK(patch_lock);
index d607c9912025219469d1946b1ea6ac56128d8cc3..609edde7a5ddefc864f17416d99b77f566f80caa 100644 (file)
@@ -7,26 +7,28 @@
  * Copyright (C) 2013 Linaro Limited.
  * Author: Sandeepa Prabhu <sandeepa.prabhu@linaro.org>
  */
+#include <linux/extable.h>
 #include <linux/kasan.h>
 #include <linux/kernel.h>
 #include <linux/kprobes.h>
-#include <linux/extable.h>
-#include <linux/slab.h>
-#include <linux/stop_machine.h>
 #include <linux/sched/debug.h>
 #include <linux/set_memory.h>
+#include <linux/slab.h>
+#include <linux/stop_machine.h>
 #include <linux/stringify.h>
+#include <linux/uaccess.h>
 #include <linux/vmalloc.h>
-#include <asm/traps.h>
-#include <asm/ptrace.h>
+
 #include <asm/cacheflush.h>
-#include <asm/debug-monitors.h>
 #include <asm/daifflags.h>
-#include <asm/system_misc.h>
+#include <asm/debug-monitors.h>
 #include <asm/insn.h>
-#include <linux/uaccess.h>
 #include <asm/irq.h>
+#include <asm/patching.h>
+#include <asm/ptrace.h>
 #include <asm/sections.h>
+#include <asm/system_misc.h>
+#include <asm/traps.h>
 
 #include "decode-insn.h"
 
index 9b683b2381cf184cb460a58e9f16a982597ffd3e..48ff6fb888e0c839e2fbadefec725a9baff295d5 100644 (file)
@@ -37,6 +37,7 @@
 #include <asm/exception.h>
 #include <asm/extable.h>
 #include <asm/kprobes.h>
+#include <asm/patching.h>
 #include <asm/traps.h>
 #include <asm/smp.h>
 #include <asm/stack_pointer.h>