diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2011-04-18 18:19:51 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2011-04-18 19:40:21 -0400 |
commit | dc326fca2b640fc41aed7c015d0f456935a66255 (patch) | |
tree | 9181ef9c416e8fba822d75b53155c896b3900e72 /arch/x86/include/asm/nops.h | |
parent | b1e7734f024c9ce4393016a97c8d821e1f18d9b4 (diff) |
x86, cpu: Clean up and unify the NOP selection infrastructure
Clean up and unify the NOP selection infrastructure:
- Make the atomic 5-byte NOP a part of the selection system.
- Pick NOPs once during early boot and then be done with it.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jason Baron <jbaron@redhat.com>
Link: http://lkml.kernel.org/r/1303166160-10315-3-git-send-email-hpa@linux.intel.com
Diffstat (limited to 'arch/x86/include/asm/nops.h')
-rw-r--r-- | arch/x86/include/asm/nops.h | 146 |
1 files changed, 84 insertions, 62 deletions
diff --git a/arch/x86/include/asm/nops.h b/arch/x86/include/asm/nops.h index af788496020b..405b4032a60b 100644 --- a/arch/x86/include/asm/nops.h +++ b/arch/x86/include/asm/nops.h | |||
@@ -1,7 +1,13 @@ | |||
1 | #ifndef _ASM_X86_NOPS_H | 1 | #ifndef _ASM_X86_NOPS_H |
2 | #define _ASM_X86_NOPS_H | 2 | #define _ASM_X86_NOPS_H |
3 | 3 | ||
4 | /* Define nops for use with alternative() */ | 4 | /* |
5 | * Define nops for use with alternative() and for tracing. | ||
6 | * | ||
7 | * *_NOP5_ATOMIC must be a single instruction. | ||
8 | */ | ||
9 | |||
10 | #define NOP_DS_PREFIX 0x3e | ||
5 | 11 | ||
6 | /* generic versions from gas | 12 | /* generic versions from gas |
7 | 1: nop | 13 | 1: nop |
@@ -13,14 +19,15 @@ | |||
13 | 6: leal 0x00000000(%esi),%esi | 19 | 6: leal 0x00000000(%esi),%esi |
14 | 7: leal 0x00000000(,%esi,1),%esi | 20 | 7: leal 0x00000000(,%esi,1),%esi |
15 | */ | 21 | */ |
16 | #define GENERIC_NOP1 ".byte 0x90\n" | 22 | #define GENERIC_NOP1 0x90 |
17 | #define GENERIC_NOP2 ".byte 0x89,0xf6\n" | 23 | #define GENERIC_NOP2 0x89,0xf6 |
18 | #define GENERIC_NOP3 ".byte 0x8d,0x76,0x00\n" | 24 | #define GENERIC_NOP3 0x8d,0x76,0x00 |
19 | #define GENERIC_NOP4 ".byte 0x8d,0x74,0x26,0x00\n" | 25 | #define GENERIC_NOP4 0x8d,0x74,0x26,0x00 |
20 | #define GENERIC_NOP5 GENERIC_NOP1 GENERIC_NOP4 | 26 | #define GENERIC_NOP5 GENERIC_NOP1,GENERIC_NOP4 |
21 | #define GENERIC_NOP6 ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n" | 27 | #define GENERIC_NOP6 0x8d,0xb6,0x00,0x00,0x00,0x00 |
22 | #define GENERIC_NOP7 ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n" | 28 | #define GENERIC_NOP7 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00 |
23 | #define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7 | 29 | #define GENERIC_NOP8 GENERIC_NOP1,GENERIC_NOP7 |
30 | #define GENERIC_NOP5_ATOMIC NOP_DS_PREFIX,GENERIC_NOP4 | ||
24 | 31 | ||
25 | /* Opteron 64bit nops | 32 | /* Opteron 64bit nops |
26 | 1: nop | 33 | 1: nop |
@@ -29,13 +36,14 @@ | |||
29 | 4: osp osp osp nop | 36 | 4: osp osp osp nop |
30 | */ | 37 | */ |
31 | #define K8_NOP1 GENERIC_NOP1 | 38 | #define K8_NOP1 GENERIC_NOP1 |
32 | #define K8_NOP2 ".byte 0x66,0x90\n" | 39 | #define K8_NOP2 0x66,K8_NOP1 |
33 | #define K8_NOP3 ".byte 0x66,0x66,0x90\n" | 40 | #define K8_NOP3 0x66,K8_NOP2 |
34 | #define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n" | 41 | #define K8_NOP4 0x66,K8_NOP3 |
35 | #define K8_NOP5 K8_NOP3 K8_NOP2 | 42 | #define K8_NOP5 K8_NOP3,K8_NOP2 |
36 | #define K8_NOP6 K8_NOP3 K8_NOP3 | 43 | #define K8_NOP6 K8_NOP3,K8_NOP3 |
37 | #define K8_NOP7 K8_NOP4 K8_NOP3 | 44 | #define K8_NOP7 K8_NOP4,K8_NOP3 |
38 | #define K8_NOP8 K8_NOP4 K8_NOP4 | 45 | #define K8_NOP8 K8_NOP4,K8_NOP4 |
46 | #define K8_NOP5_ATOMIC 0x66,K8_NOP4 | ||
39 | 47 | ||
40 | /* K7 nops | 48 | /* K7 nops |
41 | uses eax dependencies (arbitrary choice) | 49 | uses eax dependencies (arbitrary choice) |
@@ -47,13 +55,14 @@ | |||
47 | 7: leal 0x00000000(,%eax,1),%eax | 55 | 7: leal 0x00000000(,%eax,1),%eax |
48 | */ | 56 | */ |
49 | #define K7_NOP1 GENERIC_NOP1 | 57 | #define K7_NOP1 GENERIC_NOP1 |
50 | #define K7_NOP2 ".byte 0x8b,0xc0\n" | 58 | #define K7_NOP2 0x8b,0xc0 |
51 | #define K7_NOP3 ".byte 0x8d,0x04,0x20\n" | 59 | #define K7_NOP3 0x8d,0x04,0x20 |
52 | #define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n" | 60 | #define K7_NOP4 0x8d,0x44,0x20,0x00 |
53 | #define K7_NOP5 K7_NOP4 ASM_NOP1 | 61 | #define K7_NOP5 K7_NOP4,K7_NOP1 |
54 | #define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n" | 62 | #define K7_NOP6 0x8d,0x80,0,0,0,0 |
55 | #define K7_NOP7 ".byte 0x8D,0x04,0x05,0,0,0,0\n" | 63 | #define K7_NOP7 0x8D,0x04,0x05,0,0,0,0 |
56 | #define K7_NOP8 K7_NOP7 ASM_NOP1 | 64 | #define K7_NOP8 K7_NOP7,K7_NOP1 |
65 | #define K7_NOP5_ATOMIC NOP_DS_PREFIX,K7_NOP4 | ||
57 | 66 | ||
58 | /* P6 nops | 67 | /* P6 nops |
59 | uses eax dependencies (Intel-recommended choice) | 68 | uses eax dependencies (Intel-recommended choice) |
@@ -69,52 +78,65 @@ | |||
69 | There is kernel code that depends on this. | 78 | There is kernel code that depends on this. |
70 | */ | 79 | */ |
71 | #define P6_NOP1 GENERIC_NOP1 | 80 | #define P6_NOP1 GENERIC_NOP1 |
72 | #define P6_NOP2 ".byte 0x66,0x90\n" | 81 | #define P6_NOP2 0x66,0x90 |
73 | #define P6_NOP3 ".byte 0x0f,0x1f,0x00\n" | 82 | #define P6_NOP3 0x0f,0x1f,0x00 |
74 | #define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n" | 83 | #define P6_NOP4 0x0f,0x1f,0x40,0 |
75 | #define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n" | 84 | #define P6_NOP5 0x0f,0x1f,0x44,0x00,0 |
76 | #define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n" | 85 | #define P6_NOP6 0x66,0x0f,0x1f,0x44,0x00,0 |
77 | #define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n" | 86 | #define P6_NOP7 0x0f,0x1f,0x80,0,0,0,0 |
78 | #define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n" | 87 | #define P6_NOP8 0x0f,0x1f,0x84,0x00,0,0,0,0 |
88 | #define P6_NOP5_ATOMIC P6_NOP5 | ||
89 | |||
90 | #define _ASM_MK_NOP(x) ".byte " __stringify(x) "\n" | ||
79 | 91 | ||
80 | #if defined(CONFIG_MK7) | 92 | #if defined(CONFIG_MK7) |
81 | #define ASM_NOP1 K7_NOP1 | 93 | #define ASM_NOP1 _ASM_MK_NOP(K7_NOP1) |
82 | #define ASM_NOP2 K7_NOP2 | 94 | #define ASM_NOP2 _ASM_MK_NOP(K7_NOP2) |
83 | #define ASM_NOP3 K7_NOP3 | 95 | #define ASM_NOP3 _ASM_MK_NOP(K7_NOP3) |
84 | #define ASM_NOP4 K7_NOP4 | 96 | #define ASM_NOP4 _ASM_MK_NOP(K7_NOP4) |
85 | #define ASM_NOP5 K7_NOP5 | 97 | #define ASM_NOP5 _ASM_MK_NOP(K7_NOP5) |
86 | #define ASM_NOP6 K7_NOP6 | 98 | #define ASM_NOP6 _ASM_MK_NOP(K7_NOP6) |
87 | #define ASM_NOP7 K7_NOP7 | 99 | #define ASM_NOP7 _ASM_MK_NOP(K7_NOP7) |
88 | #define ASM_NOP8 K7_NOP8 | 100 | #define ASM_NOP8 _ASM_MK_NOP(K7_NOP8) |
101 | #define ASM_NOP5_ATOMIC _ASM_MK_NOP(K7_NOP5_ATOMIC) | ||
89 | #elif defined(CONFIG_X86_P6_NOP) | 102 | #elif defined(CONFIG_X86_P6_NOP) |
90 | #define ASM_NOP1 P6_NOP1 | 103 | #define ASM_NOP1 _ASM_MK_NOP(P6_NOP1) |
91 | #define ASM_NOP2 P6_NOP2 | 104 | #define ASM_NOP2 _ASM_MK_NOP(P6_NOP2) |
92 | #define ASM_NOP3 P6_NOP3 | 105 | #define ASM_NOP3 _ASM_MK_NOP(P6_NOP3) |
93 | #define ASM_NOP4 P6_NOP4 | 106 | #define ASM_NOP4 _ASM_MK_NOP(P6_NOP4) |
94 | #define ASM_NOP5 P6_NOP5 | 107 | #define ASM_NOP5 _ASM_MK_NOP(P6_NOP5) |
95 | #define ASM_NOP6 P6_NOP6 | 108 | #define ASM_NOP6 _ASM_MK_NOP(P6_NOP6) |
96 | #define ASM_NOP7 P6_NOP7 | 109 | #define ASM_NOP7 _ASM_MK_NOP(P6_NOP7) |
97 | #define ASM_NOP8 P6_NOP8 | 110 | #define ASM_NOP8 _ASM_MK_NOP(P6_NOP8) |
111 | #define ASM_NOP5_ATOMIC _ASM_MK_NOP(P6_NOP5_ATOMIC) | ||
98 | #elif defined(CONFIG_X86_64) | 112 | #elif defined(CONFIG_X86_64) |
99 | #define ASM_NOP1 K8_NOP1 | 113 | #define ASM_NOP1 _ASM_MK_NOP(K8_NOP1) |
100 | #define ASM_NOP2 K8_NOP2 | 114 | #define ASM_NOP2 _ASM_MK_NOP(K8_NOP2) |
101 | #define ASM_NOP3 K8_NOP3 | 115 | #define ASM_NOP3 _ASM_MK_NOP(K8_NOP3) |
102 | #define ASM_NOP4 K8_NOP4 | 116 | #define ASM_NOP4 _ASM_MK_NOP(K8_NOP4) |
103 | #define ASM_NOP5 K8_NOP5 | 117 | #define ASM_NOP5 _ASM_MK_NOP(K8_NOP5) |
104 | #define ASM_NOP6 K8_NOP6 | 118 | #define ASM_NOP6 _ASM_MK_NOP(K8_NOP6) |
105 | #define ASM_NOP7 K8_NOP7 | 119 | #define ASM_NOP7 _ASM_MK_NOP(K8_NOP7) |
106 | #define ASM_NOP8 K8_NOP8 | 120 | #define ASM_NOP8 _ASM_MK_NOP(K8_NOP8) |
121 | #define ASM_NOP5_ATOMIC _ASM_MK_NOP(K8_NOP5_ATOMIC) | ||
107 | #else | 122 | #else |
108 | #define ASM_NOP1 GENERIC_NOP1 | 123 | #define ASM_NOP1 _ASM_MK_NOP(GENERIC_NOP1) |
109 | #define ASM_NOP2 GENERIC_NOP2 | 124 | #define ASM_NOP2 _ASM_MK_NOP(GENERIC_NOP2) |
110 | #define ASM_NOP3 GENERIC_NOP3 | 125 | #define ASM_NOP3 _ASM_MK_NOP(GENERIC_NOP3) |
111 | #define ASM_NOP4 GENERIC_NOP4 | 126 | #define ASM_NOP4 _ASM_MK_NOP(GENERIC_NOP4) |
112 | #define ASM_NOP5 GENERIC_NOP5 | 127 | #define ASM_NOP5 _ASM_MK_NOP(GENERIC_NOP5) |
113 | #define ASM_NOP6 GENERIC_NOP6 | 128 | #define ASM_NOP6 _ASM_MK_NOP(GENERIC_NOP6) |
114 | #define ASM_NOP7 GENERIC_NOP7 | 129 | #define ASM_NOP7 _ASM_MK_NOP(GENERIC_NOP7) |
115 | #define ASM_NOP8 GENERIC_NOP8 | 130 | #define ASM_NOP8 _ASM_MK_NOP(GENERIC_NOP8) |
131 | #define ASM_NOP5_ATOMIC _ASM_MK_NOP(GENERIC_NOP5_ATOMIC) | ||
116 | #endif | 132 | #endif |
117 | 133 | ||
118 | #define ASM_NOP_MAX 8 | 134 | #define ASM_NOP_MAX 8 |
135 | #define NOP_ATOMIC5 (ASM_NOP_MAX+1) /* Entry for the 5-byte atomic NOP */ | ||
136 | |||
137 | #ifndef __ASSEMBLY__ | ||
138 | extern const unsigned char * const *ideal_nops; | ||
139 | extern void arch_init_ideal_nops(void); | ||
140 | #endif | ||
119 | 141 | ||
120 | #endif /* _ASM_X86_NOPS_H */ | 142 | #endif /* _ASM_X86_NOPS_H */ |