Skip to content

Commit 6007878

Browse files
jgross1suryasaimadhu
authored andcommitted
x86/cpu: Switch to cpu_feature_enabled() for X86_FEATURE_XENPV
Convert the remaining cases of static_cpu_has(X86_FEATURE_XENPV) and boot_cpu_has(X86_FEATURE_XENPV) to use cpu_feature_enabled(), allowing more efficient code in case the kernel is configured without CONFIG_XEN_PV. Signed-off-by: Juergen Gross <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Dave Hansen <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d76c4f7 commit 6007878

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

arch/x86/kernel/cpu/amd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ static void init_amd(struct cpuinfo_x86 *c)
985985
set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH);
986986

987987
/* AMD CPUs don't reset SS attributes on SYSRET, Xen does. */
988-
if (!cpu_has(c, X86_FEATURE_XENPV))
988+
if (!cpu_feature_enabled(X86_FEATURE_XENPV))
989989
set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
990990

991991
/*

arch/x86/kernel/cpu/bugs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
13021302
return SPECTRE_V2_CMD_AUTO;
13031303
}
13041304

1305-
if (cmd == SPECTRE_V2_CMD_IBRS && boot_cpu_has(X86_FEATURE_XENPV)) {
1305+
if (cmd == SPECTRE_V2_CMD_IBRS && cpu_feature_enabled(X86_FEATURE_XENPV)) {
13061306
pr_err("%s selected but running as XenPV guest. Switching to AUTO select\n",
13071307
mitigation_options[i].option);
13081308
return SPECTRE_V2_CMD_AUTO;

arch/x86/kernel/cpu/hygon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static void init_hygon(struct cpuinfo_x86 *c)
339339
set_cpu_cap(c, X86_FEATURE_ARAT);
340340

341341
/* Hygon CPUs don't reset SS attributes on SYSRET, Xen does. */
342-
if (!cpu_has(c, X86_FEATURE_XENPV))
342+
if (!cpu_feature_enabled(X86_FEATURE_XENPV))
343343
set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
344344

345345
check_null_seg_clears_base(c);

arch/x86/kernel/process_64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static noinstr unsigned long __rdgsbase_inactive(void)
165165

166166
lockdep_assert_irqs_disabled();
167167

168-
if (!static_cpu_has(X86_FEATURE_XENPV)) {
168+
if (!cpu_feature_enabled(X86_FEATURE_XENPV)) {
169169
native_swapgs();
170170
gsbase = rdgsbase();
171171
native_swapgs();
@@ -190,7 +190,7 @@ static noinstr void __wrgsbase_inactive(unsigned long gsbase)
190190
{
191191
lockdep_assert_irqs_disabled();
192192

193-
if (!static_cpu_has(X86_FEATURE_XENPV)) {
193+
if (!cpu_feature_enabled(X86_FEATURE_XENPV)) {
194194
native_swapgs();
195195
wrgsbase(gsbase);
196196
native_swapgs();

arch/x86/kernel/topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int arch_register_cpu(int num)
106106
* Xen PV guests don't support CPU0 hotplug at all.
107107
*/
108108
if (c->x86_vendor != X86_VENDOR_INTEL ||
109-
boot_cpu_has(X86_FEATURE_XENPV))
109+
cpu_feature_enabled(X86_FEATURE_XENPV))
110110
cpu0_hotpluggable = 0;
111111

112112
/*

0 commit comments

Comments
 (0)