aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/alternative_64.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-x86/alternative_64.h')
-rw-r--r--include/asm-x86/alternative_64.h84
1 files changed, 43 insertions, 41 deletions
diff --git a/include/asm-x86/alternative_64.h b/include/asm-x86/alternative_64.h
index ab161e810151..50efcebae33f 100644
--- a/include/asm-x86/alternative_64.h
+++ b/include/asm-x86/alternative_64.h
@@ -1,10 +1,9 @@
1#ifndef _X86_64_ALTERNATIVE_H 1#ifndef _X86_64_ALTERNATIVE_H
2#define _X86_64_ALTERNATIVE_H 2#define _X86_64_ALTERNATIVE_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/types.h> 4#include <linux/types.h>
7#include <linux/stddef.h> 5#include <linux/stddef.h>
6#include <asm/asm.h>
8 7
9/* 8/*
10 * Alternative inline assembly for SMP. 9 * Alternative inline assembly for SMP.
@@ -30,10 +29,10 @@
30#ifdef CONFIG_SMP 29#ifdef CONFIG_SMP
31#define LOCK_PREFIX \ 30#define LOCK_PREFIX \
32 ".section .smp_locks,\"a\"\n" \ 31 ".section .smp_locks,\"a\"\n" \
33 " .align 8\n" \ 32 _ASM_ALIGN "\n" \
34 " .quad 661f\n" /* address */ \ 33 _ASM_PTR "661f\n" /* address */ \
35 ".previous\n" \ 34 ".previous\n" \
36 "661:\n\tlock; " 35 "661:\n\tlock; "
37 36
38#else /* ! CONFIG_SMP */ 37#else /* ! CONFIG_SMP */
39#define LOCK_PREFIX "" 38#define LOCK_PREFIX ""
@@ -43,12 +42,15 @@
43#include <asm/cpufeature.h> 42#include <asm/cpufeature.h>
44 43
45struct alt_instr { 44struct alt_instr {
46 u8 *instr; /* original instruction */ 45 u8 *instr; /* original instruction */
47 u8 *replacement; 46 u8 *replacement;
48 u8 cpuid; /* cpuid bit set for replacement */ 47 u8 cpuid; /* cpuid bit set for replacement */
49 u8 instrlen; /* length of original instruction */ 48 u8 instrlen; /* length of original instruction */
50 u8 replacementlen; /* length of new instruction, <= instrlen */ 49 u8 replacementlen; /* length of new instruction, <= instrlen */
51 u8 pad[5]; 50 u8 pad1;
51#ifdef CONFIG_X86_64
52 u32 pad2;
53#endif
52}; 54};
53 55
54extern void alternative_instructions(void); 56extern void alternative_instructions(void);
@@ -68,9 +70,7 @@ static inline void alternatives_smp_module_add(struct module *mod, char *name,
68 void *text, void *text_end) {} 70 void *text, void *text_end) {}
69static inline void alternatives_smp_module_del(struct module *mod) {} 71static inline void alternatives_smp_module_del(struct module *mod) {}
70static inline void alternatives_smp_switch(int smp) {} 72static inline void alternatives_smp_switch(int smp) {}
71#endif 73#endif /* CONFIG_SMP */
72
73#endif
74 74
75/* 75/*
76 * Alternative instructions for different CPU types or capabilities. 76 * Alternative instructions for different CPU types or capabilities.
@@ -84,18 +84,18 @@ static inline void alternatives_smp_switch(int smp) {}
84 * For non barrier like inlines please define new variants 84 * For non barrier like inlines please define new variants
85 * without volatile and memory clobber. 85 * without volatile and memory clobber.
86 */ 86 */
87#define alternative(oldinstr, newinstr, feature) \ 87#define alternative(oldinstr, newinstr, feature) \
88 asm volatile ("661:\n\t" oldinstr "\n662:\n" \ 88 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
89 ".section .altinstructions,\"a\"\n" \ 89 ".section .altinstructions,\"a\"\n" \
90 " .align 8\n" \ 90 _ASM_ALIGN "\n" \
91 " .quad 661b\n" /* label */ \ 91 _ASM_PTR "661b\n" /* label */ \
92 " .quad 663f\n" /* new instruction */ \ 92 _ASM_PTR "663f\n" /* new instruction */ \
93 " .byte %c0\n" /* feature bit */ \ 93 " .byte %c0\n" /* feature bit */ \
94 " .byte 662b-661b\n" /* sourcelen */ \ 94 " .byte 662b-661b\n" /* sourcelen */ \
95 " .byte 664f-663f\n" /* replacementlen */ \ 95 " .byte 664f-663f\n" /* replacementlen */ \
96 ".previous\n" \ 96 ".previous\n" \
97 ".section .altinstr_replacement,\"ax\"\n" \ 97 ".section .altinstr_replacement,\"ax\"\n" \
98 "663:\n\t" newinstr "\n664:\n" /* replacement */ \ 98 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
99 ".previous" :: "i" (feature) : "memory") 99 ".previous" :: "i" (feature) : "memory")
100 100
101/* 101/*
@@ -111,30 +111,30 @@ static inline void alternatives_smp_switch(int smp) {}
111#define alternative_input(oldinstr, newinstr, feature, input...) \ 111#define alternative_input(oldinstr, newinstr, feature, input...) \
112 asm volatile ("661:\n\t" oldinstr "\n662:\n" \ 112 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
113 ".section .altinstructions,\"a\"\n" \ 113 ".section .altinstructions,\"a\"\n" \
114 " .align 8\n" \ 114 _ASM_ALIGN "\n" \
115 " .quad 661b\n" /* label */ \ 115 _ASM_PTR "661b\n" /* label */ \
116 " .quad 663f\n" /* new instruction */ \ 116 _ASM_PTR "663f\n" /* new instruction */ \
117 " .byte %c0\n" /* feature bit */ \ 117 " .byte %c0\n" /* feature bit */ \
118 " .byte 662b-661b\n" /* sourcelen */ \ 118 " .byte 662b-661b\n" /* sourcelen */ \
119 " .byte 664f-663f\n" /* replacementlen */ \ 119 " .byte 664f-663f\n" /* replacementlen */ \
120 ".previous\n" \ 120 ".previous\n" \
121 ".section .altinstr_replacement,\"ax\"\n" \ 121 ".section .altinstr_replacement,\"ax\"\n" \
122 "663:\n\t" newinstr "\n664:\n" /* replacement */ \ 122 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
123 ".previous" :: "i" (feature), ##input) 123 ".previous" :: "i" (feature), ##input)
124 124
125/* Like alternative_input, but with a single output argument */ 125/* Like alternative_input, but with a single output argument */
126#define alternative_io(oldinstr, newinstr, feature, output, input...) \ 126#define alternative_io(oldinstr, newinstr, feature, output, input...) \
127 asm volatile ("661:\n\t" oldinstr "\n662:\n" \ 127 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
128 ".section .altinstructions,\"a\"\n" \ 128 ".section .altinstructions,\"a\"\n" \
129 " .align 8\n" \ 129 _ASM_ALIGN "\n" \
130 " .quad 661b\n" /* label */ \ 130 _ASM_PTR "661b\n" /* label */ \
131 " .quad 663f\n" /* new instruction */ \ 131 _ASM_PTR "663f\n" /* new instruction */ \
132 " .byte %c[feat]\n" /* feature bit */ \ 132 " .byte %c[feat]\n" /* feature bit */ \
133 " .byte 662b-661b\n" /* sourcelen */ \ 133 " .byte 662b-661b\n" /* sourcelen */ \
134 " .byte 664f-663f\n" /* replacementlen */ \ 134 " .byte 664f-663f\n" /* replacementlen */ \
135 ".previous\n" \ 135 ".previous\n" \
136 ".section .altinstr_replacement,\"ax\"\n" \ 136 ".section .altinstr_replacement,\"ax\"\n" \
137 "663:\n\t" newinstr "\n664:\n" /* replacement */ \ 137 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
138 ".previous" : output : [feat] "i" (feature), ##input) 138 ".previous" : output : [feat] "i" (feature), ##input)
139 139
140/* 140/*
@@ -143,15 +143,17 @@ static inline void alternatives_smp_switch(int smp) {}
143 */ 143 */
144#define ASM_OUTPUT2(a, b) a, b 144#define ASM_OUTPUT2(a, b) a, b
145 145
146struct paravirt_patch; 146struct paravirt_patch_site;
147#ifdef CONFIG_PARAVIRT 147#ifdef CONFIG_PARAVIRT
148void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end); 148void apply_paravirt(struct paravirt_patch_site *start,
149 struct paravirt_patch_site *end);
149#else 150#else
150static inline void 151static inline void
151apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end) 152apply_paravirt(struct paravirt_patch_site *start,
153 struct paravirt_patch_site *end)
152{} 154{}
153#define __parainstructions NULL 155#define __parainstructions NULL
154#define __parainstructions_end NULL 156#define __parainstructions_end NULL
155#endif 157#endif
156 158
157extern void text_poke(void *addr, unsigned char *opcode, int len); 159extern void text_poke(void *addr, unsigned char *opcode, int len);