All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][HVM] fix XSAVE leaf 0 EBX size calculation
@ 2011-02-04 17:49 Wei Huang
  2011-02-09  5:32 ` [PATCH] x86: reduce magic number usage in XSAVE code (RE: [PATCH][HVM] fix XSAVE leaf 0 EBX size calculation) Wei, Gang
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Huang @ 2011-02-04 17:49 UTC (permalink / raw)
  To: xen-devel; +Cc: gang.wei

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

Fixes a size calculation bug when enabled bits in XFEATURE_MASK (xcr0)
aren't contiguous.

Current for_loop will stop when xcr0 feature bit is 0. But in reality,
the bits can be non-contiguous. One example is that LWP is bit 62 on AMD
platform. This patch iterates through all bits to calculate the size for
enabled features.

Signed-off-by: Wei Huang <wei.huang2@amd.com>

 

[-- Attachment #2: fix_xsave_leaf_0_size_bug.txt --]
[-- Type: text/plain, Size: 884 bytes --]

diff -r fc84efa61ef1 -r d42732f29bed xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c	Wed Feb 02 15:26:29 2011 -0600
+++ b/xen/arch/x86/hvm/hvm.c	Wed Feb 02 16:13:03 2011 -0600
@@ -2222,10 +2222,12 @@
         /* EBX value of main leaf 0 depends on enabled xsave features */
         if ( count == 0 && v->arch.xcr0 ) 
         {
-            for ( sub_leaf = 2; 
-                  (sub_leaf < 64) && (v->arch.xcr0 & (1ULL << sub_leaf));
-                  sub_leaf++ ) 
+            /* reset EBX to default value first */
+            *ebx = 576; 
+            for ( sub_leaf = 2; sub_leaf < 64; sub_leaf++ )
             {
+                if ( !(v->arch.xcr0 & (1ULL << sub_leaf)) )
+                    continue;
                 domain_cpuid(v->domain, input, sub_leaf, &_eax, &_ebx, &_ecx, 
                              &_edx);
                 if ( (_eax + _ebx) > *ebx )

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

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

end of thread, other threads:[~2011-02-09 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-04 17:49 [PATCH][HVM] fix XSAVE leaf 0 EBX size calculation Wei Huang
2011-02-09  5:32 ` [PATCH] x86: reduce magic number usage in XSAVE code (RE: [PATCH][HVM] fix XSAVE leaf 0 EBX size calculation) Wei, Gang
2011-02-09 16:41   ` Wei Huang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.