xc_vcpu_getcontext() can no longer be called before a
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 14 Jan 2006 21:17:33 +0000 (22:17 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 14 Jan 2006 21:17:33 +0000 (22:17 +0100)
VCPU's context has been explicitly initialised.

Fix all the domain builders to no longer attempt this.
They really don't need to anyhow.

Signed-off-by: Keir Fraser <keir@xensource.com>
tools/libxc/xc_ia64_stubs.c
tools/libxc/xc_linux_build.c
tools/libxc/xc_vmx_build.c
xen/common/dom0_ops.c
xen/common/domain.c

index a10992be8e294f7a081707fec45617f06f562ea5..e742df3ba0fc8221b9ece9e0811d304dedd71cfe 100644 (file)
@@ -665,15 +665,7 @@ int xc_vmx_build(int xc_handle,
         goto error_out;
     }
 
-    if ( xc_vcpu_getcontext(xc_handle, domid, 0, ctxt) ){
-        PERROR("Could not get vcpu context");
-        goto error_out;
-    }
-
-    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ) {
-        ERROR("Domain is already constructed");
-        goto error_out;
-    }
+    memset(ctxt, 0, sizeof(*ctxt));
 
     if ( setup_guest(xc_handle, domid, (unsigned long)memsize, image, image_size, 
                        control_evtchn, store_evtchn, store_mfn ) < 0 ){
index 5312b42bbaf4f31be1cd0584fd721986a17dab37..23fc456554b9b91ee123fd04066d7d0c6947293b 100644 (file)
 #endif
 
 #ifdef __ia64__
-#define already_built(ctxt) (0)
 #define get_tot_pages xc_get_max_pages
 #else
-#define already_built(ctxt) ((ctxt)->ctrlreg[3] != 0)
 #define get_tot_pages xc_get_tot_pages
 #endif
 
@@ -800,17 +798,7 @@ int xc_linux_build(int xc_handle,
         goto error_out;
     }
 
-    if ( xc_vcpu_getcontext(xc_handle, domid, 0, ctxt) )
-    {
-        PERROR("Could not get vcpu context");
-        goto error_out;
-    }
-
-    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) || already_built(ctxt) )
-    {
-        ERROR("Domain is already constructed");
-        goto error_out;
-    }
+    memset(ctxt, 0, sizeof(*ctxt));
 
     if ( setup_guest(xc_handle, domid, image, image_size, 
                      initrd_gfd, initrd_size, nr_pages, 
@@ -865,6 +853,8 @@ int xc_linux_build(int xc_handle,
     ctxt->user_regs.esi = vstartinfo_start;
     ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
 
+    ctxt->flags = VGCF_IN_KERNEL;
+
     /* FPU is set up to default initial state. */
     memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
 
index ee18a4f8a219f98a68bcb2c77d072d756f206a14..222ec17207417915beb837a32089e2ea2f231dfe 100644 (file)
@@ -651,18 +651,7 @@ int xc_vmx_build(int xc_handle,
         goto error_out;
     }
 
-    if ( xc_vcpu_getcontext(xc_handle, domid, 0, ctxt) )
-    {
-        PERROR("Could not get vcpu context");
-        goto error_out;
-    }
-
-    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
-         (ctxt->ctrlreg[3] != 0) )
-    {
-        ERROR("Domain is already constructed");
-        goto error_out;
-    }
+    memset(ctxt, 0, sizeof(*ctxt));
 
     if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_pages,
                      ctxt, op.u.getdomaininfo.shared_info_frame, control_evtchn,
index 8e7754d84a2ebaaed542471e58718357d2079234..5b92dc75d3134014080f571319bfc4057cfbfbc7 100644 (file)
@@ -450,6 +450,10 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         if ( (v = d->vcpu[op->u.getvcpucontext.vcpu]) == NULL )
             goto getvcpucontext_out;
 
+        ret = -ENODATA;
+        if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
+            goto getvcpucontext_out;
+
         ret = -ENOMEM;
         if ( (c = xmalloc(struct vcpu_guest_context)) == NULL )
             goto getvcpucontext_out;
index 34f2ed86783daae01e5461c12c9b6446d06c2f8b..b0af3ebaf2a7458755e52f5cb2d7adda140f5ed9 100644 (file)
@@ -369,16 +369,17 @@ int set_info_guest(struct domain *d, dom0_setvcpucontext_t *setvcpucontext)
     if ( (vcpu >= MAX_VIRT_CPUS) || ((v = d->vcpu[vcpu]) == NULL) )
         return -EINVAL;
     
-    if ( !test_bit(_DOMF_ctrl_pause, &d->domain_flags) )
-        return -EINVAL;
-
     if ( (c = xmalloc(struct vcpu_guest_context)) == NULL )
         return -ENOMEM;
 
+    domain_pause(d);
+
     rc = -EFAULT;
     if ( copy_from_user(c, setvcpucontext->ctxt, sizeof(*c)) == 0 )
         rc = arch_set_info_guest(v, c);
 
+    domain_unpause(d);
+
     xfree(c);
     return rc;
 }