diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index ea9bfc51b6..ab1a48ff90 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -770,7 +770,8 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, * damage itself. * * - Enlightened CPUID or CPUID faulting available: - * Xen can fully control what is seen here. Guest kernels need + * Xen can fully control what is seen here. When the guest has + * been configured to have XSAVE available, guest kernels need * to see the leaked OSXSAVE via the enlightened path, but * guest userspace and the native is given architectural * behaviour. @@ -780,7 +781,8 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, */ /* OSXSAVE clear in policy. Fast-forward CR4 back in. */ if ( (v->arch.pv.ctrlreg[4] & X86_CR4_OSXSAVE) || - (regs->entry_vector == TRAP_invalid_op && + (p->basic.xsave && + regs->entry_vector == TRAP_invalid_op && guest_kernel_mode(v, regs) && (read_cr4() & X86_CR4_OSXSAVE)) ) res->c |= cpufeat_mask(X86_FEATURE_OSXSAVE);