xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/libxc: Correct use of X86_XSS_MASK in guest xstate generation
@ 2016-04-19 17:27 Andrew Cooper
  2016-04-19 17:39 ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2016-04-19 17:27 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Ian Jackson, Wei Liu, Jan Beulich

c/s 75f9455e "tools/libxc: Calculate xstate cpuid leaf from guest information"
incorrectly inverted the shift and mask when using X86_XSS_MASK.  Luckily, the
mask is currently zero, avoiding incorrect calculations.

While adjusting this, use an explcit uint32_t cast rather than masking against
0xffffffff.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Jan Beulich <JBeulich@suse.com>

Submitted-from: A punt, on the Cam, during the the hackathon, because.
---
 tools/libxc/xc_cpuid_x86.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index 6d14904..84f4e08 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -460,7 +460,7 @@ static void xc_cpuid_config_xsave(xc_interface *xch,
     {
     case 0:
         /* EAX: low 32bits of xfeature_enabled_mask */
-        regs[0] = guest_xfeature_mask & 0xFFFFFFFF;
+        regs[0] = (uint32_t)guest_xfeature_mask;
         /* EDX: high 32bits of xfeature_enabled_mask */
         regs[3] = guest_xfeature_mask >> 32;
         /* ECX: max size required by all HW features */
@@ -487,8 +487,8 @@ static void xc_cpuid_config_xsave(xc_interface *xch,
 
         if ( test_bit(X86_FEATURE_XSAVES, info->featureset) )
         {
-            regs[2] = guest_xfeature_mask & X86_XSS_MASK & 0xFFFFFFFF;
-            regs[3] = (guest_xfeature_mask >> 32) & X86_XSS_MASK;
+            regs[2] = (uint32_t)(guest_xfeature_mask & X86_XSS_MASK);
+            regs[3] = (guest_xfeature_mask & X86_XSS_MASK) >> 32;
         }
         else
             regs[2] = regs[3] = 0;
-- 
1.9.1


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

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

* Re: [PATCH] tools/libxc: Correct use of X86_XSS_MASK in guest xstate generation
  2016-04-19 17:27 [PATCH] tools/libxc: Correct use of X86_XSS_MASK in guest xstate generation Andrew Cooper
@ 2016-04-19 17:39 ` Wei Liu
  2016-04-20 13:48   ` Ian Jackson
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Liu @ 2016-04-19 17:39 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Wei Liu, Ian Jackson, Jan Beulich, Xen-devel

On Tue, Apr 19, 2016 at 06:27:05PM +0100, Andrew Cooper wrote:
> c/s 75f9455e "tools/libxc: Calculate xstate cpuid leaf from guest information"
> incorrectly inverted the shift and mask when using X86_XSS_MASK.  Luckily, the
> mask is currently zero, avoiding incorrect calculations.
> 
> While adjusting this, use an explcit uint32_t cast rather than masking against
> 0xffffffff.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Jan Beulich <JBeulich@suse.com>
> 
> Submitted-from: A punt, on the Cam, during the the hackathon, because.


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

On a punt, too, because

> ---
>  tools/libxc/xc_cpuid_x86.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
> index 6d14904..84f4e08 100644
> --- a/tools/libxc/xc_cpuid_x86.c
> +++ b/tools/libxc/xc_cpuid_x86.c
> @@ -460,7 +460,7 @@ static void xc_cpuid_config_xsave(xc_interface *xch,
>      {
>      case 0:
>          /* EAX: low 32bits of xfeature_enabled_mask */
> -        regs[0] = guest_xfeature_mask & 0xFFFFFFFF;
> +        regs[0] = (uint32_t)guest_xfeature_mask;
>          /* EDX: high 32bits of xfeature_enabled_mask */
>          regs[3] = guest_xfeature_mask >> 32;
>          /* ECX: max size required by all HW features */
> @@ -487,8 +487,8 @@ static void xc_cpuid_config_xsave(xc_interface *xch,
>  
>          if ( test_bit(X86_FEATURE_XSAVES, info->featureset) )
>          {
> -            regs[2] = guest_xfeature_mask & X86_XSS_MASK & 0xFFFFFFFF;
> -            regs[3] = (guest_xfeature_mask >> 32) & X86_XSS_MASK;
> +            regs[2] = (uint32_t)(guest_xfeature_mask & X86_XSS_MASK);
> +            regs[3] = (guest_xfeature_mask & X86_XSS_MASK) >> 32;
>          }
>          else
>              regs[2] = regs[3] = 0;
> -- 
> 1.9.1
> 

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

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

* Re: [PATCH] tools/libxc: Correct use of X86_XSS_MASK in guest xstate generation
  2016-04-19 17:39 ` Wei Liu
@ 2016-04-20 13:48   ` Ian Jackson
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Jackson @ 2016-04-20 13:48 UTC (permalink / raw)
  To: Wei Liu; +Cc: Andrew Cooper, Jan Beulich, Xen-devel

Wei Liu writes ("Re: [PATCH] tools/libxc: Correct use of X86_XSS_MASK in guest xstate generation"):
> On Tue, Apr 19, 2016 at 06:27:05PM +0100, Andrew Cooper wrote:
> > Submitted-from: A punt, on the Cam, during the the hackathon, because.
> 
> Acked-by: Wei Liu <wei.liu2@citrix.com>
> Release-acked-by: Wei Liu <wei.liu2@citrix.com>
> 
> On a punt, too, because

Queued, thanks.

Ian.
(at his desk)

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

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

end of thread, other threads:[~2016-04-20 13:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-19 17:27 [PATCH] tools/libxc: Correct use of X86_XSS_MASK in guest xstate generation Andrew Cooper
2016-04-19 17:39 ` Wei Liu
2016-04-20 13:48   ` Ian Jackson

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