Skip to content

Commit ea01598

Browse files
committed
x86/xen: use capabilities instead of fake cpuid values for mwait
When running as pv domain xen_cpuid() is being used instead of native_cpuid(). In xen_cpuid() the mwait feature is indicated to be present or not by special casing the related cpuid leaf. Instead of delivering fake cpuid values use the cpu capability bit for mwait instead. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent b778d6b commit ea01598

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

arch/x86/xen/enlighten_pv.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ xen_running_on_version_or_later(unsigned int major, unsigned int minor)
167167

168168
static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0;
169169

170-
static __read_mostly unsigned int cpuid_leaf1_ecx_set_mask;
171170
static __read_mostly unsigned int cpuid_leaf5_ecx_val;
172171
static __read_mostly unsigned int cpuid_leaf5_edx_val;
173172

@@ -176,15 +175,13 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
176175
{
177176
unsigned maskebx = ~0;
178177
unsigned maskecx = ~0;
179-
unsigned setecx = 0;
180178
/*
181179
* Mask out inconvenient features, to try and disable as many
182180
* unsupported kernel subsystems as possible.
183181
*/
184182
switch (*ax) {
185183
case 1:
186184
maskecx = cpuid_leaf1_ecx_mask;
187-
setecx = cpuid_leaf1_ecx_set_mask;
188185
break;
189186

190187
case CPUID_MWAIT_LEAF:
@@ -210,7 +207,6 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
210207

211208
*bx &= maskebx;
212209
*cx &= maskecx;
213-
*cx |= setecx;
214210
}
215211
STACK_FRAME_NON_STANDARD(xen_cpuid); /* XEN_EMULATE_PREFIX */
216212

@@ -303,8 +299,6 @@ static void __init xen_init_cpuid_mask(void)
303299
/* Xen will set CR4.OSXSAVE if supported and not disabled by force */
304300
if ((cx & xsave_mask) != xsave_mask)
305301
cpuid_leaf1_ecx_mask &= ~xsave_mask; /* disable XSAVE & OSXSAVE */
306-
if (xen_check_mwait())
307-
cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32));
308302
}
309303

310304
static void __init xen_init_capabilities(void)
@@ -318,6 +312,11 @@ static void __init xen_init_capabilities(void)
318312

319313
if (!xen_initial_domain())
320314
setup_clear_cpu_cap(X86_FEATURE_ACPI);
315+
316+
if (xen_check_mwait())
317+
setup_force_cpu_cap(X86_FEATURE_MWAIT);
318+
else
319+
setup_clear_cpu_cap(X86_FEATURE_MWAIT);
321320
}
322321

323322
static void xen_set_debugreg(int reg, unsigned long val)

0 commit comments

Comments
 (0)