ia64/xen-unstable

changeset 8610:334dc7e6a23f

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 <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Jan 14 22:17:33 2006 +0100 (2006-01-14)
parents 85d693e6f61a
children 1ccc28e075ba
files 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
line diff
     1.1 --- a/tools/libxc/xc_ia64_stubs.c	Sat Jan 14 21:26:40 2006 +0100
     1.2 +++ b/tools/libxc/xc_ia64_stubs.c	Sat Jan 14 22:17:33 2006 +0100
     1.3 @@ -665,15 +665,7 @@ int xc_vmx_build(int xc_handle,
     1.4          goto error_out;
     1.5      }
     1.6  
     1.7 -    if ( xc_vcpu_getcontext(xc_handle, domid, 0, ctxt) ){
     1.8 -        PERROR("Could not get vcpu context");
     1.9 -        goto error_out;
    1.10 -    }
    1.11 -
    1.12 -    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ) {
    1.13 -        ERROR("Domain is already constructed");
    1.14 -        goto error_out;
    1.15 -    }
    1.16 +    memset(ctxt, 0, sizeof(*ctxt));
    1.17  
    1.18      if ( setup_guest(xc_handle, domid, (unsigned long)memsize, image, image_size, 
    1.19                         control_evtchn, store_evtchn, store_mfn ) < 0 ){
     2.1 --- a/tools/libxc/xc_linux_build.c	Sat Jan 14 21:26:40 2006 +0100
     2.2 +++ b/tools/libxc/xc_linux_build.c	Sat Jan 14 22:17:33 2006 +0100
     2.3 @@ -33,10 +33,8 @@
     2.4  #endif
     2.5  
     2.6  #ifdef __ia64__
     2.7 -#define already_built(ctxt) (0)
     2.8  #define get_tot_pages xc_get_max_pages
     2.9  #else
    2.10 -#define already_built(ctxt) ((ctxt)->ctrlreg[3] != 0)
    2.11  #define get_tot_pages xc_get_tot_pages
    2.12  #endif
    2.13  
    2.14 @@ -800,17 +798,7 @@ int xc_linux_build(int xc_handle,
    2.15          goto error_out;
    2.16      }
    2.17  
    2.18 -    if ( xc_vcpu_getcontext(xc_handle, domid, 0, ctxt) )
    2.19 -    {
    2.20 -        PERROR("Could not get vcpu context");
    2.21 -        goto error_out;
    2.22 -    }
    2.23 -
    2.24 -    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) || already_built(ctxt) )
    2.25 -    {
    2.26 -        ERROR("Domain is already constructed");
    2.27 -        goto error_out;
    2.28 -    }
    2.29 +    memset(ctxt, 0, sizeof(*ctxt));
    2.30  
    2.31      if ( setup_guest(xc_handle, domid, image, image_size, 
    2.32                       initrd_gfd, initrd_size, nr_pages, 
    2.33 @@ -865,6 +853,8 @@ int xc_linux_build(int xc_handle,
    2.34      ctxt->user_regs.esi = vstartinfo_start;
    2.35      ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
    2.36  
    2.37 +    ctxt->flags = VGCF_IN_KERNEL;
    2.38 +
    2.39      /* FPU is set up to default initial state. */
    2.40      memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
    2.41  
     3.1 --- a/tools/libxc/xc_vmx_build.c	Sat Jan 14 21:26:40 2006 +0100
     3.2 +++ b/tools/libxc/xc_vmx_build.c	Sat Jan 14 22:17:33 2006 +0100
     3.3 @@ -651,18 +651,7 @@ int xc_vmx_build(int xc_handle,
     3.4          goto error_out;
     3.5      }
     3.6  
     3.7 -    if ( xc_vcpu_getcontext(xc_handle, domid, 0, ctxt) )
     3.8 -    {
     3.9 -        PERROR("Could not get vcpu context");
    3.10 -        goto error_out;
    3.11 -    }
    3.12 -
    3.13 -    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
    3.14 -         (ctxt->ctrlreg[3] != 0) )
    3.15 -    {
    3.16 -        ERROR("Domain is already constructed");
    3.17 -        goto error_out;
    3.18 -    }
    3.19 +    memset(ctxt, 0, sizeof(*ctxt));
    3.20  
    3.21      if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_pages,
    3.22                       ctxt, op.u.getdomaininfo.shared_info_frame, control_evtchn,
     4.1 --- a/xen/common/dom0_ops.c	Sat Jan 14 21:26:40 2006 +0100
     4.2 +++ b/xen/common/dom0_ops.c	Sat Jan 14 22:17:33 2006 +0100
     4.3 @@ -450,6 +450,10 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     4.4          if ( (v = d->vcpu[op->u.getvcpucontext.vcpu]) == NULL )
     4.5              goto getvcpucontext_out;
     4.6  
     4.7 +        ret = -ENODATA;
     4.8 +        if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
     4.9 +            goto getvcpucontext_out;
    4.10 +
    4.11          ret = -ENOMEM;
    4.12          if ( (c = xmalloc(struct vcpu_guest_context)) == NULL )
    4.13              goto getvcpucontext_out;
     5.1 --- a/xen/common/domain.c	Sat Jan 14 21:26:40 2006 +0100
     5.2 +++ b/xen/common/domain.c	Sat Jan 14 22:17:33 2006 +0100
     5.3 @@ -369,16 +369,17 @@ int set_info_guest(struct domain *d, dom
     5.4      if ( (vcpu >= MAX_VIRT_CPUS) || ((v = d->vcpu[vcpu]) == NULL) )
     5.5          return -EINVAL;
     5.6      
     5.7 -    if ( !test_bit(_DOMF_ctrl_pause, &d->domain_flags) )
     5.8 -        return -EINVAL;
     5.9 -
    5.10      if ( (c = xmalloc(struct vcpu_guest_context)) == NULL )
    5.11          return -ENOMEM;
    5.12  
    5.13 +    domain_pause(d);
    5.14 +
    5.15      rc = -EFAULT;
    5.16      if ( copy_from_user(c, setvcpucontext->ctxt, sizeof(*c)) == 0 )
    5.17          rc = arch_set_info_guest(v, c);
    5.18  
    5.19 +    domain_unpause(d);
    5.20 +
    5.21      xfree(c);
    5.22      return rc;
    5.23  }