Skip to content

Commit 78b92c7

Browse files
mrutland-armwilldeacon
authored andcommitted
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>
1 parent 71766b8 commit 78b92c7

8 files changed

Lines changed: 15 additions & 11 deletions

File tree

arch/arm64/include/asm/insn.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/types.h>
1212

1313
#include <asm/alternative.h>
14-
#include <asm/patching.h>
1514

1615
#ifndef __ASSEMBLY__
1716
/*

arch/arm64/include/asm/patching.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
#include <linux/types.h>
66

7-
#ifndef __ASSEMBLY__
87
int aarch64_insn_read(void *addr, u32 *insnp);
98
int aarch64_insn_write(void *addr, u32 insn);
109

1110
int aarch64_insn_patch_text_nosync(void *addr, u32 insn);
1211
int aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt);
13-
#endif /* __ASSEMBLY__ */
1412

1513
#endif /* __ASM_PATCHING_H */

arch/arm64/kernel/ftrace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <asm/debug-monitors.h>
1616
#include <asm/ftrace.h>
1717
#include <asm/insn.h>
18+
#include <asm/patching.h>
1819

1920
#ifdef CONFIG_DYNAMIC_FTRACE
2021
/*

arch/arm64/kernel/jump_label.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/kernel.h>
99
#include <linux/jump_label.h>
1010
#include <asm/insn.h>
11+
#include <asm/patching.h>
1112

1213
void arch_jump_label_transform(struct jump_entry *entry,
1314
enum jump_label_type type)

arch/arm64/kernel/kgdb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <asm/debug-monitors.h>
1919
#include <asm/insn.h>
20+
#include <asm/patching.h>
2021
#include <asm/traps.h>
2122

2223
struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {

arch/arm64/kernel/patching.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/cacheflush.h>
1010
#include <asm/fixmap.h>
1111
#include <asm/kprobes.h>
12+
#include <asm/patching.h>
1213
#include <asm/sections.h>
1314

1415
static DEFINE_RAW_SPINLOCK(patch_lock);

arch/arm64/kernel/probes/kprobes.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@
77
* Copyright (C) 2013 Linaro Limited.
88
* Author: Sandeepa Prabhu <sandeepa.prabhu@linaro.org>
99
*/
10+
#include <linux/extable.h>
1011
#include <linux/kasan.h>
1112
#include <linux/kernel.h>
1213
#include <linux/kprobes.h>
13-
#include <linux/extable.h>
14-
#include <linux/slab.h>
15-
#include <linux/stop_machine.h>
1614
#include <linux/sched/debug.h>
1715
#include <linux/set_memory.h>
16+
#include <linux/slab.h>
17+
#include <linux/stop_machine.h>
1818
#include <linux/stringify.h>
19+
#include <linux/uaccess.h>
1920
#include <linux/vmalloc.h>
20-
#include <asm/traps.h>
21-
#include <asm/ptrace.h>
21+
2222
#include <asm/cacheflush.h>
23-
#include <asm/debug-monitors.h>
2423
#include <asm/daifflags.h>
25-
#include <asm/system_misc.h>
24+
#include <asm/debug-monitors.h>
2625
#include <asm/insn.h>
27-
#include <linux/uaccess.h>
2826
#include <asm/irq.h>
27+
#include <asm/patching.h>
28+
#include <asm/ptrace.h>
2929
#include <asm/sections.h>
30+
#include <asm/system_misc.h>
31+
#include <asm/traps.h>
3032

3133
#include "decode-insn.h"
3234

arch/arm64/kernel/traps.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <asm/exception.h>
3838
#include <asm/extable.h>
3939
#include <asm/kprobes.h>
40+
#include <asm/patching.h>
4041
#include <asm/traps.h>
4142
#include <asm/smp.h>
4243
#include <asm/stack_pointer.h>

0 commit comments

Comments
 (0)