@@ -132,16 +132,14 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
132
132
*/
133
133
134
134
#if defined(CC_HAVE_ASM_GOTO ) && defined(CONFIG_X86_FAST_FEATURE_TESTS )
135
- extern bool __static_cpu_has (u16 bit );
136
-
137
135
/*
138
136
* Static testing of CPU features. Used the same as boot_cpu_has().
139
137
* These will statically patch the target code for additional
140
138
* performance.
141
139
*/
142
140
static __always_inline __pure bool _static_cpu_has (u16 bit )
143
141
{
144
- asm_volatile_goto ("1: jmp %l[t_dynamic] \n"
142
+ asm_volatile_goto ("1: jmp 6f \n"
145
143
"2:\n"
146
144
".skip -(((5f-4f) - (2b-1b)) > 0) * "
147
145
"((5f-4f) - (2b-1b)),0x90\n"
@@ -166,13 +164,20 @@ static __always_inline __pure bool _static_cpu_has(u16 bit)
166
164
" .byte 0\n" /* repl len */
167
165
" .byte 0\n" /* pad len */
168
166
".previous\n"
169
- : : "i " (bit ), "i" (X86_FEATURE_ALWAYS )
170
- : : t_dynamic , t_no );
167
+ ".section .altinstr_aux,\"ax\"\n"
168
+ "6:\n"
169
+ " testb %[bitnum],%[cap_byte]\n"
170
+ " jnz %l[t_yes]\n"
171
+ " jmp %l[t_no]\n"
172
+ ".previous\n"
173
+ : : "i " (bit ), "i" (X86_FEATURE_ALWAYS ),
174
+ [bitnum ] "i" (1 << (bit & 7 )),
175
+ [cap_byte ] "m" (((const char * )boot_cpu_data .x86_capability )[bit >> 3 ])
176
+ : : t_yes , t_no );
177
+ t_yes :
171
178
return true;
172
179
t_no :
173
180
return false;
174
- t_dynamic :
175
- return __static_cpu_has (bit );
176
181
}
177
182
178
183
#define static_cpu_has (bit ) \
0 commit comments