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

[Xen-changelog] [xen stable-4.7] x86/PV: also cover Dom0 in SPEC_CTRL / PRED_CMD emulation



commit 4bfe39fc2022b4ea6878696cda6a5594728d425d
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Mar 22 10:24:16 2018 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Mar 22 10:24:16 2018 +0100

    x86/PV: also cover Dom0 in SPEC_CTRL / PRED_CMD emulation
    
    Introduce a helper wrapping the pv_cpuid()-style domain_cpuid() /
    cpuid_count() (or alike) invocations, and use it instead of plain
    domain_cpuid() in MSR access emulation.
    
    Reported-by: Jason Andryuk <jandryuk@xxxxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/traps.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 5f804d58dc..e5884039bf 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -913,6 +913,17 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t 
sub_idx,
     return 1;
 }
 
+static void _domain_cpuid(struct domain *currd,
+                          unsigned int leaf, unsigned int subleaf,
+                          unsigned int *eax, unsigned int *ebx,
+                          unsigned int *ecx, unsigned int *edx)
+{
+    if ( !is_control_domain(currd) && !is_hardware_domain(currd) )
+        domain_cpuid(currd, leaf, subleaf, eax, ebx, ecx, edx);
+    else
+        cpuid_count(leaf, subleaf, eax, ebx, ecx, edx);
+}
+
 void pv_cpuid(struct cpu_user_regs *regs)
 {
     uint32_t leaf, subleaf, a, b, c, d;
@@ -927,10 +938,7 @@ void pv_cpuid(struct cpu_user_regs *regs)
     if ( cpuid_hypervisor_leaves(leaf, subleaf, &a, &b, &c, &d) )
         goto out;
 
-    if ( !is_control_domain(currd) && !is_hardware_domain(currd) )
-        domain_cpuid(currd, leaf, subleaf, &a, &b, &c, &d);
-    else
-        cpuid_count(leaf, subleaf, &a, &b, &c, &d);
+    _domain_cpuid(currd, leaf, subleaf, &a, &b, &c, &d);
 
     switch ( leaf )
     {
@@ -1099,11 +1107,7 @@ void pv_cpuid(struct cpu_user_regs *regs)
         break;
 
     case XSTATE_CPUID:
-
-        if ( !is_control_domain(currd) && !is_hardware_domain(currd) )
-            domain_cpuid(currd, 1, 0, &tmp, &tmp, &_ecx, &tmp);
-        else
-            _ecx = cpuid_ecx(1);
+        _domain_cpuid(currd, 1, 0, &tmp, &tmp, &_ecx, &tmp);
         _ecx &= pv_featureset[FEATURESET_1c];
 
         if ( !(_ecx & cpufeat_mask(X86_FEATURE_XSAVE)) || subleaf >= 63 )
@@ -2889,7 +2893,7 @@ static int emulate_privileged_op(struct cpu_user_regs 
*regs)
             goto fail;
 
         case MSR_SPEC_CTRL:
-            domain_cpuid(currd, 7, 0, &dummy, &dummy, &dummy, &edx);
+            _domain_cpuid(currd, 7, 0, &dummy, &dummy, &dummy, &edx);
             if ( !(edx & cpufeat_mask(X86_FEATURE_IBRSB)) )
                 goto fail; /* MSR available? */
 
@@ -2905,8 +2909,8 @@ static int emulate_privileged_op(struct cpu_user_regs 
*regs)
             break;
 
         case MSR_PRED_CMD:
-            domain_cpuid(currd, 7, 0, &dummy, &dummy, &dummy, &edx);
-            domain_cpuid(currd, 0x80000008, 0, &dummy, &ebx, &dummy, &dummy);
+            _domain_cpuid(currd, 7, 0, &dummy, &dummy, &dummy, &edx);
+            _domain_cpuid(currd, 0x80000008, 0, &dummy, &ebx, &dummy, &dummy);
             if ( !(edx & cpufeat_mask(X86_FEATURE_IBRSB)) &&
                  !(ebx & cpufeat_mask(X86_FEATURE_IBPB)) )
                 goto fail; /* MSR available? */
@@ -3054,7 +3058,7 @@ static int emulate_privileged_op(struct cpu_user_regs 
*regs)
             goto fail;
 
         case MSR_SPEC_CTRL:
-            domain_cpuid(currd, 7, 0, &dummy, &dummy, &dummy, &edx);
+            _domain_cpuid(currd, 7, 0, &dummy, &dummy, &dummy, &edx);
             if ( !(edx & cpufeat_mask(X86_FEATURE_IBRSB)) )
                 goto fail;
             regs->eax = v->arch.spec_ctrl;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.7

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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