ia64/xen-unstable

changeset 19129:971d2d5cb5cb

[IA64] Widen page counts and domain pointer

This is ia64 counter part of 19089:39517e863cc8.
This patch is preliminary for removing xenheap.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Fri Jan 30 11:12:44 2009 +0900 (2009-01-30)
parents 77393d4de777
children c8962b24fb50
files xen/arch/ia64/xen/machine_kexec.c xen/arch/ia64/xen/mm.c xen/arch/ia64/xen/xensetup.c xen/include/asm-ia64/mm.h
line diff
     1.1 --- a/xen/arch/ia64/xen/machine_kexec.c	Fri Jan 30 11:12:29 2009 +0900
     1.2 +++ b/xen/arch/ia64/xen/machine_kexec.c	Fri Jan 30 11:12:44 2009 +0900
     1.3 @@ -200,7 +200,6 @@ void arch_crash_save_vmcoreinfo(void)
     1.4  	VMCOREINFO_SYMBOL(dom_io);
     1.5  	VMCOREINFO_SYMBOL(xen_pstart);
     1.6  	VMCOREINFO_SYMBOL(frametable_pg_dir);
     1.7 -	VMCOREINFO_SYMBOL_ALIAS(xen_heap_start, xen_pickle_offset);
     1.8  }
     1.9  
    1.10  /*
     2.1 --- a/xen/arch/ia64/xen/mm.c	Fri Jan 30 11:12:29 2009 +0900
     2.2 +++ b/xen/arch/ia64/xen/mm.c	Fri Jan 30 11:12:44 2009 +0900
     2.3 @@ -1261,17 +1261,18 @@ adjust_page_count_info(struct page_info*
     2.4          int ret = get_page(page, d);
     2.5          BUG_ON(ret == 0);
     2.6      } else {
     2.7 -        u64 x, nx, y;
     2.8 -
     2.9 -        y = *((u64*)&page->count_info);
    2.10 +        unsigned long x, nx, y;
    2.11 +
    2.12 +        y = page->count_info;
    2.13          do {
    2.14              x = y;
    2.15              nx = x + 1;
    2.16  
    2.17              BUG_ON((x >> 32) != 0);
    2.18              BUG_ON((nx & PGC_count_mask) != 2);
    2.19 -            y = cmpxchg((u64*)&page->count_info, x, nx);
    2.20 +            y = cmpxchg(&page->count_info, x, nx);
    2.21          } while (unlikely(y != x));
    2.22 +        BUG_ON(page_get_owner(page) != NULL);
    2.23      }
    2.24  }
    2.25  
    2.26 @@ -2748,7 +2749,7 @@ steal_page(struct domain *d, struct page
    2.27  #if 0 /* if big endian */
    2.28  # error "implement big endian version of steal_page()"
    2.29  #endif
    2.30 -    u32 x, y;
    2.31 +    unsigned long x, y;
    2.32  
    2.33      if (page_get_owner(page) != d) {
    2.34          gdprintk(XENLOG_INFO, "%s d 0x%p owner 0x%p\n",
    2.35 @@ -2808,7 +2809,6 @@ steal_page(struct domain *d, struct page
    2.36      y = page->count_info;
    2.37      do {
    2.38          x = y;
    2.39 -        // page->count_info: untouched
    2.40  
    2.41          if (unlikely(((x & (PGC_count_mask | PGC_allocated)) !=
    2.42                        (1 | PGC_allocated)))) {
    2.43 @@ -2817,7 +2817,7 @@ steal_page(struct domain *d, struct page
    2.44                  gdprintk(XENLOG_INFO, "gnttab_transfer: "
    2.45                          "Bad page %p: ed=%p(%u), "
    2.46                          "sd=%p,"
    2.47 -                        " caf=%016x, taf=%" PRtype_info
    2.48 +                        " caf=%016lx, taf=%" PRtype_info
    2.49                          " memflags 0x%x\n",
    2.50                          (void *) page_to_mfn(page),
    2.51                          d, d->domain_id,
    2.52 @@ -2829,7 +2829,7 @@ steal_page(struct domain *d, struct page
    2.53                  gdprintk(XENLOG_WARNING, "gnttab_transfer: "
    2.54                          "Bad page %p: ed=%p(%u), "
    2.55                          "sd=%p(%u),"
    2.56 -                        " caf=%016x, taf=%" PRtype_info
    2.57 +                        " caf=%016lx, taf=%" PRtype_info
    2.58                          " memflags 0x%x\n",
    2.59                          (void *) page_to_mfn(page),
    2.60                          d, d->domain_id,
    2.61 @@ -2864,7 +2864,7 @@ steal_page(struct domain *d, struct page
    2.62  
    2.63   fail:
    2.64      spin_unlock(&d->page_alloc_lock);
    2.65 -    MEM_LOG("Bad page %p: ed=%p(%u), sd=%p, caf=%08x, taf=%" PRtype_info,
    2.66 +    MEM_LOG("Bad page %p: ed=%p(%u), sd=%p, caf=%016lx, taf=%" PRtype_info,
    2.67              (void *)page_to_mfn(page), d, d->domain_id,
    2.68              page_get_owner(page), page->count_info, page->u.inuse.type_info);
    2.69      return -1;
    2.70 @@ -3055,11 +3055,11 @@ void domain_cache_flush (struct domain *
    2.71      //printk ("domain_cache_flush: %d %d pages\n", d->domain_id, nbr_page);
    2.72  }
    2.73  
    2.74 -static void free_page_type(struct page_info *page, u32 type)
    2.75 +static void free_page_type(struct page_info *page, unsigned long type)
    2.76  {
    2.77  }
    2.78  
    2.79 -static int alloc_page_type(struct page_info *page, u32 type)
    2.80 +static int alloc_page_type(struct page_info *page, unsigned long type)
    2.81  {
    2.82  	return 1;
    2.83  }
    2.84 @@ -3150,7 +3150,7 @@ static int get_page_from_pagenr(unsigned
    2.85  }
    2.86  
    2.87  
    2.88 -int get_page_type(struct page_info *page, u32 type)
    2.89 +int get_page_type(struct page_info *page, unsigned long type)
    2.90  {
    2.91      u64 nx, x, y = page->u.inuse.type_info;
    2.92  
    2.93 @@ -3198,7 +3198,7 @@ int get_page_type(struct page_info *page
    2.94          {
    2.95              if ( ((x & PGT_type_mask) != PGT_l2_page_table) ||
    2.96                   (type != PGT_l1_page_table) )
    2.97 -                MEM_LOG("Bad type (saw %08lx != exp %08x) "
    2.98 +                MEM_LOG("Bad type (saw %08lx != exp %08lx) "
    2.99                          "for mfn %016lx (pfn %016lx)",
   2.100                          x, type, page_to_mfn(page),
   2.101                          get_gpfn_from_mfn(page_to_mfn(page)));
   2.102 @@ -3219,8 +3219,8 @@ int get_page_type(struct page_info *page
   2.103          /* Try to validate page type; drop the new reference on failure. */
   2.104          if ( unlikely(!alloc_page_type(page, type)) )
   2.105          {
   2.106 -            MEM_LOG("Error while validating mfn %lx (pfn %lx) for type %08x"
   2.107 -                    ": caf=%08x taf=%" PRtype_info,
   2.108 +            MEM_LOG("Error while validating mfn %lx (pfn %lx) for type %08lx"
   2.109 +                    ": caf=%016lx taf=%" PRtype_info,
   2.110                      page_to_mfn(page), get_gpfn_from_mfn(page_to_mfn(page)),
   2.111                      type, page->count_info, page->u.inuse.type_info);
   2.112              /* Noone else can get a reference. We hold the only ref. */
     3.1 --- a/xen/arch/ia64/xen/xensetup.c	Fri Jan 30 11:12:29 2009 +0900
     3.2 +++ b/xen/arch/ia64/xen/xensetup.c	Fri Jan 30 11:12:44 2009 +0900
     3.3 @@ -74,7 +74,6 @@ boolean_param("xencons_poll", opt_xencon
     3.4  
     3.5  unsigned long xenheap_size = XENHEAP_DEFAULT_SIZE;
     3.6  unsigned long xen_pstart;
     3.7 -void *xen_pickle_offset __read_mostly;
     3.8  
     3.9  static void __init parse_xenheap_megabytes(char *s)
    3.10  {
    3.11 @@ -84,9 +83,7 @@ static void __init parse_xenheap_megabyt
    3.12      if (megabytes < XENHEAP_MEGABYTES_MIN)
    3.13          megabytes = XENHEAP_MEGABYTES_MIN;
    3.14  
    3.15 -#define XENHEAP_MEGABYTES_MAX   4096UL  /* need more? If so,
    3.16 -                                           __pickle()/__unpickle() must be
    3.17 -                                           revised. */
    3.18 +#define XENHEAP_MEGABYTES_MAX   4096UL  /* need more? */
    3.19      if (megabytes > XENHEAP_MEGABYTES_MAX)
    3.20          megabytes = XENHEAP_MEGABYTES_MAX;
    3.21  
    3.22 @@ -530,14 +527,6 @@ skip_move:
    3.23      printk("find_memory: efi_memmap_walk returns max_page=%lx\n",max_page);
    3.24      efi_print();
    3.25      
    3.26 -    /*
    3.27 -     * later [__init_begin, __init_end) will be freed up as xen heap
    3.28 -     * so that struct domain might be allocated from the init area
    3.29 -     * which is < xen_heap_start. so we can't simply set
    3.30 -     * xen_pickle_offset = xen_heap_start.
    3.31 -     */
    3.32 -    xen_pickle_offset = ia64_imva(__init_begin);
    3.33 -
    3.34      xen_heap_start = memguard_init(ia64_imva(&_end));
    3.35      printk("Before xen_heap_start: %p\n", xen_heap_start);
    3.36      xen_heap_start = __va(init_boot_allocator(__pa(xen_heap_start)));
     4.1 --- a/xen/include/asm-ia64/mm.h	Fri Jan 30 11:12:29 2009 +0900
     4.2 +++ b/xen/include/asm-ia64/mm.h	Fri Jan 30 11:12:44 2009 +0900
     4.3 @@ -46,7 +46,7 @@ struct page_info
     4.4      struct list_head list;
     4.5  
     4.6      /* Reference count and various PGC_xxx flags and fields. */
     4.7 -    u32 count_info;
     4.8 +    unsigned long count_info;
     4.9  
    4.10      /* Context-dependent fields follow... */
    4.11      union {
    4.12 @@ -54,10 +54,10 @@ struct page_info
    4.13          /* Page is in use: ((count_info & PGC_count_mask) != 0). */
    4.14          struct {
    4.15              /* Owner of this page (NULL if page is anonymous). */
    4.16 -            u32 _domain; /* pickled format */
    4.17 +            unsigned long _domain; /* pickled format */
    4.18              /* Type reference count and various PGT_xxx flags and fields. */
    4.19              unsigned long type_info;
    4.20 -        } __attribute__ ((packed)) inuse;
    4.21 +        } inuse;
    4.22  
    4.23          /* Page is on a free list: ((count_info & PGC_count_mask) == 0). */
    4.24          struct {
    4.25 @@ -65,7 +65,7 @@ struct page_info
    4.26              u32 order;
    4.27              /* Mask of possibly-tainted TLBs. */
    4.28              cpumask_t cpumask;
    4.29 -        } __attribute__ ((packed)) free;
    4.30 +        } free;
    4.31  
    4.32      } u;
    4.33  
    4.34 @@ -86,50 +86,47 @@ struct page_info
    4.35   * Still small set of flags defined by far on IA-64.
    4.36   * IA-64 should make it a definition same as x86_64.
    4.37   */
    4.38 +#define PG_shift(idx)   (BITS_PER_LONG - (idx))
    4.39 +#define PG_mask(x, idx) (x ## UL << PG_shift(idx))
    4.40 +
    4.41  /* The following page types are MUTUALLY EXCLUSIVE. */
    4.42 -#define PGT_none            (0UL<<29) /* no special uses of this page */
    4.43 -#define PGT_l1_page_table   (1UL<<29) /* using this page as an L1 page table? */
    4.44 -#define PGT_l2_page_table   (2UL<<29) /* using this page as an L2 page table? */
    4.45 -#define PGT_l3_page_table   (3UL<<29) /* using this page as an L3 page table? */
    4.46 -#define PGT_l4_page_table   (4UL<<29) /* using this page as an L4 page table? */
    4.47 +#define PGT_none          PG_mask(0, 3) /* no special uses of this page */
    4.48 +#define PGT_l1_page_table PG_mask(1, 3) /* using as an L1 page table? */
    4.49 +#define PGT_l2_page_table PG_mask(2, 3) /* using as an L2 page table? */
    4.50 +#define PGT_l3_page_table PG_mask(3, 3) /* using as an L3 page table? */
    4.51 +#define PGT_l4_page_table PG_mask(4, 3) /* using as an L4 page table? */
    4.52   /* Value 5 reserved. See asm-x86/mm.h */
    4.53   /* Value 6 reserved. See asm-x86/mm.h */
    4.54 -#define PGT_writable_page   (7UL<<29) /* has writable mappings of this page? */
    4.55 -#define PGT_type_mask       (7UL<<29) /* Bits 29-31. */
    4.56 +#define PGT_writable_page PG_mask(7, 3) /* has writable mappings? */
    4.57 +#define PGT_type_mask     PG_mask(7, 3) /* Bits 29-31. */
    4.58  
    4.59 + /* Owning guest has pinned this page to its current type? */
    4.60 +#define _PGT_pinned       PG_shift(4)
    4.61 +#define PGT_pinned        PG_mask(1, 4)
    4.62   /* Has this page been validated for use as its current type? */
    4.63 -#define _PGT_validated      28
    4.64 -#define PGT_validated       (1UL<<_PGT_validated)
    4.65 - /* Owning guest has pinned this page to its current type? */
    4.66 -#define _PGT_pinned         27
    4.67 -#define PGT_pinned          (1UL<<_PGT_pinned)
    4.68 +#define _PGT_validated    PG_shift(5)
    4.69 +#define PGT_validated     PG_mask(1, 5)
    4.70  
    4.71 - /* 16-bit count of uses of this frame as its current type. */
    4.72 -#define PGT_count_mask      ((1UL<<16)-1)
    4.73 + /* Count of uses of this frame as its current type. */
    4.74 +#define PGT_count_width   PG_shift(7)
    4.75 +#define PGT_count_mask    ((1UL<<PGT_count_width)-1)
    4.76  
    4.77   /* Cleared when the owning guest 'frees' this page. */
    4.78 -#define _PGC_allocated      31
    4.79 -#define PGC_allocated       (1UL<<_PGC_allocated)
    4.80 - /* Bit 30 reserved. See asm-x86/mm.h */
    4.81 - /* Bit 29 reserved. See asm-x86/mm.h */
    4.82 - /* 29-bit count of references to this frame. */
    4.83 -#define PGC_count_mask      ((1UL<<29)-1)
    4.84 +#define _PGC_allocated    PG_shift(1)
    4.85 +#define PGC_allocated     PG_mask(1, 1)
    4.86 + /* bit PG_shift(2) reserved. See asm-x86/mm.h */
    4.87 + /* bit PG_shift(3) reserved. See asm-x86/mm.h */
    4.88 + /* PG_mask(7, 6) reserved. See asm-x86/mm.h*/
    4.89 + /* Count of references to this frame. */
    4.90 +#define PGC_count_width   PG_shift(6)
    4.91 +#define PGC_count_mask    ((1UL<<PGC_count_width)-1)
    4.92  
    4.93  #define is_xen_heap_mfn(mfn)   (((mfn) < paddr_to_pfn(xenheap_phys_end)) \
    4.94                                  && ((mfn) >= paddr_to_pfn(xen_pstart)))
    4.95  #define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
    4.96  
    4.97 -extern void* xen_pickle_offset;
    4.98 -#define __pickle(a)	((unsigned long)a - (unsigned long)xen_pickle_offset)
    4.99 -#define __unpickle(a)	(void *)(a + xen_pickle_offset)
   4.100 -
   4.101 -static inline struct domain *unpickle_domptr(u64 _d)
   4.102 -{ return (_d == 0) ? NULL : __unpickle(_d); }
   4.103 -static inline u32 pickle_domptr(struct domain *_d)
   4.104 -{ return (_d == NULL) ? 0 : (u32)__pickle(_d); }
   4.105 -
   4.106 -#define page_get_owner(_p)	(unpickle_domptr((_p)->u.inuse._domain))
   4.107 -#define page_set_owner(_p, _d)	((_p)->u.inuse._domain = pickle_domptr(_d))
   4.108 +#define page_get_owner(_p)      ((struct domain *)(_p)->u.inuse._domain)
   4.109 +#define page_set_owner(_p, _d)	((_p)->u.inuse._domain = (unsigned long)(_d))
   4.110  
   4.111  #define XENSHARE_writable 0
   4.112  #define XENSHARE_readonly 1
   4.113 @@ -151,23 +148,23 @@ void add_to_domain_alloc_list(unsigned l
   4.114  
   4.115  static inline void put_page(struct page_info *page)
   4.116  {
   4.117 -    u32 nx, x, y = page->count_info;
   4.118 +    unsigned long nx, x, y = page->count_info;
   4.119  
   4.120      do {
   4.121 -	x = y;
   4.122 -	nx = x - 1;
   4.123 +        x = y;
   4.124 +        nx = x - 1;
   4.125      }
   4.126      while (unlikely((y = cmpxchg_rel(&page->count_info, x, nx)) != x));
   4.127  
   4.128      if (unlikely((nx & PGC_count_mask) == 0))
   4.129 -	free_domheap_page(page);
   4.130 +        free_domheap_page(page);
   4.131  }
   4.132  
   4.133  /* count_info and ownership are checked atomically. */
   4.134  static inline int get_page(struct page_info *page,
   4.135                             struct domain *domain)
   4.136  {
   4.137 -    u32 x, y = page->count_info;
   4.138 +    unsigned long x, y = page->count_info;
   4.139  
   4.140      do {
   4.141          x = y;
   4.142 @@ -185,7 +182,7 @@ static inline int get_page(struct page_i
   4.143  fail:
   4.144      /* if (!domain->is_dying) */ /* XXX: header inclusion hell */
   4.145      gdprintk(XENLOG_INFO,
   4.146 -             "Error pfn %lx: rd=%p, od=%p, caf=%016x, taf=%" PRtype_info "\n",
   4.147 +             "Error pfn %lx: rd=%p, od=%p, caf=%016lx, taf=%" PRtype_info "\n",
   4.148               page_to_mfn(page), domain,
   4.149               page_get_owner(page), y, page->u.inuse.type_info);
   4.150      return 0;
   4.151 @@ -194,7 +191,7 @@ fail:
   4.152  int is_iomem_page(unsigned long mfn);
   4.153  
   4.154  extern void put_page_type(struct page_info *page);
   4.155 -extern int get_page_type(struct page_info *page, u32 type);
   4.156 +extern int get_page_type(struct page_info *page, unsigned long type);
   4.157  
   4.158  static inline void put_page_and_type(struct page_info *page)
   4.159  {
   4.160 @@ -205,7 +202,7 @@ static inline void put_page_and_type(str
   4.161  
   4.162  static inline int get_page_and_type(struct page_info *page,
   4.163                                      struct domain *domain,
   4.164 -                                    u32 type)
   4.165 +                                    unsigned long type)
   4.166  {
   4.167      int rc = get_page(page, domain);
   4.168