[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] x86/HVM: don't calculate XSTATE area sizes in software



commit 95dc05bb04b0737181a27f9469c69ee0e902f350
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Jun 2 09:41:07 2016 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jun 2 09:41:07 2016 +0200

    x86/HVM: don't calculate XSTATE area sizes in software
    
    Use hardware output instead, bringing HVM behavior in line with PV one
    in this regard.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Release-acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c | 47 ++++++++++++++++++-----------------------------
 1 file changed, 18 insertions(+), 29 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 79abdb6..bb98051 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3362,7 +3362,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, 
unsigned int *ebx,
 
     switch ( input )
     {
-        unsigned int sub_leaf, _eax, _ebx, _ecx, _edx;
+        unsigned int _ecx, _edx;
 
     case 0x1:
         /* Fix up VLAPIC details. */
@@ -3440,42 +3440,31 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, 
unsigned int *ebx,
             *eax = *ebx = *ecx = *edx = 0;
             break;
         }
-        /* EBX value of main leaf 0 depends on enabled xsave features */
-        if ( count == 0 && v->arch.xcr0 ) 
-        {
-            /* reset EBX to default value first */
-            *ebx = XSTATE_AREA_MIN_SIZE; 
-            for ( sub_leaf = 2; sub_leaf < 63; sub_leaf++ )
-            {
-                if ( !(v->arch.xcr0 & (1ULL << sub_leaf)) )
-                    continue;
-                domain_cpuid(d, input, sub_leaf, &_eax, &_ebx, &_ecx, 
-                             &_edx);
-                if ( (_eax + _ebx) > *ebx )
-                    *ebx = _eax + _ebx;
-            }
-        }
-
-        if ( count == 1 )
+        switch ( count )
         {
+        case 0:
+            /*
+             * Always read CPUID[0xD,0].EBX from hardware, rather than domain
+             * policy.  It varies with enabled xstate, and the correct xcr0 is
+             * in context.
+             */
+            cpuid_count(input, count, &dummy, ebx, &dummy, &dummy);
+            break;
+        case 1:
             *eax &= hvm_featureset[FEATURESET_Da1];
 
             if ( *eax & cpufeat_mask(X86_FEATURE_XSAVES) )
             {
-                uint64_t xfeatures = v->arch.xcr0 | v->arch.hvm_vcpu.msr_xss;
-
-                *ebx = XSTATE_AREA_MIN_SIZE;
-                if ( xfeatures & ~XSTATE_FP_SSE )
-                    for ( sub_leaf = 2; sub_leaf < 63; sub_leaf++ )
-                        if ( xfeatures & (1ULL << sub_leaf) )
-                        {
-                            if ( test_bit(sub_leaf, &xstate_align) )
-                                *ebx = ROUNDUP(*ebx, 64);
-                            *ebx += xstate_sizes[sub_leaf];
-                        }
+                /*
+                 * Always read CPUID[0xD,1].EBX from hardware, rather than
+                 * domain policy.  It varies with enabled xstate, and the
+                 * correct xcr0/xss are in context.
+                 */
+                cpuid_count(input, count, &dummy, ebx, &dummy, &dummy);
             }
             else
                 *ebx = *ecx = *edx = 0;
+            break;
         }
         break;
 
--
generated by git-patchbot for /home/xen/git/xen.git#master

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.