ia64/xen-unstable

changeset 19137:6fe44eb28f52

x86-64: use MFN also for next_shadow link

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jan 30 11:09:44 2009 +0000 (2009-01-30)
parents 4a2f93fb03eb
children 162cdb596b9a
files xen/arch/x86/mm/shadow/common.c xen/include/asm-x86/mm.h
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/common.c	Fri Jan 30 11:08:06 2009 +0000
     1.2 +++ b/xen/arch/x86/mm/shadow/common.c	Fri Jan 30 11:09:44 2009 +0000
     1.3 @@ -1489,6 +1489,22 @@ static __init int shadow_blow_tables_key
     1.4  __initcall(shadow_blow_tables_keyhandler_init);
     1.5  #endif /* !NDEBUG */
     1.6  
     1.7 +#ifdef __i386__
     1.8 +# define next_shadow(pg) ((pg)->next_shadow)
     1.9 +# define set_next_shadow(pg, n) ((void)((pg)->next_shadow = (n)))
    1.10 +#else
    1.11 +static inline struct shadow_page_info *
    1.12 +next_shadow(const struct shadow_page_info *sp)
    1.13 +{
    1.14 +    return sp->next_shadow ? mfn_to_shadow_page(_mfn(sp->next_shadow)) : NULL;
    1.15 +}
    1.16 +static inline void
    1.17 +set_next_shadow(struct shadow_page_info *sp, struct shadow_page_info *next)
    1.18 +{
    1.19 +    sp->next_shadow = next ? mfn_x(shadow_page_to_mfn(next)) : 0;
    1.20 +}
    1.21 +#endif
    1.22 +
    1.23  /* Allocate another shadow's worth of (contiguous, aligned) pages,
    1.24   * and fill in the type and backpointer fields of their page_infos. 
    1.25   * Never fails to allocate. */
    1.26 @@ -1554,7 +1570,7 @@ mfn_t shadow_alloc(struct domain *d,
    1.27          sp[i].u.sh.pinned = 0;
    1.28          sp[i].u.sh.count = 0;
    1.29          sp[i].u.sh.back = backpointer;
    1.30 -        sp[i].next_shadow = NULL;
    1.31 +        set_next_shadow(&sp[i], NULL);
    1.32          perfc_incr(shadow_alloc_count);
    1.33      }
    1.34      return shadow_page_to_mfn(sp);
    1.35 @@ -1890,7 +1906,7 @@ static void sh_hash_audit_bucket(struct 
    1.36          /* Wrong bucket? */
    1.37          BUG_ON( sh_hash(sp->u.sh.back, sp->u.sh.type) != bucket );
    1.38          /* Duplicate entry? */
    1.39 -        for ( x = sp->next_shadow; x; x = x->next_shadow )
    1.40 +        for ( x = next_shadow(sp); x; x = next_shadow(x) )
    1.41              BUG_ON( x->u.sh.back == sp->u.sh.back &&
    1.42                      x->u.sh.type == sp->u.sh.type );
    1.43          /* Follow the backpointer to the guest pagetable */
    1.44 @@ -1934,7 +1950,7 @@ static void sh_hash_audit_bucket(struct 
    1.45              }
    1.46          }
    1.47          /* That entry was OK; on we go */
    1.48 -        sp = sp->next_shadow;
    1.49 +        sp = next_shadow(sp);
    1.50      }
    1.51  }
    1.52  
    1.53 @@ -2028,7 +2044,7 @@ mfn_t shadow_hash_lookup(struct vcpu *v,
    1.54                      /* Delete sp from the list */
    1.55                      prev->next_shadow = sp->next_shadow;                    
    1.56                      /* Re-insert it at the head of the list */
    1.57 -                    sp->next_shadow = d->arch.paging.shadow.hash_table[key];
    1.58 +                    set_next_shadow(sp, d->arch.paging.shadow.hash_table[key]);
    1.59                      d->arch.paging.shadow.hash_table[key] = sp;
    1.60                  }
    1.61              }
    1.62 @@ -2039,7 +2055,7 @@ mfn_t shadow_hash_lookup(struct vcpu *v,
    1.63              return shadow_page_to_mfn(sp);
    1.64          }
    1.65          prev = sp;
    1.66 -        sp = sp->next_shadow;
    1.67 +        sp = next_shadow(sp);
    1.68      }
    1.69  
    1.70      perfc_incr(shadow_hash_lookup_miss);
    1.71 @@ -2066,7 +2082,7 @@ void shadow_hash_insert(struct vcpu *v, 
    1.72      
    1.73      /* Insert this shadow at the top of the bucket */
    1.74      sp = mfn_to_shadow_page(smfn);
    1.75 -    sp->next_shadow = d->arch.paging.shadow.hash_table[key];
    1.76 +    set_next_shadow(sp, d->arch.paging.shadow.hash_table[key]);
    1.77      d->arch.paging.shadow.hash_table[key] = sp;
    1.78      
    1.79      sh_hash_audit_bucket(d, key);
    1.80 @@ -2093,7 +2109,7 @@ void shadow_hash_delete(struct vcpu *v, 
    1.81      sp = mfn_to_shadow_page(smfn);
    1.82      if ( d->arch.paging.shadow.hash_table[key] == sp ) 
    1.83          /* Easy case: we're deleting the head item. */
    1.84 -        d->arch.paging.shadow.hash_table[key] = sp->next_shadow;
    1.85 +        d->arch.paging.shadow.hash_table[key] = next_shadow(sp);
    1.86      else 
    1.87      {
    1.88          /* Need to search for the one we want */
    1.89 @@ -2102,15 +2118,15 @@ void shadow_hash_delete(struct vcpu *v, 
    1.90          {
    1.91              ASSERT(x); /* We can't have hit the end, since our target is
    1.92                          * still in the chain somehwere... */
    1.93 -            if ( x->next_shadow == sp ) 
    1.94 +            if ( next_shadow(x) == sp )
    1.95              {
    1.96                  x->next_shadow = sp->next_shadow;
    1.97                  break;
    1.98              }
    1.99 -            x = x->next_shadow;
   1.100 +            x = next_shadow(x);
   1.101          }
   1.102      }
   1.103 -    sp->next_shadow = NULL;
   1.104 +    set_next_shadow(sp, NULL);
   1.105  
   1.106      sh_hash_audit_bucket(d, key);
   1.107  }
   1.108 @@ -2144,7 +2160,7 @@ static void hash_foreach(struct vcpu *v,
   1.109          /* WARNING: This is not safe against changes to the hash table.
   1.110           * The callback *must* return non-zero if it has inserted or
   1.111           * deleted anything from the hash (lookups are OK, though). */
   1.112 -        for ( x = d->arch.paging.shadow.hash_table[i]; x; x = x->next_shadow )
   1.113 +        for ( x = d->arch.paging.shadow.hash_table[i]; x; x = next_shadow(x) )
   1.114          {
   1.115              if ( callback_mask & (1 << x->u.sh.type) )
   1.116              {
     2.1 --- a/xen/include/asm-x86/mm.h	Fri Jan 30 11:08:06 2009 +0000
     2.2 +++ b/xen/include/asm-x86/mm.h	Fri Jan 30 11:09:44 2009 +0000
     2.3 @@ -139,7 +139,11 @@ struct page_info
     2.4          u32 shadow_flags;
     2.5  
     2.6          /* When in use as a shadow, next shadow in this hash chain. */
     2.7 +#ifdef __i386__
     2.8          struct shadow_page_info *next_shadow;
     2.9 +#else
    2.10 +        __mfn_t next_shadow;
    2.11 +#endif
    2.12      };
    2.13  };
    2.14