diff -r 5fe770c8a8a3 xen/arch/x86/traps.c --- a/xen/arch/x86/traps.c Tue Sep 06 15:49:40 2011 +0100 +++ b/xen/arch/x86/traps.c Wed Sep 07 02:09:12 2011 +0800 @@ -770,6 +770,30 @@ static void pv_cpuid(struct cpu_user_reg { if ( !cpuid_hypervisor_leaves(a, c, &a, &b, &c, &d) ) domain_cpuid(current->domain, a, c, &a, &b, &c, &d); + + switch ( a ) + { + case 0xd: + { + unsigned int sub_leaf, _eax, _ebx, _ecx, _edx; + /* EBX value of main leaf 0 depends on enabled xsave features */ + if ( c == 0 && current->arch.xcr0 ) + { + /* reset EBX to default value first */ + b = XSTATE_AREA_MIN_SIZE; + for ( sub_leaf = 2; sub_leaf < 64; sub_leaf++ ) + { + if ( !(current->arch.xcr0 & (1ULL << sub_leaf)) ) + continue; + domain_cpuid(current->domain, a, c, &_eax, &_ebx, &_ecx, + &_edx); + if ( (_eax + _ebx) > b ) + b = _eax + _ebx; + } + } + break; + } + } goto out; }