direct-io.hg

changeset 14315:26e034395b8e

[XEN] Shadow: be more explicit in assuming that d->vcpu[0] is valid
Signed-off-by: Tim Deegan <Tim.Deegan@xensourc.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Fri Mar 09 12:10:29 2007 +0000 (2007-03-09)
parents 101a1ccfc3f7
children bae81f7013a6
files xen/arch/x86/mm/shadow/common.c xen/include/asm-x86/paging.h
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/common.c	Fri Mar 09 11:45:49 2007 +0000
     1.2 +++ b/xen/arch/x86/mm/shadow/common.c	Fri Mar 09 12:10:29 2007 +0000
     1.3 @@ -802,7 +802,7 @@ void shadow_prealloc(struct domain *d, u
     1.4      v = current;
     1.5      if ( v->domain != d )
     1.6          v = d->vcpu[0];
     1.7 -    ASSERT(v != NULL);
     1.8 +    ASSERT(v != NULL); /* Shouldn't have enabled shadows if we've no vcpus  */
     1.9  
    1.10      /* Stage one: walk the list of pinned pages, unpinning them */
    1.11      perfc_incrc(shadow_prealloc_1);
    1.12 @@ -861,7 +861,9 @@ static void shadow_blow_tables(struct do
    1.13      struct vcpu *v = d->vcpu[0];
    1.14      mfn_t smfn;
    1.15      int i;
    1.16 -    
    1.17 +
    1.18 +    ASSERT(v != NULL);
    1.19 +
    1.20      /* Pass one: unpin all pinned pages */
    1.21      list_for_each_backwards_safe(l,t, &d->arch.paging.shadow.pinned_shadows)
    1.22      {
    1.23 @@ -2384,6 +2386,7 @@ int shadow_enable(struct domain *d, u32 
    1.24  
    1.25      /* Sanity check the arguments */
    1.26      if ( (d == current->domain) ||
    1.27 +         d->vcpu[0] == NULL ||
    1.28           shadow_mode_enabled(d) ||
    1.29           ((mode & PG_translate) && !(mode & PG_refcounts)) ||
    1.30           ((mode & PG_external) && !(mode & PG_translate)) )
    1.31 @@ -2993,6 +2996,13 @@ int shadow_domctl(struct domain *d,
    1.32          return 0;
    1.33      }
    1.34  
    1.35 +    if ( unlikely(d->vcpu[0] == NULL) )
    1.36 +    {
    1.37 +        SHADOW_ERROR("Shadow op on a domain (%u) with no vcpus\n",
    1.38 +                     d->domain_id);
    1.39 +        return -EINVAL;
    1.40 +    }
    1.41 +
    1.42      switch ( sc->op )
    1.43      {
    1.44      case XEN_DOMCTL_SHADOW_OP_OFF:
     2.1 --- a/xen/include/asm-x86/paging.h	Fri Mar 09 11:45:49 2007 +0000
     2.2 +++ b/xen/include/asm-x86/paging.h	Fri Mar 09 12:10:29 2007 +0000
     2.3 @@ -273,7 +273,7 @@ static inline void paging_write_p2m_entr
     2.4      struct vcpu *v = current;
     2.5      if ( v->domain != d )
     2.6          v = d->vcpu[0];
     2.7 -    if ( likely(paging_mode_enabled(d) && v->arch.paging.mode != NULL) )
     2.8 +    if ( likely(v && paging_mode_enabled(d) && v->arch.paging.mode != NULL) )
     2.9      {
    2.10          return v->arch.paging.mode->write_p2m_entry(v, gfn, p, new, level);
    2.11      }