From 96a745cc270060712f9ea86c5f909ef443be0309 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Fri, 10 Jun 2016 19:11:12 +0100 Subject: [PATCH] xen/hvm: Fix advertisement 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.) Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Reviewed-by: Wei Liu --- xen/arch/x86/hvm/hvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index e664b34306..78db903e1c 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -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, -- 2.30.2