From: Wei Huang Subject: [PATCH][HVM] fix XSAVE leaf 0 EBX size calculation Date: Fri, 4 Feb 2011 11:49:28 -0600 Message-ID: <1296841768.2570.9.camel@weilaptop> Reply-To: wei.huang2@amd.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-7UYg4fg4bfIP4HzKiP2f" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: gang.wei@intel.com List-Id: xen-devel@lists.xenproject.org --=-7UYg4fg4bfIP4HzKiP2f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit 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 --=-7UYg4fg4bfIP4HzKiP2f Content-Disposition: attachment; filename="fix_xsave_leaf_0_size_bug.txt" Content-Type: text/plain; name="fix_xsave_leaf_0_size_bug.txt"; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-Description: fix_xsave_leaf_0_size_bug.txt 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 ) --=-7UYg4fg4bfIP4HzKiP2f Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-7UYg4fg4bfIP4HzKiP2f--