From: kaf24@firebug.cl.cam.ac.uk Date: Sat, 14 Jan 2006 21:17:33 +0000 (+0100) Subject: xc_vcpu_getcontext() can no longer be called before a X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16541^2~34 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f59958dd8242e3bafdc7c03623b48222eae5f9de;p=xen.git xc_vcpu_getcontext() can no longer be called before a 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 --- diff --git a/tools/libxc/xc_ia64_stubs.c b/tools/libxc/xc_ia64_stubs.c index a10992be8e..e742df3ba0 100644 --- a/tools/libxc/xc_ia64_stubs.c +++ b/tools/libxc/xc_ia64_stubs.c @@ -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 ){ diff --git a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c index 5312b42bba..23fc456554 100644 --- a/tools/libxc/xc_linux_build.c +++ b/tools/libxc/xc_linux_build.c @@ -33,10 +33,8 @@ #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)); diff --git a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c index ee18a4f8a2..222ec17207 100644 --- a/tools/libxc/xc_vmx_build.c +++ b/tools/libxc/xc_vmx_build.c @@ -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, diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index 8e7754d84a..5b92dc75d3 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -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; diff --git a/xen/common/domain.c b/xen/common/domain.c index 34f2ed8678..b0af3ebaf2 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -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; }