aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2011-02-06 17:26:31 +0000
committerKeir Fraser <keir@xen.org>2011-02-06 17:26:31 +0000
commitb6f72ecd9eae09e31970f051d9921a70f9e36e84 (patch)
tree12968993ea44bf8a6985f2841985c79eefae00cb
parent20a91fe64a70d77c1331b11512ec889c0eea1130 (diff)
downloadxen-b6f72ecd9eae09e31970f051d9921a70f9e36e84.tar.gz
xen-b6f72ecd9eae09e31970f051d9921a70f9e36e84.tar.bz2
xen-b6f72ecd9eae09e31970f051d9921a70f9e36e84.zip
hvm: fix XSAVE leaf 0 EBX size calculation
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>
-rw-r--r--xen/arch/x86/hvm/hvm.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 23db7de282..da78d1c385 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2222,10 +2222,12 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
/* 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 )