diff options
-rw-r--r-- | arch/x86/include/asm/alternative.h | 33 | ||||
-rw-r--r-- | arch/x86/include/asm/kgdb.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/setup.h | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/text-patching.h | 40 | ||||
-rw-r--r-- | arch/x86/kernel/alternative.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/jump_label.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/kgdb.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/kprobes/core.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/kprobes/opt.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/module.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/traps.c | 1 |
11 files changed, 50 insertions, 33 deletions
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 99afb665a004..be4496c961db 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h | |||
@@ -5,7 +5,6 @@ | |||
5 | #include <linux/stddef.h> | 5 | #include <linux/stddef.h> |
6 | #include <linux/stringify.h> | 6 | #include <linux/stringify.h> |
7 | #include <asm/asm.h> | 7 | #include <asm/asm.h> |
8 | #include <asm/ptrace.h> | ||
9 | 8 | ||
10 | /* | 9 | /* |
11 | * Alternative inline assembly for SMP. | 10 | * Alternative inline assembly for SMP. |
@@ -233,36 +232,4 @@ static inline int alternatives_text_reserved(void *start, void *end) | |||
233 | */ | 232 | */ |
234 | #define ASM_NO_INPUT_CLOBBER(clbr...) "i" (0) : clbr | 233 | #define ASM_NO_INPUT_CLOBBER(clbr...) "i" (0) : clbr |
235 | 234 | ||
236 | struct paravirt_patch_site; | ||
237 | #ifdef CONFIG_PARAVIRT | ||
238 | void apply_paravirt(struct paravirt_patch_site *start, | ||
239 | struct paravirt_patch_site *end); | ||
240 | #else | ||
241 | static inline void apply_paravirt(struct paravirt_patch_site *start, | ||
242 | struct paravirt_patch_site *end) | ||
243 | {} | ||
244 | #define __parainstructions NULL | ||
245 | #define __parainstructions_end NULL | ||
246 | #endif | ||
247 | |||
248 | extern void *text_poke_early(void *addr, const void *opcode, size_t len); | ||
249 | |||
250 | /* | ||
251 | * Clear and restore the kernel write-protection flag on the local CPU. | ||
252 | * Allows the kernel to edit read-only pages. | ||
253 | * Side-effect: any interrupt handler running between save and restore will have | ||
254 | * the ability to write to read-only pages. | ||
255 | * | ||
256 | * Warning: | ||
257 | * Code patching in the UP case is safe if NMIs and MCE handlers are stopped and | ||
258 | * no thread can be preempted in the instructions being modified (no iret to an | ||
259 | * invalid instruction possible) or if the instructions are changed from a | ||
260 | * consistent state to another consistent state atomically. | ||
261 | * On the local CPU you need to be protected again NMI or MCE handlers seeing an | ||
262 | * inconsistent instruction while you patch. | ||
263 | */ | ||
264 | extern void *text_poke(void *addr, const void *opcode, size_t len); | ||
265 | extern int poke_int3_handler(struct pt_regs *regs); | ||
266 | extern void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler); | ||
267 | |||
268 | #endif /* _ASM_X86_ALTERNATIVE_H */ | 235 | #endif /* _ASM_X86_ALTERNATIVE_H */ |
diff --git a/arch/x86/include/asm/kgdb.h b/arch/x86/include/asm/kgdb.h index 332f98c9111f..22a8537eb780 100644 --- a/arch/x86/include/asm/kgdb.h +++ b/arch/x86/include/asm/kgdb.h | |||
@@ -6,6 +6,8 @@ | |||
6 | * Copyright (C) 2008 Wind River Systems, Inc. | 6 | * Copyright (C) 2008 Wind River Systems, Inc. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <asm/ptrace.h> | ||
10 | |||
9 | /* | 11 | /* |
10 | * BUFMAX defines the maximum number of characters in inbound/outbound | 12 | * BUFMAX defines the maximum number of characters in inbound/outbound |
11 | * buffers at least NUMREGBYTES*2 are needed for register packets | 13 | * buffers at least NUMREGBYTES*2 are needed for register packets |
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index 11af24e09c8a..ac1d5da14734 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #define COMMAND_LINE_SIZE 2048 | 6 | #define COMMAND_LINE_SIZE 2048 |
7 | 7 | ||
8 | #include <linux/linkage.h> | 8 | #include <linux/linkage.h> |
9 | #include <asm/page_types.h> | ||
9 | 10 | ||
10 | #ifdef __i386__ | 11 | #ifdef __i386__ |
11 | 12 | ||
diff --git a/arch/x86/include/asm/text-patching.h b/arch/x86/include/asm/text-patching.h new file mode 100644 index 000000000000..90395063383c --- /dev/null +++ b/arch/x86/include/asm/text-patching.h | |||
@@ -0,0 +1,40 @@ | |||
1 | #ifndef _ASM_X86_TEXT_PATCHING_H | ||
2 | #define _ASM_X86_TEXT_PATCHING_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <linux/stddef.h> | ||
6 | #include <asm/ptrace.h> | ||
7 | |||
8 | struct paravirt_patch_site; | ||
9 | #ifdef CONFIG_PARAVIRT | ||
10 | void apply_paravirt(struct paravirt_patch_site *start, | ||
11 | struct paravirt_patch_site *end); | ||
12 | #else | ||
13 | static inline void apply_paravirt(struct paravirt_patch_site *start, | ||
14 | struct paravirt_patch_site *end) | ||
15 | {} | ||
16 | #define __parainstructions NULL | ||
17 | #define __parainstructions_end NULL | ||
18 | #endif | ||
19 | |||
20 | extern void *text_poke_early(void *addr, const void *opcode, size_t len); | ||
21 | |||
22 | /* | ||
23 | * Clear and restore the kernel write-protection flag on the local CPU. | ||
24 | * Allows the kernel to edit read-only pages. | ||
25 | * Side-effect: any interrupt handler running between save and restore will have | ||
26 | * the ability to write to read-only pages. | ||
27 | * | ||
28 | * Warning: | ||
29 | * Code patching in the UP case is safe if NMIs and MCE handlers are stopped and | ||
30 | * no thread can be preempted in the instructions being modified (no iret to an | ||
31 | * invalid instruction possible) or if the instructions are changed from a | ||
32 | * consistent state to another consistent state atomically. | ||
33 | * On the local CPU you need to be protected again NMI or MCE handlers seeing an | ||
34 | * inconsistent instruction while you patch. | ||
35 | */ | ||
36 | extern void *text_poke(void *addr, const void *opcode, size_t len); | ||
37 | extern int poke_int3_handler(struct pt_regs *regs); | ||
38 | extern void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler); | ||
39 | |||
40 | #endif /* _ASM_X86_TEXT_PATCHING_H */ | ||
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 25f909362b7a..5cb272a7a5a3 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/stop_machine.h> | 11 | #include <linux/stop_machine.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/kdebug.h> | 13 | #include <linux/kdebug.h> |
14 | #include <asm/text-patching.h> | ||
14 | #include <asm/alternative.h> | 15 | #include <asm/alternative.h> |
15 | #include <asm/sections.h> | 16 | #include <asm/sections.h> |
16 | #include <asm/pgtable.h> | 17 | #include <asm/pgtable.h> |
diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index e565e0e4d216..fc25f698d792 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/cpu.h> | 13 | #include <linux/cpu.h> |
14 | #include <asm/kprobes.h> | 14 | #include <asm/kprobes.h> |
15 | #include <asm/alternative.h> | 15 | #include <asm/alternative.h> |
16 | #include <asm/text-patching.h> | ||
16 | 17 | ||
17 | #ifdef HAVE_JUMP_LABEL | 18 | #ifdef HAVE_JUMP_LABEL |
18 | 19 | ||
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c index 2da6ee9ae69b..04cde527d728 100644 --- a/arch/x86/kernel/kgdb.c +++ b/arch/x86/kernel/kgdb.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/uaccess.h> | 45 | #include <linux/uaccess.h> |
46 | #include <linux/memory.h> | 46 | #include <linux/memory.h> |
47 | 47 | ||
48 | #include <asm/text-patching.h> | ||
48 | #include <asm/debugreg.h> | 49 | #include <asm/debugreg.h> |
49 | #include <asm/apicdef.h> | 50 | #include <asm/apicdef.h> |
50 | #include <asm/apic.h> | 51 | #include <asm/apic.h> |
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index ae703acb85c1..38cf7a741250 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <linux/ftrace.h> | 51 | #include <linux/ftrace.h> |
52 | #include <linux/frame.h> | 52 | #include <linux/frame.h> |
53 | 53 | ||
54 | #include <asm/text-patching.h> | ||
54 | #include <asm/cacheflush.h> | 55 | #include <asm/cacheflush.h> |
55 | #include <asm/desc.h> | 56 | #include <asm/desc.h> |
56 | #include <asm/pgtable.h> | 57 | #include <asm/pgtable.h> |
diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c index 7b3b9d15c47a..4425f593f0ec 100644 --- a/arch/x86/kernel/kprobes/opt.c +++ b/arch/x86/kernel/kprobes/opt.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/kallsyms.h> | 29 | #include <linux/kallsyms.h> |
30 | #include <linux/ftrace.h> | 30 | #include <linux/ftrace.h> |
31 | 31 | ||
32 | #include <asm/text-patching.h> | ||
32 | #include <asm/cacheflush.h> | 33 | #include <asm/cacheflush.h> |
33 | #include <asm/desc.h> | 34 | #include <asm/desc.h> |
34 | #include <asm/pgtable.h> | 35 | #include <asm/pgtable.h> |
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c index 005c03e93fc5..477ae806c2fa 100644 --- a/arch/x86/kernel/module.c +++ b/arch/x86/kernel/module.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/jump_label.h> | 31 | #include <linux/jump_label.h> |
32 | #include <linux/random.h> | 32 | #include <linux/random.h> |
33 | 33 | ||
34 | #include <asm/text-patching.h> | ||
34 | #include <asm/page.h> | 35 | #include <asm/page.h> |
35 | #include <asm/pgtable.h> | 36 | #include <asm/pgtable.h> |
36 | #include <asm/setup.h> | 37 | #include <asm/setup.h> |
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 06cbe25861f1..d1590486204a 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <asm/processor.h> | 51 | #include <asm/processor.h> |
52 | #include <asm/debugreg.h> | 52 | #include <asm/debugreg.h> |
53 | #include <linux/atomic.h> | 53 | #include <linux/atomic.h> |
54 | #include <asm/text-patching.h> | ||
54 | #include <asm/ftrace.h> | 55 | #include <asm/ftrace.h> |
55 | #include <asm/traps.h> | 56 | #include <asm/traps.h> |
56 | #include <asm/desc.h> | 57 | #include <asm/desc.h> |