ia64/xen-unstable

changeset 1932:8c6aa4b97dfc

bitkeeper revision 1.1108.23.3 (41065b4fZjYRRIBRamPXu6SAWqoNVQ)

Reformat the pfn_info structure.
author kaf24@scramble.cl.cam.ac.uk
date Tue Jul 27 13:40:31 2004 +0000 (2004-07-27)
parents 04ebbad06e8f
children 9975cd31ac46
files xen/arch/x86/domain.c xen/arch/x86/memory.c xen/arch/x86/shadow.c xen/arch/x86/x86_32/mm.c xen/common/dom0_ops.c xen/common/dom_mem_ops.c xen/common/domain.c xen/common/keyhandler.c xen/common/memory.c xen/include/asm-x86/mm.h xen/include/asm-x86/shadow.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Tue Jul 27 13:17:38 2004 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Tue Jul 27 13:40:31 2004 +0000
     1.3 @@ -467,7 +467,7 @@ void domain_relinquish_memory(struct dom
     1.4  
     1.5      /* Relinquish Xen-heap pages. Currently this can only be 'shared_info'. */
     1.6      page = virt_to_page(d->shared_info);
     1.7 -    if ( test_and_clear_bit(_PGC_allocated, &page->count_and_flags) )
     1.8 +    if ( test_and_clear_bit(_PGC_allocated, &page->u.inuse.count_info) )
     1.9          put_page(page);
    1.10  
    1.11      /* Relinquish all pages on the domain's allocation list. */
    1.12 @@ -476,10 +476,10 @@ void domain_relinquish_memory(struct dom
    1.13      {
    1.14          page = list_entry(ent, struct pfn_info, list);
    1.15  
    1.16 -        if ( test_and_clear_bit(_PGC_guest_pinned, &page->count_and_flags) )
    1.17 +        if ( test_and_clear_bit(_PGC_guest_pinned, &page->u.inuse.count_info) )
    1.18              put_page_and_type(page);
    1.19  
    1.20 -        if ( test_and_clear_bit(_PGC_allocated, &page->count_and_flags) )
    1.21 +        if ( test_and_clear_bit(_PGC_allocated, &page->u.inuse.count_info) )
    1.22              put_page(page);
    1.23  
    1.24          /*
    1.25 @@ -488,13 +488,13 @@ void domain_relinquish_memory(struct dom
    1.26           * are not shared across domains and this domain is now dead. Thus base
    1.27           * tables are not in use so a non-zero count means circular reference.
    1.28           */
    1.29 -        y = page->type_and_flags;
    1.30 +        y = page->u.inuse.type_info;
    1.31          do {
    1.32              x = y;
    1.33              if ( likely((x & (PGT_type_mask|PGT_validated)) != 
    1.34                          (PGT_base_page_table|PGT_validated)) )
    1.35                  break;
    1.36 -            y = cmpxchg(&page->type_and_flags, x, x & ~PGT_validated);
    1.37 +            y = cmpxchg(&page->u.inuse.type_info, x, x & ~PGT_validated);
    1.38              if ( likely(y == x) )
    1.39                  free_page_type(page, PGT_base_page_table);
    1.40          }
    1.41 @@ -654,9 +654,9 @@ int construct_dom0(struct domain *p,
    1.42            mfn++ )
    1.43      {
    1.44          page = &frame_table[mfn];
    1.45 -        page->u.domain        = p;
    1.46 -        page->type_and_flags  = 0;
    1.47 -        page->count_and_flags = PGC_allocated | 1;
    1.48 +        page->u.inuse.domain        = p;
    1.49 +        page->u.inuse.type_info  = 0;
    1.50 +        page->u.inuse.count_info = PGC_allocated | 1;
    1.51          list_add_tail(&page->list, &p->page_list);
    1.52          p->tot_pages++; p->max_pages++;
    1.53      }
    1.54 @@ -701,7 +701,7 @@ int construct_dom0(struct domain *p,
    1.55          *l1tab++ = mk_l1_pgentry((mfn << PAGE_SHIFT) | L1_PROT);
    1.56          
    1.57          page = &frame_table[mfn];
    1.58 -        set_bit(_PGC_tlb_flush_on_type_change, &page->count_and_flags);
    1.59 +        set_bit(_PGC_tlb_flush_on_type_change, &page->u.inuse.count_info);
    1.60          if ( !get_page_and_type(page, p, PGT_writeable_page) )
    1.61              BUG();
    1.62  
    1.63 @@ -719,18 +719,18 @@ int construct_dom0(struct domain *p,
    1.64          page = &frame_table[l1_pgentry_to_pagenr(*l1tab)];
    1.65          if ( count == 0 )
    1.66          {
    1.67 -            page->type_and_flags &= ~PGT_type_mask;
    1.68 -            page->type_and_flags |= PGT_l2_page_table;
    1.69 +            page->u.inuse.type_info &= ~PGT_type_mask;
    1.70 +            page->u.inuse.type_info |= PGT_l2_page_table;
    1.71              get_page(page, p); /* an extra ref because of readable mapping */
    1.72              /* Get another ref to L2 page so that it can be pinned. */
    1.73              if ( !get_page_and_type(page, p, PGT_l2_page_table) )
    1.74                  BUG();
    1.75 -            set_bit(_PGC_guest_pinned, &page->count_and_flags);
    1.76 +            set_bit(_PGC_guest_pinned, &page->u.inuse.count_info);
    1.77          }
    1.78          else
    1.79          {
    1.80 -            page->type_and_flags &= ~PGT_type_mask;
    1.81 -            page->type_and_flags |= PGT_l1_page_table;
    1.82 +            page->u.inuse.type_info &= ~PGT_type_mask;
    1.83 +            page->u.inuse.type_info |= PGT_l1_page_table;
    1.84              get_page(page, p); /* an extra ref because of readable mapping */
    1.85          }
    1.86          l1tab++;
     2.1 --- a/xen/arch/x86/memory.c	Tue Jul 27 13:17:38 2004 +0000
     2.2 +++ b/xen/arch/x86/memory.c	Tue Jul 27 13:40:31 2004 +0000
     2.3 @@ -245,7 +245,7 @@ static int get_page_and_type_from_pagenr
     2.4      if ( unlikely(!get_page_type(page, type)) )
     2.5      {
     2.6          MEM_LOG("Bad page type for pfn %08lx (%08x)", 
     2.7 -                page_nr, page->type_and_flags);
     2.8 +                page_nr, page->u.inuse.type_info);
     2.9          put_page(page);
    2.10          return 0;
    2.11      }
    2.12 @@ -288,7 +288,7 @@ static int get_linear_pagetable(l2_pgent
    2.13           * If so, atomically increment the count (checking for overflow).
    2.14           */
    2.15          page = &frame_table[l2_pgentry_to_pagenr(l2e)];
    2.16 -        y = page->type_and_flags;
    2.17 +        y = page->u.inuse.type_info;
    2.18          do {
    2.19              x = y;
    2.20              if ( unlikely((x & PGT_count_mask) == PGT_count_mask) ||
    2.21 @@ -299,7 +299,7 @@ static int get_linear_pagetable(l2_pgent
    2.22                  return 0;
    2.23              }
    2.24          }
    2.25 -        while ( (y = cmpxchg(&page->type_and_flags, x, x + 1)) != x );
    2.26 +        while ( (y = cmpxchg(&page->u.inuse.type_info, x, x + 1)) != x );
    2.27      }
    2.28  
    2.29      return 1;
    2.30 @@ -339,7 +339,7 @@ static int get_page_from_l1e(l1_pgentry_
    2.31              pfn, PGT_writeable_page, GPS)) )
    2.32              return 0;
    2.33          set_bit(_PGC_tlb_flush_on_type_change, 
    2.34 -                &frame_table[pfn].count_and_flags);
    2.35 +                &frame_table[pfn].u.inuse.count_info);
    2.36          return 1;
    2.37      }
    2.38  
    2.39 @@ -383,10 +383,10 @@ static void put_page_from_l1e(l1_pgentry
    2.40      else
    2.41      {
    2.42          /* We expect this is rare so we blow the entire shadow LDT. */
    2.43 -        if ( unlikely(((page->type_and_flags & PGT_type_mask) == 
    2.44 +        if ( unlikely(((page->u.inuse.type_info & PGT_type_mask) == 
    2.45                         PGT_ldt_page)) &&
    2.46 -             unlikely(((page->type_and_flags & PGT_count_mask) != 0)) )
    2.47 -            invalidate_shadow_ldt(page->u.domain);
    2.48 +             unlikely(((page->u.inuse.type_info & PGT_count_mask) != 0)) )
    2.49 +            invalidate_shadow_ldt(page->u.inuse.domain);
    2.50          put_page(page);
    2.51      }
    2.52  }
    2.53 @@ -424,7 +424,7 @@ static int alloc_l2_table(struct pfn_inf
    2.54      pl2e[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] =
    2.55          mk_l2_pgentry((page_nr << PAGE_SHIFT) | __PAGE_HYPERVISOR);
    2.56      pl2e[PERDOMAIN_VIRT_START >> L2_PAGETABLE_SHIFT] =
    2.57 -        mk_l2_pgentry(__pa(page->u.domain->mm.perdomain_pt) | 
    2.58 +        mk_l2_pgentry(__pa(page->u.inuse.domain->mm.perdomain_pt) | 
    2.59                        __PAGE_HYPERVISOR);
    2.60  #endif
    2.61  
    2.62 @@ -617,9 +617,9 @@ static int mod_l1_entry(l1_pgentry_t *pl
    2.63  int alloc_page_type(struct pfn_info *page, unsigned int type)
    2.64  {
    2.65      if ( unlikely(test_and_clear_bit(_PGC_tlb_flush_on_type_change, 
    2.66 -                                     &page->count_and_flags)) )
    2.67 +                                     &page->u.inuse.count_info)) )
    2.68      {
    2.69 -        struct domain *p = page->u.domain;
    2.70 +        struct domain *p = page->u.inuse.domain;
    2.71          if ( unlikely(NEED_FLUSH(tlbflush_time[p->processor],
    2.72                                   page->tlbflush_timestamp)) )
    2.73          {
    2.74 @@ -713,7 +713,7 @@ static int do_extended_command(unsigned 
    2.75          }
    2.76  
    2.77          if ( unlikely(test_and_set_bit(_PGC_guest_pinned, 
    2.78 -                                       &page->count_and_flags)) )
    2.79 +                                       &page->u.inuse.count_info)) )
    2.80          {
    2.81              MEM_LOG("Pfn %08lx already pinned", pfn);
    2.82              put_page_and_type(page);
    2.83 @@ -727,10 +727,10 @@ static int do_extended_command(unsigned 
    2.84          if ( unlikely(!(okay = get_page_from_pagenr(pfn, PTS))) )
    2.85          {
    2.86              MEM_LOG("Page %08lx bad domain (dom=%p)",
    2.87 -                    ptr, page->u.domain);
    2.88 +                    ptr, page->u.inuse.domain);
    2.89          }
    2.90          else if ( likely(test_and_clear_bit(_PGC_guest_pinned, 
    2.91 -                                            &page->count_and_flags)) )
    2.92 +                                            &page->u.inuse.count_info)) )
    2.93          {
    2.94              put_page_and_type(page);
    2.95              put_page(page);
    2.96 @@ -874,8 +874,8 @@ static int do_extended_command(unsigned 
    2.97           * benign reference to the page (PGC_allocated). If that reference
    2.98           * disappears then the deallocation routine will safely spin.
    2.99           */
   2.100 -        nd = page->u.domain;
   2.101 -        y  = page->count_and_flags;
   2.102 +        nd = page->u.inuse.domain;
   2.103 +        y  = page->u.inuse.count_info;
   2.104          do {
   2.105              x = y;
   2.106              if ( unlikely((x & (PGC_count_mask|PGC_allocated)) != 
   2.107 @@ -884,14 +884,14 @@ static int do_extended_command(unsigned 
   2.108              {
   2.109                  MEM_LOG("Bad page values %08lx: ed=%p(%u), sd=%p,"
   2.110                          " caf=%08x, taf=%08x\n", page_to_pfn(page),
   2.111 -                        d, d->domain, nd, x, page->type_and_flags);
   2.112 +                        d, d->domain, nd, x, page->u.inuse.type_info);
   2.113                  okay = 0;
   2.114                  goto reassign_fail;
   2.115              }
   2.116              __asm__ __volatile__(
   2.117                  LOCK_PREFIX "cmpxchg8b %3"
   2.118                  : "=a" (nd), "=d" (y), "=b" (e),
   2.119 -                "=m" (*(volatile u64 *)(&page->u.domain))
   2.120 +                "=m" (*(volatile u64 *)(&page->u.inuse.domain))
   2.121                  : "0" (d), "1" (x), "b" (e), "c" (x) );
   2.122          } 
   2.123          while ( unlikely(nd != d) || unlikely(y != x) );
   2.124 @@ -985,7 +985,7 @@ int do_mmu_update(mmu_update_t *ureqs, i
   2.125              }
   2.126  
   2.127              page = &frame_table[pfn];
   2.128 -            switch ( (page->type_and_flags & PGT_type_mask) )
   2.129 +            switch ( (page->u.inuse.type_info & PGT_type_mask) )
   2.130              {
   2.131              case PGT_l1_page_table: 
   2.132                  if ( likely(get_page_type(page, PGT_l1_page_table)) )
     3.1 --- a/xen/arch/x86/shadow.c	Tue Jul 27 13:17:38 2004 +0000
     3.2 +++ b/xen/arch/x86/shadow.c	Tue Jul 27 13:40:31 2004 +0000
     3.3 @@ -68,7 +68,7 @@ static inline void free_shadow_page( str
     3.4                                       struct pfn_info *pfn_info )
     3.5  {
     3.6      unsigned long flags;
     3.7 -    unsigned long type = pfn_info->type_and_flags & PGT_type_mask;
     3.8 +    unsigned long type = pfn_info->u.inuse.type_info & PGT_type_mask;
     3.9  
    3.10      m->shadow_page_count--;
    3.11  
    3.12 @@ -77,9 +77,9 @@ static inline void free_shadow_page( str
    3.13      else if (type == PGT_l2_page_table)
    3.14          perfc_decr(shadow_l2_pages);
    3.15      else printk("Free shadow weird page type pfn=%08x type=%08x\n",
    3.16 -                frame_table-pfn_info, pfn_info->type_and_flags);
    3.17 +                frame_table-pfn_info, pfn_info->u.inuse.type_info);
    3.18      
    3.19 -    pfn_info->type_and_flags = 0;
    3.20 +    pfn_info->u.inuse.type_info = 0;
    3.21  
    3.22      spin_lock_irqsave(&free_list_lock, flags);
    3.23      list_add(&pfn_info->list, &free_list);
    3.24 @@ -147,7 +147,7 @@ static inline int shadow_page_op( struct
    3.25      {
    3.26  	case TABLE_OP_ZERO_L2:
    3.27  	{
    3.28 -		if ( (spfn_info->type_and_flags & PGT_type_mask) == 
    3.29 +		if ( (spfn_info->u.inuse.type_info & PGT_type_mask) == 
    3.30               PGT_l2_page_table )
    3.31  		{
    3.32  			unsigned long * spl1e = map_domain_mem( spfn<<PAGE_SHIFT );
    3.33 @@ -161,7 +161,7 @@ static inline int shadow_page_op( struct
    3.34  	
    3.35  	case TABLE_OP_ZERO_L1:
    3.36  	{
    3.37 -		if ( (spfn_info->type_and_flags & PGT_type_mask) == 
    3.38 +		if ( (spfn_info->u.inuse.type_info & PGT_type_mask) == 
    3.39               PGT_l1_page_table )
    3.40  		{
    3.41  			unsigned long * spl1e = map_domain_mem( spfn<<PAGE_SHIFT );
    3.42 @@ -173,7 +173,7 @@ static inline int shadow_page_op( struct
    3.43  
    3.44  	case TABLE_OP_FREE_L1:
    3.45  	{
    3.46 -		if ( (spfn_info->type_and_flags & PGT_type_mask) == 
    3.47 +		if ( (spfn_info->u.inuse.type_info & PGT_type_mask) == 
    3.48               PGT_l1_page_table )
    3.49  		{
    3.50  			// lock is already held
    3.51 @@ -564,7 +564,7 @@ unsigned long shadow_l2_table(
    3.52  
    3.53      ASSERT( spfn_info ); // XXX deal with failure later e.g. blow cache
    3.54  
    3.55 -    spfn_info->type_and_flags = PGT_l2_page_table;
    3.56 +    spfn_info->u.inuse.type_info = PGT_l2_page_table;
    3.57      perfc_incr(shadow_l2_pages);
    3.58  
    3.59      spfn = (unsigned long) (spfn_info - frame_table);
    3.60 @@ -585,7 +585,7 @@ unsigned long shadow_l2_table(
    3.61      spl2e[SH_LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] =
    3.62          mk_l2_pgentry((spfn << PAGE_SHIFT) | __PAGE_HYPERVISOR);
    3.63      spl2e[PERDOMAIN_VIRT_START >> L2_PAGETABLE_SHIFT] =
    3.64 -        mk_l2_pgentry(__pa(frame_table[gpfn].u.domain->mm.perdomain_pt) | 
    3.65 +        mk_l2_pgentry(__pa(frame_table[gpfn].u.inuse.domain->mm.perdomain_pt) | 
    3.66                        __PAGE_HYPERVISOR);
    3.67  #endif
    3.68  
    3.69 @@ -728,7 +728,7 @@ int shadow_fault( unsigned long va, long
    3.70              unsigned long *gpl1e, *spl1e;
    3.71              int i;
    3.72              sl1pfn_info = alloc_shadow_page( &current->mm ); 
    3.73 -            sl1pfn_info->type_and_flags = PGT_l1_page_table;
    3.74 +            sl1pfn_info->u.inuse.type_info = PGT_l1_page_table;
    3.75  			
    3.76              sl1pfn = sl1pfn_info - frame_table;
    3.77  
    3.78 @@ -1017,7 +1017,7 @@ int check_pagetable( struct mm_struct *m
    3.79              );
    3.80  
    3.81      if ( (l2_pgentry_val(spl2e[PERDOMAIN_VIRT_START >> L2_PAGETABLE_SHIFT]) !=
    3.82 -          ((__pa(frame_table[gpfn].u.domain->mm.perdomain_pt) | __PAGE_HYPERVISOR))) )
    3.83 +          ((__pa(frame_table[gpfn].u.inuse.domain->mm.perdomain_pt) | __PAGE_HYPERVISOR))) )
    3.84          FAILPT("hypervisor per-domain map inconsistent");
    3.85  
    3.86  
     4.1 --- a/xen/arch/x86/x86_32/mm.c	Tue Jul 27 13:17:38 2004 +0000
     4.2 +++ b/xen/arch/x86/x86_32/mm.c	Tue Jul 27 13:40:31 2004 +0000
     4.3 @@ -338,7 +338,7 @@ long do_update_descriptor(
     4.4          return -EINVAL;
     4.5  
     4.6      /* Check if the given frame is in use in an unsafe context. */
     4.7 -    switch ( page->type_and_flags & PGT_type_mask )
     4.8 +    switch ( page->u.inuse.type_info & PGT_type_mask )
     4.9      {
    4.10      case PGT_gdt_page:
    4.11          /* Disallow updates of Xen-reserved descriptors in the current GDT. */
     5.1 --- a/xen/common/dom0_ops.c	Tue Jul 27 13:17:38 2004 +0000
     5.2 +++ b/xen/common/dom0_ops.c	Tue Jul 27 13:40:31 2004 +0000
     5.3 @@ -442,9 +442,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     5.4  
     5.5              op->u.getpageframeinfo.type = NOTAB;
     5.6  
     5.7 -            if ( (page->type_and_flags & PGT_count_mask) != 0 )
     5.8 +            if ( (page->u.inuse.type_info & PGT_count_mask) != 0 )
     5.9              {
    5.10 -                switch ( page->type_and_flags & PGT_type_mask )
    5.11 +                switch ( page->u.inuse.type_info & PGT_type_mask )
    5.12                  {
    5.13                  case PGT_l1_page_table:
    5.14                      op->u.getpageframeinfo.type = L1TAB;
    5.15 @@ -645,7 +645,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    5.16                  if ( likely(get_page(page, d)) )
    5.17                  {
    5.18                      unsigned long type = 0;
    5.19 -                    switch( page->type_and_flags & PGT_type_mask )
    5.20 +                    switch( page->u.inuse.type_info & PGT_type_mask )
    5.21                      {
    5.22                      case PGT_l1_page_table:
    5.23                          type = L1TAB;
     6.1 --- a/xen/common/dom_mem_ops.c	Tue Jul 27 13:17:38 2004 +0000
     6.2 +++ b/xen/common/dom_mem_ops.c	Tue Jul 27 13:40:31 2004 +0000
     6.3 @@ -78,10 +78,10 @@ static long free_dom_mem(struct domain *
     6.4              break;
     6.5          }
     6.6  
     6.7 -        if ( test_and_clear_bit(_PGC_guest_pinned, &page->count_and_flags) )
     6.8 +        if ( test_and_clear_bit(_PGC_guest_pinned, &page->u.inuse.count_info) )
     6.9              put_page_and_type(page);
    6.10  
    6.11 -        if ( test_and_clear_bit(_PGC_allocated, &page->count_and_flags) )
    6.12 +        if ( test_and_clear_bit(_PGC_allocated, &page->u.inuse.count_info) )
    6.13              put_page(page);
    6.14  
    6.15          put_page(page);
     7.1 --- a/xen/common/domain.c	Tue Jul 27 13:17:38 2004 +0000
     7.2 +++ b/xen/common/domain.c	Tue Jul 27 13:40:31 2004 +0000
     7.3 @@ -214,7 +214,7 @@ struct pfn_info *alloc_domain_page(struc
     7.4      if ( unlikely(page == NULL) )
     7.5          return NULL;
     7.6  
     7.7 -    if ( (mask = page->u.cpu_mask) != 0 )
     7.8 +    if ( (mask = page->u.free.cpu_mask) != 0 )
     7.9      {
    7.10          pfn_stamp = page->tlbflush_timestamp;
    7.11          for ( i = 0; (mask != 0) && (i < smp_num_cpus); i++ )
    7.12 @@ -234,8 +234,8 @@ struct pfn_info *alloc_domain_page(struc
    7.13          }
    7.14      }
    7.15  
    7.16 -    page->u.domain = d;
    7.17 -    page->type_and_flags = 0;
    7.18 +    page->u.inuse.domain = d;
    7.19 +    page->u.inuse.type_info = 0;
    7.20      if ( d != NULL )
    7.21      {
    7.22          wmb(); /* Domain pointer must be visible before updating refcnt. */
    7.23 @@ -248,7 +248,7 @@ struct pfn_info *alloc_domain_page(struc
    7.24              goto free_and_exit;
    7.25          }
    7.26          list_add_tail(&page->list, &d->page_list);
    7.27 -        page->count_and_flags = PGC_allocated | 1;
    7.28 +        page->u.inuse.count_info = PGC_allocated | 1;
    7.29          if ( unlikely(d->tot_pages++ == 0) )
    7.30              get_domain(d);
    7.31          spin_unlock(&d->page_alloc_lock);
    7.32 @@ -268,7 +268,7 @@ void free_domain_page(struct pfn_info *p
    7.33  {
    7.34      unsigned long  flags;
    7.35      int            drop_dom_ref;
    7.36 -    struct domain *d = page->u.domain;
    7.37 +    struct domain *d = page->u.inuse.domain;
    7.38  
    7.39      if ( unlikely(IS_XEN_HEAP_FRAME(page)) )
    7.40      {
    7.41 @@ -279,7 +279,7 @@ void free_domain_page(struct pfn_info *p
    7.42      else
    7.43      {
    7.44          page->tlbflush_timestamp = tlbflush_clock;
    7.45 -        page->u.cpu_mask = 1 << d->processor;
    7.46 +        page->u.free.cpu_mask = 1 << d->processor;
    7.47          
    7.48          /* NB. May recursively lock from domain_relinquish_memory(). */
    7.49          spin_lock_recursive(&d->page_alloc_lock);
    7.50 @@ -287,7 +287,7 @@ void free_domain_page(struct pfn_info *p
    7.51          drop_dom_ref = (--d->tot_pages == 0);
    7.52          spin_unlock_recursive(&d->page_alloc_lock);
    7.53  
    7.54 -        page->count_and_flags = 0;
    7.55 +        page->u.inuse.count_info = 0;
    7.56          
    7.57          spin_lock_irqsave(&free_list_lock, flags);
    7.58          list_add(&page->list, &free_list);
     8.1 --- a/xen/common/keyhandler.c	Tue Jul 27 13:17:38 2004 +0000
     8.2 +++ b/xen/common/keyhandler.c	Tue Jul 27 13:40:31 2004 +0000
     8.3 @@ -82,15 +82,15 @@ void do_task_queues(unsigned char key, v
     8.4              {
     8.5                  page = list_entry(ent, struct pfn_info, list);
     8.6                  printk("Page %08x: caf=%08x, taf=%08x\n",
     8.7 -                       page_to_phys(page), page->count_and_flags,
     8.8 -                       page->type_and_flags);
     8.9 +                       page_to_phys(page), page->u.inuse.count_info,
    8.10 +                       page->u.inuse.type_info);
    8.11              }
    8.12          }
    8.13  
    8.14          page = virt_to_page(d->shared_info);
    8.15          printk("Shared_info@%08x: caf=%08x, taf=%08x\n",
    8.16 -               page_to_phys(page), page->count_and_flags,
    8.17 -               page->type_and_flags);
    8.18 +               page_to_phys(page), page->u.inuse.count_info,
    8.19 +               page->u.inuse.type_info);
    8.20                 
    8.21          printk("Guest: upcall_pend = %02x, upcall_mask = %02x\n", 
    8.22                 d->shared_info->vcpu_data[0].evtchn_upcall_pending, 
     9.1 --- a/xen/common/memory.c	Tue Jul 27 13:17:38 2004 +0000
     9.2 +++ b/xen/common/memory.c	Tue Jul 27 13:40:31 2004 +0000
     9.3 @@ -71,9 +71,9 @@ void __init init_frametable(void *framet
     9.4            mfn < virt_to_phys(&machine_to_phys_mapping[1<<20])>>PAGE_SHIFT;
     9.5            mfn++ )
     9.6      {
     9.7 -        frame_table[mfn].count_and_flags = 1 | PGC_allocated;
     9.8 -        frame_table[mfn].type_and_flags = 1 | PGT_gdt_page; /* non-RW type */
     9.9 -        frame_table[mfn].u.domain = &idle0_task;
    9.10 +        frame_table[mfn].u.inuse.count_info = 1 | PGC_allocated;
    9.11 +        frame_table[mfn].u.inuse.type_info = 1 | PGT_gdt_page; /* non-RW type */
    9.12 +        frame_table[mfn].u.inuse.domain = &idle0_task;
    9.13      }
    9.14  }
    9.15  
    10.1 --- a/xen/include/asm-x86/mm.h	Tue Jul 27 13:17:38 2004 +0000
    10.2 +++ b/xen/include/asm-x86/mm.h	Tue Jul 27 13:40:31 2004 +0000
    10.3 @@ -18,23 +18,43 @@
    10.4  
    10.5  /*
    10.6   * Per-page-frame information.
    10.7 + * 
    10.8 + * Every architecture must ensure the following:
    10.9 + *  1. 'struct pfn_info' contains a 'struct list_head list'.
   10.10 + *  2. Provide a PFN_ORDER() macro for accessing the order of a free page.
   10.11   */
   10.12 +#define PFN_ORDER(_pfn) ((_pfn)->u.free.order)
   10.13  
   10.14  struct pfn_info
   10.15  {
   10.16      /* Each frame can be threaded onto a doubly-linked list. */
   10.17      struct list_head list;
   10.18 -    /* The following possible uses are context-dependent. */
   10.19 +
   10.20 +    /* Context-dependent fields follow... */
   10.21      union {
   10.22 -        /* Page is in use: we keep a pointer to its owner. */
   10.23 -        struct domain *domain;
   10.24 -        /* Page is not currently allocated: mask of possibly-tainted TLBs. */
   10.25 -        unsigned long cpu_mask;
   10.26 +
   10.27 +        /* Page is in use by a domain. */
   10.28 +        struct {
   10.29 +            /* Owner of this page. */
   10.30 +            struct domain *domain;
   10.31 +            /* Reference count and various PGC_xxx flags and fields. */
   10.32 +            u32 count_info;
   10.33 +            /* Type reference count and various PGT_xxx flags and fields. */
   10.34 +            u32 type_info;
   10.35 +        } inuse;
   10.36 +
   10.37 +        /* Page is on a free list. */
   10.38 +        struct {
   10.39 +            /* Mask of possibly-tainted TLBs. */
   10.40 +            unsigned long cpu_mask;
   10.41 +            /* Must be at same offset as 'u.inuse.count_flags'. */
   10.42 +            u32 __unavailable;
   10.43 +            /* Order-size of the free chunk this page is the head of. */
   10.44 +            u8 order;
   10.45 +        } free;
   10.46 +
   10.47      } u;
   10.48 -    /* Reference count and various PGC_xxx flags and fields. */
   10.49 -    u32 count_and_flags;
   10.50 -    /* Type reference count and various PGT_xxx flags and fields. */
   10.51 -    u32 type_and_flags;
   10.52 +
   10.53      /* Timestamp from 'TLB clock', used to reduce need for safety flushes. */
   10.54      u32 tlbflush_timestamp;
   10.55  };
   10.56 @@ -77,13 +97,13 @@ struct pfn_info
   10.57  
   10.58  #define SHARE_PFN_WITH_DOMAIN(_pfn, _dom)                                   \
   10.59      do {                                                                    \
   10.60 -        (_pfn)->u.domain = (_dom);                                          \
   10.61 +        (_pfn)->u.inuse.domain = (_dom);                                          \
   10.62          /* The incremented type count is intended to pin to 'writeable'. */ \
   10.63 -        (_pfn)->type_and_flags  = PGT_writeable_page | PGT_validated | 1;   \
   10.64 +        (_pfn)->u.inuse.type_info  = PGT_writeable_page | PGT_validated | 1;   \
   10.65          wmb(); /* install valid domain ptr before updating refcnt. */       \
   10.66          spin_lock(&(_dom)->page_alloc_lock);                                \
   10.67          /* _dom holds an allocation reference */                            \
   10.68 -        (_pfn)->count_and_flags = PGC_allocated | 1;                        \
   10.69 +        (_pfn)->u.inuse.count_info = PGC_allocated | 1;                        \
   10.70          if ( unlikely((_dom)->xenheap_pages++ == 0) )                       \
   10.71              get_domain(_dom);                                               \
   10.72          spin_unlock(&(_dom)->page_alloc_lock);                              \
   10.73 @@ -106,13 +126,13 @@ void free_page_type(struct pfn_info *pag
   10.74  
   10.75  static inline void put_page(struct pfn_info *page)
   10.76  {
   10.77 -    u32 nx, x, y = page->count_and_flags;
   10.78 +    u32 nx, x, y = page->u.inuse.count_info;
   10.79  
   10.80      do {
   10.81          x  = y;
   10.82          nx = x - 1;
   10.83      }
   10.84 -    while ( unlikely((y = cmpxchg(&page->count_and_flags, x, nx)) != x) );
   10.85 +    while ( unlikely((y = cmpxchg(&page->u.inuse.count_info, x, nx)) != x) );
   10.86  
   10.87      if ( unlikely((nx & PGC_count_mask) == 0) )
   10.88          free_domain_page(page);
   10.89 @@ -122,8 +142,8 @@ static inline void put_page(struct pfn_i
   10.90  static inline int get_page(struct pfn_info *page,
   10.91                             struct domain *domain)
   10.92  {
   10.93 -    u32 x, nx, y = page->count_and_flags;
   10.94 -    struct domain *p, *np = page->u.domain;
   10.95 +    u32 x, nx, y = page->u.inuse.count_info;
   10.96 +    struct domain *p, *np = page->u.inuse.domain;
   10.97  
   10.98      do {
   10.99          x  = y;
  10.100 @@ -137,13 +157,13 @@ static inline int get_page(struct pfn_in
  10.101                      " caf=%08x, taf=%08x\n",
  10.102                      page_to_pfn(page), domain, domain->domain,
  10.103                      p, (p && !((x & PGC_count_mask) == 0))?p->domain:999, 
  10.104 -                    x, page->type_and_flags);
  10.105 +                    x, page->u.inuse.type_info);
  10.106              return 0;
  10.107          }
  10.108          __asm__ __volatile__(
  10.109              LOCK_PREFIX "cmpxchg8b %3"
  10.110              : "=a" (np), "=d" (y), "=b" (p),
  10.111 -              "=m" (*(volatile u64 *)(&page->u.domain))
  10.112 +              "=m" (*(volatile u64 *)(&page->u.inuse.domain))
  10.113              : "0" (p), "1" (x), "b" (p), "c" (nx) );
  10.114      }
  10.115      while ( unlikely(np != p) || unlikely(y != x) );
  10.116 @@ -154,7 +174,7 @@ static inline int get_page(struct pfn_in
  10.117  
  10.118  static inline void put_page_type(struct pfn_info *page)
  10.119  {
  10.120 -    u32 nx, x, y = page->type_and_flags;
  10.121 +    u32 nx, x, y = page->u.inuse.type_info;
  10.122  
  10.123   again:
  10.124      do {
  10.125 @@ -171,7 +191,7 @@ static inline void put_page_type(struct 
  10.126                   * 'free' is safe because the refcnt is non-zero and the
  10.127                   * validated bit is clear => other ops will spin or fail.
  10.128                   */
  10.129 -                if ( unlikely((y = cmpxchg(&page->type_and_flags, x, 
  10.130 +                if ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, 
  10.131                                             x & ~PGT_validated)) != x) )
  10.132                      goto again;
  10.133                  /* We cleared the 'valid bit' so we must do the clear up. */
  10.134 @@ -182,13 +202,13 @@ static inline void put_page_type(struct 
  10.135              }
  10.136          }
  10.137      }
  10.138 -    while ( unlikely((y = cmpxchg(&page->type_and_flags, x, nx)) != x) );
  10.139 +    while ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) != x) );
  10.140  }
  10.141  
  10.142  
  10.143  static inline int get_page_type(struct pfn_info *page, u32 type)
  10.144  {
  10.145 -    u32 nx, x, y = page->type_and_flags;
  10.146 +    u32 nx, x, y = page->u.inuse.type_info;
  10.147   again:
  10.148      do {
  10.149          x  = y;
  10.150 @@ -218,7 +238,7 @@ static inline int get_page_type(struct p
  10.151          else if ( unlikely(!(x & PGT_validated)) )
  10.152          {
  10.153              /* Someone else is updating validation of this page. Wait... */
  10.154 -            while ( (y = page->type_and_flags) != x )
  10.155 +            while ( (y = page->u.inuse.type_info) != x )
  10.156              {
  10.157                  rep_nop();
  10.158                  barrier();
  10.159 @@ -226,7 +246,7 @@ static inline int get_page_type(struct p
  10.160              goto again;
  10.161          }
  10.162      }
  10.163 -    while ( unlikely((y = cmpxchg(&page->type_and_flags, x, nx)) != x) );
  10.164 +    while ( unlikely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) != x) );
  10.165  
  10.166      if ( unlikely(!(nx & PGT_validated)) )
  10.167      {
  10.168 @@ -238,7 +258,7 @@ static inline int get_page_type(struct p
  10.169              put_page_type(page);
  10.170              return 0;
  10.171          }
  10.172 -        set_bit(_PGT_validated, &page->type_and_flags);
  10.173 +        set_bit(_PGT_validated, &page->u.inuse.type_info);
  10.174      }
  10.175  
  10.176      return 1;
  10.177 @@ -268,11 +288,11 @@ static inline int get_page_and_type(stru
  10.178  }
  10.179  
  10.180  #define ASSERT_PAGE_IS_TYPE(_p, _t)                \
  10.181 -    ASSERT(((_p)->type_and_flags & PGT_type_mask) == (_t));  \
  10.182 -    ASSERT(((_p)->type_and_flags & PGT_count_mask) != 0)
  10.183 +    ASSERT(((_p)->u.inuse.type_info & PGT_type_mask) == (_t));  \
  10.184 +    ASSERT(((_p)->u.inuse.type_info & PGT_count_mask) != 0)
  10.185  #define ASSERT_PAGE_IS_DOMAIN(_p, _d)              \
  10.186 -    ASSERT(((_p)->count_and_flags & PGC_count_mask) != 0);  \
  10.187 -    ASSERT((_p)->u.domain == (_d))
  10.188 +    ASSERT(((_p)->u.inuse.count_info & PGC_count_mask) != 0);  \
  10.189 +    ASSERT((_p)->u.inuse.domain == (_d))
  10.190  
  10.191  int check_descriptor(unsigned long *d);
  10.192  
    11.1 --- a/xen/include/asm-x86/shadow.h	Tue Jul 27 13:17:38 2004 +0000
    11.2 +++ b/xen/include/asm-x86/shadow.h	Tue Jul 27 13:40:31 2004 +0000
    11.3 @@ -120,9 +120,9 @@ static inline int __mark_dirty( struct m
    11.4          SH_LOG("mark_dirty OOR! mfn=%x pfn=%x max=%x (mm %p)",
    11.5                 mfn, pfn, m->shadow_dirty_bitmap_size, m );
    11.6          SH_LOG("dom=%u caf=%08x taf=%08x\n", 
    11.7 -               frame_table[mfn].u.domain->domain,
    11.8 -               frame_table[mfn].count_and_flags, 
    11.9 -               frame_table[mfn].type_and_flags );
   11.10 +               frame_table[mfn].u.inuse.domain->domain,
   11.11 +               frame_table[mfn].u.inuse.count_info, 
   11.12 +               frame_table[mfn].u.inuse.type_info );
   11.13      }
   11.14  
   11.15      return rc;