Commit 40f4ac0b authored by Juergen Gross's avatar Juergen Gross

x86/xen: fix xsave capability setting

Commit 690b7f10b4f9f ("x86/xen: use capabilities instead of fake cpuid
values for xsave") introduced a regression as it tried to make use of
the fixup feature before it being available.

Fall back to the old variant testing via cpuid().
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent 3dbd8204
...@@ -277,26 +277,15 @@ static bool __init xen_check_mwait(void) ...@@ -277,26 +277,15 @@ static bool __init xen_check_mwait(void)
static bool __init xen_check_xsave(void) static bool __init xen_check_xsave(void)
{ {
unsigned int err, eax, edx; unsigned int cx, xsave_mask;
/* cx = cpuid_ecx(1);
* Xen 4.0 and older accidentally leaked the host XSAVE flag into guest
* view, despite not being able to support guests using the xsave_mask = (1 << (X86_FEATURE_XSAVE % 32)) |
* functionality. Probe for the actual availability of XSAVE by seeing (1 << (X86_FEATURE_OSXSAVE % 32));
* whether xgetbv executes successfully or raises #UD.
*/ /* Xen will set CR4.OSXSAVE if supported and not disabled by force */
asm volatile("1: .byte 0x0f,0x01,0xd0\n\t" /* xgetbv */ return (cx & xsave_mask) == xsave_mask;
"xor %[err], %[err]\n"
"2:\n\t"
".pushsection .fixup,\"ax\"\n\t"
"3: movl $1,%[err]\n\t"
"jmp 2b\n\t"
".popsection\n\t"
_ASM_EXTABLE(1b, 3b)
: [err] "=r" (err), "=a" (eax), "=d" (edx)
: "c" (0));
return err == 0;
} }
static void __init xen_init_capabilities(void) static void __init xen_init_capabilities(void)
...@@ -317,10 +306,7 @@ static void __init xen_init_capabilities(void) ...@@ -317,10 +306,7 @@ static void __init xen_init_capabilities(void)
else else
setup_clear_cpu_cap(X86_FEATURE_MWAIT); setup_clear_cpu_cap(X86_FEATURE_MWAIT);
if (xen_check_xsave()) { if (!xen_check_xsave()) {
setup_force_cpu_cap(X86_FEATURE_XSAVE);
setup_force_cpu_cap(X86_FEATURE_OSXSAVE);
} else {
setup_clear_cpu_cap(X86_FEATURE_XSAVE); setup_clear_cpu_cap(X86_FEATURE_XSAVE);
setup_clear_cpu_cap(X86_FEATURE_OSXSAVE); setup_clear_cpu_cap(X86_FEATURE_OSXSAVE);
} }
......
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