ia64/xen-unstable

changeset 15202:36959baf05c0

Cleanups to map_vcpu_info.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu May 24 13:42:16 2007 +0100 (2007-05-24)
parents 1e418f7e0212
children 7ff65f888804
files xen/arch/x86/domain.c xen/include/public/vcpu.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Thu May 24 13:34:19 2007 +0100
     1.2 +++ b/xen/arch/x86/domain.c	Thu May 24 13:42:16 2007 +0100
     1.3 @@ -489,7 +489,7 @@ void arch_domain_destroy(struct domain *
     1.4  {
     1.5      struct vcpu *v;
     1.6  
     1.7 -    for_each_vcpu( d, v )
     1.8 +    for_each_vcpu ( d, v )
     1.9          unmap_vcpu_info(v);
    1.10  
    1.11      if ( is_hvm_domain(d) )
    1.12 @@ -754,7 +754,7 @@ unmap_vcpu_info(struct vcpu *v)
    1.13          return;
    1.14  
    1.15      mfn = v->vcpu_info_mfn;
    1.16 -    unmap_domain_page_global( v->vcpu_info );
    1.17 +    unmap_domain_page_global(v->vcpu_info);
    1.18  
    1.19      v->vcpu_info = shared_info_addr(d, vcpu_info[v->vcpu_id]);
    1.20      v->vcpu_info_mfn = INVALID_MFN;
    1.21 @@ -779,8 +779,11 @@ map_vcpu_info(struct vcpu *v, unsigned l
    1.22      if ( offset > (PAGE_SIZE - sizeof(vcpu_info_t)) )
    1.23          return -EINVAL;
    1.24  
    1.25 -    if ( mfn == INVALID_MFN ||
    1.26 -         v->vcpu_info_mfn != INVALID_MFN )
    1.27 +    if ( v->vcpu_info_mfn != INVALID_MFN )
    1.28 +        return -EINVAL;
    1.29 +
    1.30 +    /* Run this command on yourself or on other offline VCPUS. */
    1.31 +    if ( (v != current) && !test_bit(_VPF_down, &v->pause_flags) )
    1.32          return -EINVAL;
    1.33  
    1.34      mfn = gmfn_to_mfn(d, mfn);
    1.35 @@ -802,19 +805,22 @@ map_vcpu_info(struct vcpu *v, unsigned l
    1.36      v->vcpu_info = new_info;
    1.37      v->vcpu_info_mfn = mfn;
    1.38  
    1.39 -    /* make sure all the pointers are uptodate before setting pending */
    1.40 +    /* Set new vcpu_info pointer /before/ setting pending flags. */
    1.41      wmb();
    1.42  
    1.43 -    /* Mark everything as being pending just to make sure nothing gets
    1.44 -       lost.  The domain will get a spurious event, but it can
    1.45 -       cope. */
    1.46 +    /*
    1.47 +     * Mark everything as being pending just to make sure nothing gets
    1.48 +     * lost.  The domain will get a spurious event, but it can cope.
    1.49 +     */
    1.50      vcpu_info(v, evtchn_upcall_pending) = 1;
    1.51      for ( i = 0; i < BITS_PER_GUEST_LONG(d); i++ )
    1.52          set_bit(i, vcpu_info_addr(v, evtchn_pending_sel));
    1.53  
    1.54 -    /* Only bother to update time for the current vcpu.  If we're
    1.55 +    /*
    1.56 +     * Only bother to update time for the current vcpu.  If we're
    1.57       * operating on another vcpu, then it had better not be running at
    1.58 -     * the time. */
    1.59 +     * the time.
    1.60 +     */
    1.61      if ( v == current )
    1.62           update_vcpu_system_time(v);
    1.63  
     2.1 --- a/xen/include/public/vcpu.h	Thu May 24 13:34:19 2007 +0100
     2.2 +++ b/xen/include/public/vcpu.h	Thu May 24 13:42:16 2007 +0100
     2.3 @@ -172,8 +172,9 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_set_singles
     2.4   */
     2.5  #define VCPUOP_register_vcpu_info   10  /* arg == struct vcpu_info */
     2.6  struct vcpu_register_vcpu_info {
     2.7 -    xen_pfn_t mfn;              /* mfn of page to place vcpu_info */
     2.8 -    uint32_t offset;            /* offset within page */
     2.9 +    uint64_t mfn;    /* mfn of page to place vcpu_info */
    2.10 +    uint32_t offset; /* offset within page */
    2.11 +    uint32_t rsvd;   /* unused */
    2.12  };
    2.13  typedef struct vcpu_register_vcpu_info vcpu_register_vcpu_info_t;
    2.14  DEFINE_XEN_GUEST_HANDLE(vcpu_register_vcpu_info_t);