ia64/xen-unstable

changeset 4215:170dd1839b49

bitkeeper revision 1.1236.32.13 (423c3ffad8-_voFAAISKCGhZl3FYWQ)

Merge fleming.research:/scratch/fleming/mafetter/xen.work/save
into fleming.research:/scratch/fleming/mafetter/xen.work

Signed-off-by: michael.fetterman@cl.cam.ac.uk
author mafetter@fleming.research
date Sat Mar 19 15:06:34 2005 +0000 (2005-03-19)
parents d509bef98bd9 6352a018ed51
children 2e28ec68d40b
files xen/arch/x86/shadow.c xen/include/asm-x86/mm.h
line diff
     1.1 --- a/xen/arch/x86/shadow.c	Sat Mar 19 14:49:05 2005 +0000
     1.2 +++ b/xen/arch/x86/shadow.c	Sat Mar 19 15:06:34 2005 +0000
     1.3 @@ -73,8 +73,9 @@ shadow_promote(struct domain *d, unsigne
     1.4      FSH_LOG("shadow_promote gpfn=%p gmfn=%p nt=%p min=%p max=%p",
     1.5              gpfn, gmfn, new_type, min_type, max_type);
     1.6  
     1.7 -    if ( min_type <= max_type )
     1.8 -        shadow_remove_all_write_access(d, min_type, max_type, gpfn, gmfn);
     1.9 +    if ( (min_type <= max_type) &&
    1.10 +         !shadow_remove_all_write_access(d, min_type, max_type, gpfn, gmfn) )
    1.11 +        return 0;
    1.12  
    1.13      // To convert this page to use as a page table, the writable count
    1.14      // should now be zero.  Test this by grabbing the page as an page table,
    1.15 @@ -90,7 +91,7 @@ shadow_promote(struct domain *d, unsigne
    1.16      // shadow_lock() and move the shadow code to BIGLOCK().
    1.17      //
    1.18      if ( unlikely(!get_page(page, d)) )
    1.19 -        BUG();
    1.20 +        BUG(); // XXX -- needs more thought for a graceful failure
    1.21      if ( unlikely(test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info)) )
    1.22      {
    1.23          pinned = 1;
    1.24 @@ -98,8 +99,8 @@ shadow_promote(struct domain *d, unsigne
    1.25      }
    1.26      if ( get_page_type(page, PGT_base_page_table) )
    1.27      {
    1.28 +        set_bit(_PGC_page_table, &page->count_info);
    1.29          put_page_type(page);
    1.30 -        set_bit(_PGC_page_table, &page->count_info);
    1.31      }
    1.32      else
    1.33      {
    1.34 @@ -111,7 +112,7 @@ shadow_promote(struct domain *d, unsigne
    1.35  
    1.36      // Now put the type back to writable...
    1.37      if ( unlikely(!get_page_type(page, PGT_writable_page)) )
    1.38 -        BUG();
    1.39 +        BUG(); // XXX -- needs more thought for a graceful failure
    1.40      if ( unlikely(pinned) )
    1.41      {
    1.42          if ( unlikely(test_and_set_bit(_PGT_pinned,
    1.43 @@ -215,14 +216,14 @@ alloc_shadow_page(struct domain *d,
    1.44      {
    1.45      case PGT_l1_shadow:
    1.46          if ( !shadow_promote(d, gpfn, gmfn, psh_type) )
    1.47 -            goto oom;
    1.48 +            goto fail;
    1.49          perfc_incr(shadow_l1_pages);
    1.50          d->arch.shadow_page_count++;
    1.51          break;
    1.52  
    1.53      case PGT_l2_shadow:
    1.54          if ( !shadow_promote(d, gpfn, gmfn, psh_type) )
    1.55 -            goto oom;
    1.56 +            goto fail;
    1.57          perfc_incr(shadow_l2_pages);
    1.58          d->arch.shadow_page_count++;
    1.59          if ( PGT_l2_page_table == PGT_root_page_table )
    1.60 @@ -236,7 +237,7 @@ alloc_shadow_page(struct domain *d,
    1.61          // pinning.
    1.62          //
    1.63          if ( !shadow_promote(d, gpfn, gmfn, PGT_l1_shadow) )
    1.64 -            goto oom;
    1.65 +            goto fail;
    1.66          perfc_incr(hl2_table_pages);
    1.67          d->arch.hl2_page_count++;
    1.68          if ( shadow_mode_external(d) &&
    1.69 @@ -263,7 +264,7 @@ alloc_shadow_page(struct domain *d,
    1.70  
    1.71      return smfn;
    1.72  
    1.73 -  oom:
    1.74 +  fail:
    1.75      FSH_LOG("promotion of pfn=%p mfn=%p failed!  external gnttab refs?\n",
    1.76              gpfn, gmfn);
    1.77      free_domheap_page(page);
    1.78 @@ -1777,7 +1778,7 @@ static u32 remove_all_write_access_in_pt
    1.79      return count;
    1.80  }
    1.81  
    1.82 -u32 shadow_remove_all_write_access(
    1.83 +int shadow_remove_all_write_access(
    1.84      struct domain *d, unsigned min_type, unsigned max_type,
    1.85      unsigned long gpfn, unsigned long gmfn)
    1.86  {
    1.87 @@ -1796,10 +1797,13 @@ u32 shadow_remove_all_write_access(
    1.88           PGT_writable_page )
    1.89      {
    1.90          write_refs = (frame_table[gmfn].u.inuse.type_info & PGT_count_mask);
    1.91 +        if ( write_refs &&
    1.92 +             (frame_table[gmfn].u.inuse.type_info & PGT_pinned) )
    1.93 +            write_refs--;
    1.94          if ( write_refs == 0 )
    1.95          {
    1.96              perfc_incrc(remove_write_access_easy);
    1.97 -            return 0;
    1.98 +            return 1;
    1.99          }
   1.100      }
   1.101  
   1.102 @@ -1816,12 +1820,16 @@ u32 shadow_remove_all_write_access(
   1.103                  case PGT_l1_shadow:
   1.104                      count +=
   1.105                          remove_all_write_access_in_ptpage(d, a->smfn, gmfn);
   1.106 +                    if ( count == write_refs )
   1.107 +                        return 1;
   1.108                      break;
   1.109                  case PGT_l2_shadow:
   1.110                      if ( sl1mfn )
   1.111                          count +=
   1.112                              remove_all_write_access_in_ptpage(d, a->smfn,
   1.113                                                                sl1mfn);
   1.114 +                    if ( count == write_refs )
   1.115 +                        return 1;
   1.116                      break;
   1.117                  case PGT_hl2_shadow:
   1.118                      // nothing to do here...
   1.119 @@ -1835,7 +1843,10 @@ u32 shadow_remove_all_write_access(
   1.120          }
   1.121      }
   1.122  
   1.123 -    return count;
   1.124 +    FSH_LOG("%s: looking for %d refs, found %d refs\n",
   1.125 +            __func__, write_refs, count);
   1.126 +
   1.127 +    return 0;
   1.128  }
   1.129  
   1.130  static u32 remove_all_access_in_page(
     2.1 --- a/xen/include/asm-x86/mm.h	Sat Mar 19 14:49:05 2005 +0000
     2.2 +++ b/xen/include/asm-x86/mm.h	Sat Mar 19 15:06:34 2005 +0000
     2.3 @@ -168,7 +168,7 @@ void init_frametable(void);
     2.4  int alloc_page_type(struct pfn_info *page, unsigned int type);
     2.5  void free_page_type(struct pfn_info *page, unsigned int type);
     2.6  extern void invalidate_shadow_ldt(struct exec_domain *d);
     2.7 -extern u32 shadow_remove_all_write_access(
     2.8 +extern int shadow_remove_all_write_access(
     2.9      struct domain *d, unsigned min_type, unsigned max_type,
    2.10      unsigned long gpfn, unsigned long gmfn);
    2.11  extern u32 shadow_remove_all_access( struct domain *d, unsigned long gmfn);