xen/hvm: Fix advertisement of available xstates following c/s c52319642
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 10 Jun 2016 18:11:12 +0000 (19:11 +0100)
committerWei Liu <wei.liu2@citrix.com>
Mon, 13 Jun 2016 10:39:14 +0000 (11:39 +0100)
PKU lives in CPUID.7[0].ECX, not EBX.  This causes hardware with BMI1 to
accidentally advertise PKU in CPUID.0xD[0].EAX.  Any OS which proceeds to
blindly write this into %xcr0 takes a #GP fault.  (Experimentally, Windows
Vista 32bit falls into this category.)

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/hvm/hvm.c

index e664b34306295ecbfde56d0a2d49a31d04dc05b0..78db903e1c175a0371c88a9db4d21f9e55f64fb0 100644 (file)
@@ -3466,7 +3466,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
                                   xstate_sizes[_XSTATE_BNDCSR]);
             }
 
-            if ( _ebx & cpufeat_mask(X86_FEATURE_PKU) )
+            if ( _ecx & cpufeat_mask(X86_FEATURE_PKU) )
             {
                 xfeature_mask |= XSTATE_PKRU;
                 xstate_size = max(xstate_size,