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

[Xen-changelog] [xen-unstable] x86/hvm: No need to arch_set_info_guest() before restoring per-vcpu HVM state.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1327227603 0
# Node ID eca719b621a1201528bfec25fb1786ec21c0c9d3
# Parent  80fdf2182bc62ca358ba2f1a3513b47a4f8d9dfd
x86/hvm: No need to arch_set_info_guest() before restoring per-vcpu HVM state.

Signed-off-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 80fdf2182bc6 -r eca719b621a1 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Sat Jan 21 17:15:40 2012 +0000
+++ b/xen/arch/x86/domain.c     Sun Jan 22 10:20:03 2012 +0000
@@ -709,13 +709,7 @@
 #undef xen_vcpu_guest_context
 #endif
 
-/*
- * This is called by do_domctl(XEN_DOMCTL_setvcpucontext, ...), boot_vcpu(),
- * and hvm_load_cpu_ctxt().
- *
- * Note that for a HVM guest NULL may be passed for the context pointer,
- * meaning "use current values".
- */
+/* Called by XEN_DOMCTL_setvcpucontext and VCPUOP_initialise. */
 int arch_set_info_guest(
     struct vcpu *v, vcpu_guest_context_u c)
 {
@@ -735,7 +729,7 @@
 #else
 #define c(fld) (c.nat->fld)
 #endif
-    flags = c.nat ? c(flags) : v->arch.vgc_flags;
+    flags = c(flags);
 
     if ( !is_hvm_vcpu(v) )
     {
@@ -791,28 +785,25 @@
 
     v->arch.vgc_flags = flags;
 
-    if ( c.nat )
+    memcpy(v->arch.fpu_ctxt, &c.nat->fpu_ctxt, sizeof(c.nat->fpu_ctxt));
+    if ( !compat )
     {
-        memcpy(v->arch.fpu_ctxt, &c.nat->fpu_ctxt, sizeof(c.nat->fpu_ctxt));
-        if ( !compat )
-        {
-            memcpy(&v->arch.user_regs, &c.nat->user_regs, 
sizeof(c.nat->user_regs));
-            if ( !is_hvm_vcpu(v) )
-                memcpy(v->arch.pv_vcpu.trap_ctxt, c.nat->trap_ctxt,
-                       sizeof(c.nat->trap_ctxt));
-        }
+        memcpy(&v->arch.user_regs, &c.nat->user_regs, 
sizeof(c.nat->user_regs));
+        if ( !is_hvm_vcpu(v) )
+            memcpy(v->arch.pv_vcpu.trap_ctxt, c.nat->trap_ctxt,
+                   sizeof(c.nat->trap_ctxt));
+    }
 #ifdef CONFIG_COMPAT
-        else
-        {
-            XLAT_cpu_user_regs(&v->arch.user_regs, &c.cmp->user_regs);
-            for ( i = 0; i < ARRAY_SIZE(c.cmp->trap_ctxt); ++i )
-                XLAT_trap_info(v->arch.pv_vcpu.trap_ctxt + i,
-                               c.cmp->trap_ctxt + i);
-        }
+    else
+    {
+        XLAT_cpu_user_regs(&v->arch.user_regs, &c.cmp->user_regs);
+        for ( i = 0; i < ARRAY_SIZE(c.cmp->trap_ctxt); ++i )
+            XLAT_trap_info(v->arch.pv_vcpu.trap_ctxt + i,
+                           c.cmp->trap_ctxt + i);
+    }
 #endif
-        for ( i = 0; i < ARRAY_SIZE(v->arch.debugreg); ++i )
-            v->arch.debugreg[i] = c(debugreg[i]);
-    }
+    for ( i = 0; i < ARRAY_SIZE(v->arch.debugreg); ++i )
+        v->arch.debugreg[i] = c(debugreg[i]);
 
     v->arch.user_regs.eflags |= 2;
 
diff -r 80fdf2182bc6 -r eca719b621a1 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Sat Jan 21 17:15:40 2012 +0000
+++ b/xen/arch/x86/hvm/hvm.c    Sun Jan 22 10:20:03 2012 +0000
@@ -670,7 +670,7 @@
 
 static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
 {
-    int vcpuid, rc;
+    int vcpuid;
     struct vcpu *v;
     struct hvm_hw_cpu ctxt;
     struct segment_register seg;
@@ -684,11 +684,6 @@
         return -EINVAL;
     }
 
-    /* Need to init this vcpu before loading its contents */
-    rc = boot_vcpu(d, vcpuid, NULL);
-    if ( (rc != 0) && (rc != -EEXIST) )
-        return rc;
-
     if ( hvm_load_entry(CPU, h, &ctxt) != 0 ) 
         return -EINVAL;
 
diff -r 80fdf2182bc6 -r eca719b621a1 xen/common/compat/domain.c
--- a/xen/common/compat/domain.c        Sat Jan 21 17:15:40 2012 +0000
+++ b/xen/common/compat/domain.c        Sun Jan 22 10:20:03 2012 +0000
@@ -46,7 +46,9 @@
             break;
         }
 
-        rc = boot_vcpu(d, vcpuid, cmp_ctxt);
+        domain_lock(d);
+        rc = v->is_initialised ? -EEXIST : arch_set_info_guest(v, cmp_ctxt);
+        domain_unlock(d);
 
         xfree(cmp_ctxt);
         break;
diff -r 80fdf2182bc6 -r eca719b621a1 xen/common/domain.c
--- a/xen/common/domain.c       Sat Jan 21 17:15:40 2012 +0000
+++ b/xen/common/domain.c       Sun Jan 22 10:20:03 2012 +0000
@@ -778,18 +778,6 @@
         domain_unpause(d);
 }
 
-int boot_vcpu(struct domain *d, int vcpuid, vcpu_guest_context_u ctxt)
-{
-    struct vcpu *v = d->vcpu[vcpuid];
-    int rc;
-
-    domain_lock(d);
-    rc = v->is_initialised ? -EEXIST : arch_set_info_guest(v, ctxt);
-    domain_unlock(d);
-
-    return rc;
-}
-
 void vcpu_reset(struct vcpu *v)
 {
     struct domain *d = v->domain;
@@ -847,7 +835,9 @@
             return -EFAULT;
         }
 
-        rc = boot_vcpu(d, vcpuid, ctxt);
+        domain_lock(d);
+        rc = v->is_initialised ? -EEXIST : arch_set_info_guest(v, ctxt);
+        domain_unlock(d);
 
         free_vcpu_guest_context(ctxt);
         break;
diff -r 80fdf2182bc6 -r eca719b621a1 xen/include/xen/domain.h
--- a/xen/include/xen/domain.h  Sat Jan 21 17:15:40 2012 +0000
+++ b/xen/include/xen/domain.h  Sun Jan 22 10:20:03 2012 +0000
@@ -12,8 +12,6 @@
 
 struct vcpu *alloc_vcpu(
     struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
-int boot_vcpu(
-    struct domain *d, int vcpuid, vcpu_guest_context_u ctxt);
 struct vcpu *alloc_dom0_vcpu0(void);
 void vcpu_reset(struct vcpu *v);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
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®.