xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.7] xen/hvm: Fix advertisment of available xstates following c/s c52319642
@ 2016-06-10 18:17 Andrew Cooper
  2016-06-10 18:29 ` Wei Liu
  2016-06-13  9:48 ` Jan Beulich
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Cooper @ 2016-06-10 18:17 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich

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>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>

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

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index e664b34..78db903 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.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH for-4.7] xen/hvm: Fix advertisment of available xstates following c/s c52319642
  2016-06-10 18:17 [PATCH for-4.7] xen/hvm: Fix advertisment of available xstates following c/s c52319642 Andrew Cooper
@ 2016-06-10 18:29 ` Wei Liu
  2016-06-13  9:48 ` Jan Beulich
  1 sibling, 0 replies; 4+ messages in thread
From: Wei Liu @ 2016-06-10 18:29 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Wei Liu, Jan Beulich, Xen-devel

On Fri, Jun 10, 2016 at 07:17:43PM +0100, Andrew Cooper 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.)
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> 

Reviewed-by: Wei Liu <wei.liu2@citrix.com>

and

Release-acked-by: Wei Liu <wei.liu2@citrix.com>

> 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(-)
> 
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index e664b34..78db903 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.1.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH for-4.7] xen/hvm: Fix advertisment of available xstates following c/s c52319642
  2016-06-10 18:17 [PATCH for-4.7] xen/hvm: Fix advertisment of available xstates following c/s c52319642 Andrew Cooper
  2016-06-10 18:29 ` Wei Liu
@ 2016-06-13  9:48 ` Jan Beulich
  2016-06-13 10:42   ` Wei Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2016-06-13  9:48 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Wei Liu, Xen-devel

>>> On 10.06.16 at 20:17, <andrew.cooper3@citrix.com> 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.)
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH for-4.7] xen/hvm: Fix advertisment of available xstates following c/s c52319642
  2016-06-13  9:48 ` Jan Beulich
@ 2016-06-13 10:42   ` Wei Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2016-06-13 10:42 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Andrew Cooper, Wei Liu, Xen-devel

On Mon, Jun 13, 2016 at 03:48:45AM -0600, Jan Beulich wrote:
> >>> On 10.06.16 at 20:17, <andrew.cooper3@citrix.com> 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.)
> > 
> > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 

Pushed to staging and staging-4.7.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-13 10:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-10 18:17 [PATCH for-4.7] xen/hvm: Fix advertisment of available xstates following c/s c52319642 Andrew Cooper
2016-06-10 18:29 ` Wei Liu
2016-06-13  9:48 ` Jan Beulich
2016-06-13 10:42   ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).