Skip to contentSkip to conversation

xen/hvm: Fix advertisment of available xstates following c/s c52319642

PATCH Applied Andrew Cooper 3 participants 4 messages Jun 10, 2016 – Jun 13, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/hvm: Fix advertisment of available xstates following c/s c52319642

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.)

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>

This is all going to be far less error prone when I have guest_has_$FEATURE(v) helpers which read the bits out of a flat array...

---
 xen/arch/x86/hvm/hvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/hvm.c +1 -1
index e664b34..78db903 100644
@@ -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,
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Andrew Cooper

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.)

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>

and

Quoted 22 lines

This is all going to be far less error prone when I have guest_has_$FEATURE(v) helpers which read the bits out of a flat array...

---
 xen/arch/x86/hvm/hvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/hvm.c +1 -1
index e664b34..78db903 100644
@@ -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,
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 10.06.16 at 20:17, <[email protected]> wrote:

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.)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Applied
#3 lore raw
Quoted 10 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 10.06.16 at 20:17, <[email protected]> wrote:

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.)

Pushed to staging and staging-4.7.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel