Only perform xsetbv on behalf of the guest if it actually has it
enabled.

Fixes: 427ff407c1ae ("x86: Check for availability of xsetbv before
executing it for the guest")

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/x86/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hypervisor/arch/x86/vmx.c b/hypervisor/arch/x86/vmx.c
index 131b869..f832612 100644
--- a/hypervisor/arch/x86/vmx.c
+++ b/hypervisor/arch/x86/vmx.c
@@ -1041,7 +1041,7 @@ static bool vmx_handle_xsetbv(void)
 {
        union registers *guest_regs = &this_cpu_data()->guest_regs;
 
-       if (cpuid_ecx(1, 0) & X86_FEATURE_XSAVE &&
+       if (vcpu_vendor_get_guest_cr4() & X86_CR4_OSXSAVE &&
            guest_regs->rax & X86_XCR0_FP &&
            (guest_regs->rax & ~cpuid_eax(0x0d, 0)) == 0 &&
             guest_regs->rcx == 0 && guest_regs->rdx == 0) {
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to