ia64/xen-unstable

changeset 19109:0858f961c77a

x86: Pickle domain in page_info into 32 bits.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jan 28 17:40:01 2009 +0000 (2009-01-28)
parents 839bece33989
children 3449d8e50fb9
files xen/arch/ia64/xen/domain.c xen/arch/x86/domain.c xen/common/domain.c xen/include/asm-x86/mm.h xen/include/xen/domain.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Wed Jan 28 17:05:18 2009 +0000
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Wed Jan 28 17:40:01 2009 +0000
     1.3 @@ -405,6 +405,16 @@ void relinquish_vcpu_resources(struct vc
     1.4  	kill_timer(&v->arch.hlt_timer);
     1.5  }
     1.6  
     1.7 +struct domain *alloc_domain_struct(void)
     1.8 +{
     1.9 +    return xmalloc(struct domain);
    1.10 +}
    1.11 +
    1.12 +void free_domain_struct(struct domain *d)
    1.13 +{
    1.14 +    xfree(d);
    1.15 +}
    1.16 +
    1.17  struct vcpu *alloc_vcpu_struct(void)
    1.18  {
    1.19  	struct page_info *page;
     2.1 --- a/xen/arch/x86/domain.c	Wed Jan 28 17:05:18 2009 +0000
     2.2 +++ b/xen/arch/x86/domain.c	Wed Jan 28 17:40:01 2009 +0000
     2.3 @@ -162,6 +162,25 @@ void dump_pageframe_info(struct domain *
     2.4      }
     2.5  }
     2.6  
     2.7 +struct domain *alloc_domain_struct(void)
     2.8 +{
     2.9 +    struct domain *d;
    2.10 +    /*
    2.11 +     * We pack the MFN of the domain structure into a 32-bit field within
    2.12 +     * the page_info structure. Hence the MEMF_bits() restriction.
    2.13 +     */
    2.14 +    d = alloc_xenheap_pages(
    2.15 +        get_order_from_bytes(sizeof(*d)), MEMF_bits(32 + PAGE_SHIFT));
    2.16 +    if ( d != NULL )
    2.17 +        memset(d, 0, sizeof(*d));
    2.18 +    return d;
    2.19 +}
    2.20 +
    2.21 +void free_domain_struct(struct domain *d)
    2.22 +{
    2.23 +    free_xenheap_pages(d, get_order_from_bytes(sizeof(*d)));
    2.24 +}
    2.25 +
    2.26  struct vcpu *alloc_vcpu_struct(void)
    2.27  {
    2.28      struct vcpu *v;
     3.1 --- a/xen/common/domain.c	Wed Jan 28 17:05:18 2009 +0000
     3.2 +++ b/xen/common/domain.c	Wed Jan 28 17:40:01 2009 +0000
     3.3 @@ -102,16 +102,6 @@ int current_domain_id(void)
     3.4      return current->domain->domain_id;
     3.5  }
     3.6  
     3.7 -static struct domain *alloc_domain_struct(void)
     3.8 -{
     3.9 -    return xmalloc(struct domain);
    3.10 -}
    3.11 -
    3.12 -static void free_domain_struct(struct domain *d)
    3.13 -{
    3.14 -    xfree(d);
    3.15 -}
    3.16 -
    3.17  static void __domain_finalise_shutdown(struct domain *d)
    3.18  {
    3.19      struct vcpu *v;
     4.1 --- a/xen/include/asm-x86/mm.h	Wed Jan 28 17:05:18 2009 +0000
     4.2 +++ b/xen/include/asm-x86/mm.h	Wed Jan 28 17:40:01 2009 +0000
     4.3 @@ -31,7 +31,7 @@ struct page_info
     4.4          /* Page is in use: ((count_info & PGC_count_mask) != 0). */
     4.5          struct {
     4.6              /* Owner of this page (NULL if page is anonymous). */
     4.7 -            unsigned long _domain; /* pickled format */
     4.8 +            u32 _domain; /* pickled format */
     4.9              /* Type reference count and various PGT_xxx flags and fields. */
    4.10              unsigned long type_info;
    4.11          } inuse;
    4.12 @@ -173,8 +173,11 @@ struct page_info
    4.13  /* OOS fixup entries */
    4.14  #define SHADOW_OOS_FIXUPS 2
    4.15  
    4.16 -#define page_get_owner(_p)    ((struct domain *)(_p)->u.inuse._domain)
    4.17 -#define page_set_owner(_p,_d) ((_p)->u.inuse._domain = (unsigned long)(_d))
    4.18 +#define page_get_owner(_p)                                              \
    4.19 +    ((struct domain *)((_p)->u.inuse._domain ?                          \
    4.20 +                       mfn_to_virt((_p)->u.inuse._domain) : NULL))
    4.21 +#define page_set_owner(_p,_d)                                           \
    4.22 +    ((_p)->u.inuse._domain = (_d) ? virt_to_mfn(_d) : 0)
    4.23  
    4.24  #define maddr_get_owner(ma)   (page_get_owner(maddr_to_page((ma))))
    4.25  #define vaddr_get_owner(va)   (page_get_owner(virt_to_page((va))))
     5.1 --- a/xen/include/xen/domain.h	Wed Jan 28 17:05:18 2009 +0000
     5.2 +++ b/xen/include/xen/domain.h	Wed Jan 28 17:40:01 2009 +0000
     5.3 @@ -23,6 +23,10 @@ void getdomaininfo(struct domain *d, str
     5.4   * Arch-specifics.
     5.5   */
     5.6  
     5.7 +/* Allocate/free a domain structure. */
     5.8 +struct domain *alloc_domain_struct(void);
     5.9 +void free_domain_struct(struct domain *d);
    5.10 +
    5.11  /* Allocate/free a VCPU structure. */
    5.12  struct vcpu *alloc_vcpu_struct(void);
    5.13  void free_vcpu_struct(struct vcpu *v);