Commit f1c5d30e authored by H. Peter Anvin's avatar H. Peter Anvin

x86: use X86_FEATURE_NOPL in alternatives

Use X86_FEATURE_NOPL to determine if it is safe to use P6 NOPs in
alternatives.  Also, replace table and loop with simple if statement.
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
parent 7e00df58
...@@ -145,35 +145,25 @@ static const unsigned char *const p6_nops[ASM_NOP_MAX+1] = { ...@@ -145,35 +145,25 @@ static const unsigned char *const p6_nops[ASM_NOP_MAX+1] = {
extern char __vsyscall_0; extern char __vsyscall_0;
const unsigned char *const *find_nop_table(void) const unsigned char *const *find_nop_table(void)
{ {
return boot_cpu_data.x86_vendor != X86_VENDOR_INTEL || if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
boot_cpu_data.x86 < 6 ? k8_nops : p6_nops; boot_cpu_has(X86_FEATURE_NOPL))
return p6_nops;
else
return k8_nops;
} }
#else /* CONFIG_X86_64 */ #else /* CONFIG_X86_64 */
static const struct nop {
int cpuid;
const unsigned char *const *noptable;
} noptypes[] = {
{ X86_FEATURE_K8, k8_nops },
{ X86_FEATURE_K7, k7_nops },
{ X86_FEATURE_P4, p6_nops },
{ X86_FEATURE_P3, p6_nops },
{ -1, NULL }
};
const unsigned char *const *find_nop_table(void) const unsigned char *const *find_nop_table(void)
{ {
const unsigned char *const *noptable = intel_nops; if (boot_cpu_has(X86_FEATURE_K8))
int i; return k8_nops;
else if (boot_cpu_has(X86_FEATURE_K7))
for (i = 0; noptypes[i].cpuid >= 0; i++) { return k7_nops;
if (boot_cpu_has(noptypes[i].cpuid)) { else if (boot_cpu_has(X86_FEATURE_NOPL))
noptable = noptypes[i].noptable; return p6_nops;
break; else
} return intel_nops;
}
return noptable;
} }
#endif /* CONFIG_X86_64 */ #endif /* CONFIG_X86_64 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment