direct-io.hg

changeset 2277:3addc3532bc7

bitkeeper revision 1.1159.1.77 (4123798fK4KZK8amlRcWgvrb90qfbQ)

Merge scramble.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xeno
author kaf24@scramble.cl.cam.ac.uk
date Wed Aug 18 15:45:19 2004 +0000 (2004-08-18)
parents b2f1fa774452 20d763e472ae
children 1419a54e36ca f96771608bc3
files linux-2.4.26-xen-sparse/arch/xen/mm/ioremap.c linux-2.6.7-xen-sparse/arch/xen/i386/mm/ioremap.c linux-2.6.7-xen-sparse/drivers/xen/netback/netback.c linux-2.6.7-xen-sparse/drivers/xen/privcmd/privcmd.c tools/libxc/xc.h tools/libxc/xc_private.c xen/arch/x86/memory.c xen/common/dom_mem_ops.c xen/include/asm-x86/mm.h xen/include/hypervisor-ifs/dom0_ops.h xen/include/hypervisor-ifs/hypervisor-if.h
line diff
     1.1 --- a/linux-2.4.26-xen-sparse/arch/xen/mm/ioremap.c	Wed Aug 18 14:27:38 2004 +0000
     1.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/mm/ioremap.c	Wed Aug 18 15:45:19 2004 +0000
     1.3 @@ -117,10 +117,9 @@ int direct_remap_area_pages(struct mm_st
     1.4  
     1.5      if ( domid != 0 )
     1.6      {
     1.7 -        u[0].val  = (unsigned long)(domid<<16) & ~0xFFFFUL;
     1.8 -        u[0].ptr  = (unsigned long)(domid<< 0) & ~0xFFFFUL;
     1.9 -        u[0].ptr |= MMU_EXTENDED_COMMAND;
    1.10 -        u[0].val |= MMUEXT_SET_SUBJECTDOM;
    1.11 +        u[0].ptr  = MMU_EXTENDED_COMMAND;
    1.12 +        u[0].val  = MMUEXT_SET_FOREIGNDOM;
    1.13 +        u[0].val |= (unsigned long)domid << 16;
    1.14          v = w = &u[1];
    1.15      }
    1.16      else
     2.1 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/mm/ioremap.c	Wed Aug 18 14:27:38 2004 +0000
     2.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/mm/ioremap.c	Wed Aug 18 15:45:19 2004 +0000
     2.3 @@ -417,10 +417,9 @@ int direct_remap_area_pages(struct mm_st
     2.4  
     2.5      if ( domid != 0 )
     2.6      {
     2.7 -        u[0].val  = (unsigned long)(domid<<16) & ~0xFFFFUL;
     2.8 -        u[0].ptr  = (unsigned long)(domid<< 0) & ~0xFFFFUL;
     2.9 -        u[0].ptr |= MMU_EXTENDED_COMMAND;
    2.10 -        u[0].val |= MMUEXT_SET_SUBJECTDOM;
    2.11 +        u[0].ptr  = MMU_EXTENDED_COMMAND;
    2.12 +        u[0].val  = MMUEXT_SET_FOREIGNDOM;
    2.13 +        u[0].val |= (unsigned long)domid << 16;
    2.14          v = w = &u[1];
    2.15      }
    2.16      else
     3.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/netback/netback.c	Wed Aug 18 14:27:38 2004 +0000
     3.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/netback/netback.c	Wed Aug 18 15:45:19 2004 +0000
     3.3 @@ -205,11 +205,10 @@ static void net_rx_action(unsigned long 
     3.4          new_mfn = get_new_mfn();
     3.5          
     3.6          mmu[0].ptr  = (new_mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
     3.7 -        mmu[0].val  = __pa(vdata) >> PAGE_SHIFT;        
     3.8 -        mmu[1].val  = (unsigned long)(netif->domid<<16) & ~0xFFFFUL;
     3.9 -        mmu[1].ptr  = (unsigned long)(netif->domid<< 0) & ~0xFFFFUL;
    3.10 -        mmu[1].ptr |= MMU_EXTENDED_COMMAND;
    3.11 -        mmu[1].val |= MMUEXT_SET_SUBJECTDOM;
    3.12 +        mmu[0].val  = __pa(vdata) >> PAGE_SHIFT;  
    3.13 +        mmu[1].ptr  = MMU_EXTENDED_COMMAND;
    3.14 +        mmu[1].val  = MMUEXT_SET_FOREIGNDOM;      
    3.15 +        mmu[1].val |= (unsigned long)netif->domid << 16;
    3.16          mmu[2].ptr  = (mdata & PAGE_MASK) | MMU_EXTENDED_COMMAND;
    3.17          mmu[2].val  = MMUEXT_REASSIGN_PAGE;
    3.18  
     4.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/privcmd/privcmd.c	Wed Aug 18 14:27:38 2004 +0000
     4.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/privcmd/privcmd.c	Wed Aug 18 15:45:19 2004 +0000
     4.3 @@ -140,10 +140,9 @@ static int privcmd_ioctl(struct inode *i
     4.4  
     4.5          if ( m.dom != 0 )
     4.6          {
     4.7 -            u[0].val  = (unsigned long)(m.dom<<16) & ~0xFFFFUL;
     4.8 -            u[0].ptr  = (unsigned long)(m.dom<< 0) & ~0xFFFFUL;
     4.9 -            u[0].ptr |= MMU_EXTENDED_COMMAND;
    4.10 -            u[0].val |= MMUEXT_SET_SUBJECTDOM;
    4.11 +            u[0].ptr  = MMU_EXTENDED_COMMAND;
    4.12 +            u[0].val  = MMUEXT_SET_FOREIGNDOM;
    4.13 +            u[0].val |= (unsigned long)m.dom << 16;
    4.14              v = w = &u[1];
    4.15          }
    4.16          else
     5.1 --- a/tools/libxc/xc.h	Wed Aug 18 14:27:38 2004 +0000
     5.2 +++ b/tools/libxc/xc.h	Wed Aug 18 15:45:19 2004 +0000
     5.3 @@ -153,7 +153,7 @@ int xc_rrobin_global_set(int xc_handle, 
     5.4  
     5.5  int xc_rrobin_global_get(int xc_handle, u64 *slice);
     5.6  
     5.7 -#define DOMID_SELF              (0x7FFEU)
     5.8 +#define DOMID_SELF              (0x7FF0U)
     5.9  
    5.10  typedef struct {
    5.11  #define EVTCHNSTAT_closed       0  /* Chennel is not in use.                 */
     6.1 --- a/tools/libxc/xc_private.c	Wed Aug 18 14:27:38 2004 +0000
     6.2 +++ b/tools/libxc/xc_private.c	Wed Aug 18 15:45:19 2004 +0000
     6.3 @@ -228,11 +228,9 @@ static int flush_mmu_updates(int xc_hand
     6.4      if ( mmu->idx == FIRST_MMU_UPDATE )
     6.5          return 0;
     6.6  
     6.7 -    /* The first two requests set the correct subject domain (PTS and GPS). */
     6.8 -    mmu->updates[0].val  = (unsigned long)(mmu->subject<<16) & ~0xFFFFUL;
     6.9 -    mmu->updates[0].ptr  = (unsigned long)(mmu->subject<< 0) & ~0xFFFFUL;
    6.10 -    mmu->updates[0].ptr |= MMU_EXTENDED_COMMAND;
    6.11 -    mmu->updates[0].val |= MMUEXT_SET_SUBJECTDOM | SET_PAGETABLE_SUBJECTDOM;
    6.12 +    mmu->updates[0].ptr  = MMU_EXTENDED_COMMAND;
    6.13 +    mmu->updates[0].val  = MMUEXT_SET_FOREIGNDOM;
    6.14 +    mmu->updates[0].val |= (unsigned long)mmu->subject << 16;
    6.15  
    6.16      hypercall.op     = __HYPERVISOR_mmu_update;
    6.17      hypercall.arg[0] = (unsigned long)mmu->updates;
     7.1 --- a/xen/arch/x86/memory.c	Wed Aug 18 14:27:38 2004 +0000
     7.2 +++ b/xen/arch/x86/memory.c	Wed Aug 18 15:45:19 2004 +0000
     7.3 @@ -127,14 +127,15 @@ static struct {
     7.4  #define DOP_RELOAD_LDT  (1<<1) /* Reload the LDT shadow mapping. */
     7.5      unsigned long       deferred_ops;
     7.6      unsigned long       cr0;
     7.7 -    /* General-Purpose Subject, Page-Table Subject */
     7.8 -    struct domain *gps, *pts;
     7.9 +    /* If non-NULL, specifies a foreign subject domain for some operations. */
    7.10 +    struct domain      *foreign;
    7.11  } percpu_info[NR_CPUS] __cacheline_aligned;
    7.12  
    7.13 -/* Determine the current General-Purpose Subject or Page-Table Subject. */
    7.14 -#define PTS (percpu_info[smp_processor_id()].pts ? : current)
    7.15 -#define GPS (percpu_info[smp_processor_id()].gps ? : current)
    7.16 -
    7.17 +/*
    7.18 + * Returns the current foreign domain; defaults to the currently-executing
    7.19 + * domain if a foreign override hasn't been specified.
    7.20 + */
    7.21 +#define FOREIGNDOM (percpu_info[smp_processor_id()].foreign ? : current)
    7.22  
    7.23  void ptwr_init_backpointers(void);
    7.24  
    7.25 @@ -283,7 +284,9 @@ static inline void set_l1_page_va(unsign
    7.26   *     frame if it is mapped by a different L2 table. This is sufficient and
    7.27   *     also necessary to allow validation of an L2 table mapping itself.
    7.28   */
    7.29 -static int get_linear_pagetable(l2_pgentry_t l2e, unsigned long pfn)
    7.30 +static int 
    7.31 +get_linear_pagetable(
    7.32 +    l2_pgentry_t l2e, unsigned long pfn, struct domain *d)
    7.33  {
    7.34      u32 x, y;
    7.35      struct pfn_info *page;
    7.36 @@ -297,7 +300,7 @@ static int get_linear_pagetable(l2_pgent
    7.37      if ( (l2_pgentry_val(l2e) >> PAGE_SHIFT) != pfn )
    7.38      {
    7.39          /* Make sure the mapped frame belongs to the correct domain. */
    7.40 -        if ( unlikely(!get_page_from_pagenr(l2_pgentry_to_pagenr(l2e), PTS)) )
    7.41 +        if ( unlikely(!get_page_from_pagenr(l2_pgentry_to_pagenr(l2e), d)) )
    7.42              return 0;
    7.43  
    7.44          /*
    7.45 @@ -323,7 +326,9 @@ static int get_linear_pagetable(l2_pgent
    7.46  }
    7.47  
    7.48  
    7.49 -static int get_page_from_l1e(l1_pgentry_t l1e)
    7.50 +static int
    7.51 +get_page_from_l1e(
    7.52 +    l1_pgentry_t l1e, struct domain *d)
    7.53  {
    7.54      unsigned long l1v = l1_pgentry_val(l1e);
    7.55      unsigned long pfn = l1_pgentry_to_pagenr(l1e);
    7.56 @@ -353,19 +358,21 @@ static int get_page_from_l1e(l1_pgentry_
    7.57      if ( l1v & _PAGE_RW )
    7.58      {
    7.59          if ( unlikely(!get_page_and_type_from_pagenr(
    7.60 -            pfn, PGT_writeable_page, GPS)) )
    7.61 +            pfn, PGT_writeable_page, d)) )
    7.62              return 0;
    7.63          set_bit(_PGC_tlb_flush_on_type_change, 
    7.64                  &frame_table[pfn].u.inuse.count_info);
    7.65          return 1;
    7.66      }
    7.67  
    7.68 -    return get_page_from_pagenr(pfn, GPS);
    7.69 +    return get_page_from_pagenr(pfn, d);
    7.70  }
    7.71  
    7.72  
    7.73  /* NB. Virtual address 'l2e' maps to a machine address within frame 'pfn'. */
    7.74 -static int get_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn)
    7.75 +static int 
    7.76 +get_page_from_l2e(
    7.77 +    l2_pgentry_t l2e, unsigned long pfn, struct domain *d)
    7.78  {
    7.79      if ( !(l2_pgentry_val(l2e) & _PAGE_PRESENT) )
    7.80          return 1;
    7.81 @@ -378,8 +385,8 @@ static int get_page_from_l2e(l2_pgentry_
    7.82      }
    7.83  
    7.84      if ( unlikely(!get_page_and_type_from_pagenr(
    7.85 -        l2_pgentry_to_pagenr(l2e), PGT_l1_page_table, PTS)) )
    7.86 -        return get_linear_pagetable(l2e, pfn);
    7.87 +        l2_pgentry_to_pagenr(l2e), PGT_l1_page_table, d)) )
    7.88 +        return get_linear_pagetable(l2e, pfn, d);
    7.89  
    7.90      return 1;
    7.91  }
    7.92 @@ -423,14 +430,15 @@ static void put_page_from_l2e(l2_pgentry
    7.93  
    7.94  static int alloc_l2_table(struct pfn_info *page)
    7.95  {
    7.96 -    unsigned long page_nr = page - frame_table;
    7.97 -    l2_pgentry_t *pl2e;
    7.98 -    int i;
    7.99 +    struct domain *d = page->u.inuse.domain;
   7.100 +    unsigned long  page_nr = page_to_pfn(page);
   7.101 +    l2_pgentry_t  *pl2e;
   7.102 +    int            i;
   7.103     
   7.104      pl2e = map_domain_mem(page_nr << PAGE_SHIFT);
   7.105  
   7.106      for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ ) {
   7.107 -        if ( unlikely(!get_page_from_l2e(pl2e[i], page_nr)) )
   7.108 +        if ( unlikely(!get_page_from_l2e(pl2e[i], page_nr, d)) )
   7.109              goto fail;
   7.110          set_l1_page_va(l2_pgentry_val(pl2e[i]) >> PAGE_SHIFT, i);
   7.111      }
   7.112 @@ -461,14 +469,15 @@ static int alloc_l2_table(struct pfn_inf
   7.113  
   7.114  static int alloc_l1_table(struct pfn_info *page)
   7.115  {
   7.116 -    unsigned long page_nr = page - frame_table;
   7.117 -    l1_pgentry_t *pl1e;
   7.118 -    int i;
   7.119 +    struct domain *d = page->u.inuse.domain;
   7.120 +    unsigned long  page_nr = page_to_pfn(page);
   7.121 +    l1_pgentry_t  *pl1e;
   7.122 +    int            i;
   7.123  
   7.124      pl1e = map_domain_mem(page_nr << PAGE_SHIFT);
   7.125  
   7.126      for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
   7.127 -        if ( unlikely(!get_page_from_l1e(pl1e[i])) )
   7.128 +        if ( unlikely(!get_page_from_l1e(pl1e[i], d)) )
   7.129              goto fail;
   7.130  
   7.131      unmap_domain_mem(pl1e);
   7.132 @@ -552,7 +561,7 @@ static int mod_l2_entry(l2_pgentry_t *pl
   7.133          if ( ((l2_pgentry_val(ol2e) ^ l2_pgentry_val(nl2e)) & ~0xffe) == 0 )
   7.134              return update_l2e(pl2e, ol2e, nl2e);
   7.135  
   7.136 -        if ( unlikely(!get_page_from_l2e(nl2e, pfn)) )
   7.137 +        if ( unlikely(!get_page_from_l2e(nl2e, pfn, current)) )
   7.138              return 0;
   7.139          
   7.140          set_l1_page_va(l2_pgentry_val(nl2e) >> PAGE_SHIFT,
   7.141 @@ -615,7 +624,7 @@ static int mod_l1_entry(l1_pgentry_t *pl
   7.142          if ( ((l1_pgentry_val(ol1e) ^ l1_pgentry_val(nl1e)) & ~0xffc) == 0 )
   7.143              return update_l1e(pl1e, ol1e, nl1e);
   7.144  
   7.145 -        if ( unlikely(!get_page_from_l1e(nl1e)) )
   7.146 +        if ( unlikely(!get_page_from_l1e(nl1e, FOREIGNDOM)) )
   7.147              return 0;
   7.148          
   7.149          if ( unlikely(!update_l1e(pl1e, ol1e, nl1e)) )
   7.150 @@ -669,42 +678,28 @@ int alloc_page_type(struct pfn_info *pag
   7.151  
   7.152  void free_page_type(struct pfn_info *page, unsigned int type)
   7.153  {
   7.154 +    struct domain *d = page->u.inuse.domain;
   7.155 +
   7.156      switch ( type )
   7.157      {
   7.158      case PGT_l1_page_table:
   7.159          free_l1_table(page);
   7.160 -        if ( unlikely(current->mm.shadow_mode) && 
   7.161 -             (get_shadow_status(&current->mm, 
   7.162 -                                page-frame_table) & PSH_shadowed) )
   7.163 -        {
   7.164 -            /*
   7.165 -             * Using 'current->mm' is safe and correct because page-table pages
   7.166 -             * are not shared across domains. Updates to such pages' types are
   7.167 -             * thus only done within the context of the owning domain. The one
   7.168 -             * exception is when destroying a domain; however, this is not a
   7.169 -             * problem as the currently-executing domain will not have this MFN
   7.170 -             * shadowed, and at domain end-of-day we explicitly unshadow
   7.171 -             * everything so that nothing will get left lying around.
   7.172 -             */
   7.173 -            unshadow_table( page-frame_table, type );
   7.174 -            put_shadow_status(&current->mm);
   7.175 -        }
   7.176          break;
   7.177  
   7.178      case PGT_l2_page_table:
   7.179          free_l2_table(page);
   7.180 -        if ( unlikely(current->mm.shadow_mode) && 
   7.181 -             (get_shadow_status(&current->mm, 
   7.182 -                                page-frame_table) & PSH_shadowed) )
   7.183 -        {
   7.184 -            unshadow_table( page-frame_table, type );
   7.185 -            put_shadow_status(&current->mm);
   7.186 -        }
   7.187          break;
   7.188  
   7.189      default:
   7.190          BUG();
   7.191      }
   7.192 +
   7.193 +    if ( unlikely(d->mm.shadow_mode) && 
   7.194 +         (get_shadow_status(&d->mm, page_to_pfn(page)) & PSH_shadowed) )
   7.195 +    {
   7.196 +        unshadow_table(page_to_pfn(page), type);
   7.197 +        put_shadow_status(&d->mm);
   7.198 +    }
   7.199  }
   7.200  
   7.201  
   7.202 @@ -719,8 +714,6 @@ static int do_extended_command(unsigned 
   7.203      u32 x, y;
   7.204      domid_t domid;
   7.205  
   7.206 -    cleanup_writable_pagetable(PTWR_CLEANUP_ACTIVE | PTWR_CLEANUP_INACTIVE);
   7.207 -
   7.208      switch ( cmd )
   7.209      {
   7.210      case MMUEXT_PIN_L1_TABLE:
   7.211 @@ -728,7 +721,7 @@ static int do_extended_command(unsigned 
   7.212          okay = get_page_and_type_from_pagenr(
   7.213              pfn, 
   7.214              (cmd==MMUEXT_PIN_L2_TABLE) ? PGT_l2_page_table : PGT_l1_page_table,
   7.215 -            PTS);
   7.216 +            FOREIGNDOM);
   7.217          if ( unlikely(!okay) )
   7.218          {
   7.219              MEM_LOG("Error while pinning pfn %08lx", pfn);
   7.220 @@ -748,7 +741,7 @@ static int do_extended_command(unsigned 
   7.221          break;
   7.222  
   7.223      case MMUEXT_UNPIN_TABLE:
   7.224 -        if ( unlikely(!(okay = get_page_from_pagenr(pfn, PTS))) )
   7.225 +        if ( unlikely(!(okay = get_page_from_pagenr(pfn, FOREIGNDOM))) )
   7.226          {
   7.227              MEM_LOG("Page %08lx bad domain (dom=%p)",
   7.228                      ptr, page->u.inuse.domain);
   7.229 @@ -829,8 +822,8 @@ static int do_extended_command(unsigned 
   7.230          break;
   7.231      }
   7.232  
   7.233 -    case MMUEXT_SET_SUBJECTDOM:
   7.234 -        domid = ((domid_t)((ptr&~0xFFFF)|(val>>16)));
   7.235 +    case MMUEXT_SET_FOREIGNDOM:
   7.236 +        domid = (domid_t)(val >> 16);
   7.237  
   7.238          if ( !IS_PRIV(d) )
   7.239          {
   7.240 @@ -840,12 +833,11 @@ static int do_extended_command(unsigned 
   7.241          }
   7.242          else
   7.243          {
   7.244 -            if ( percpu_info[cpu].gps != NULL )
   7.245 -                put_domain(percpu_info[cpu].gps);
   7.246 -            percpu_info[cpu].gps = find_domain_by_id(domid);
   7.247 -            percpu_info[cpu].pts = (val & SET_PAGETABLE_SUBJECTDOM) ? 
   7.248 -                percpu_info[cpu].gps : NULL;
   7.249 -            if ( percpu_info[cpu].gps == NULL )
   7.250 +            if ( (e = percpu_info[cpu].foreign) != NULL )
   7.251 +                put_domain(e);
   7.252 +
   7.253 +            percpu_info[cpu].foreign = e = find_domain_by_id(domid);
   7.254 +            if ( e == NULL )
   7.255              {
   7.256                  MEM_LOG("Unknown domain '%u'", domid);
   7.257                  okay = 0;
   7.258 @@ -861,9 +853,10 @@ static int do_extended_command(unsigned 
   7.259              break;
   7.260          }
   7.261  
   7.262 -        if ( unlikely((e = percpu_info[cpu].gps) == NULL) )
   7.263 +        e = percpu_info[cpu].foreign;
   7.264 +        if ( unlikely(e == NULL) )
   7.265          {
   7.266 -            MEM_LOG("No GPS to reassign pfn %08lx to", pfn);
   7.267 +            MEM_LOG("No FOREIGNDOM to reassign pfn %08lx to", pfn);
   7.268              okay = 0;
   7.269              break;
   7.270          }
   7.271 @@ -941,10 +934,10 @@ static int do_extended_command(unsigned 
   7.272          spin_unlock(&e->page_alloc_lock);
   7.273          break;
   7.274  
   7.275 -    case MMUEXT_RESET_SUBJECTDOM:
   7.276 -        if ( percpu_info[cpu].gps != NULL )
   7.277 -            put_domain(percpu_info[cpu].gps);
   7.278 -        percpu_info[cpu].gps = percpu_info[cpu].pts = NULL;
   7.279 +    case MMUEXT_CLEAR_FOREIGNDOM:
   7.280 +        if ( (e = percpu_info[cpu].foreign) != NULL )
   7.281 +            put_domain(e);
   7.282 +        percpu_info[cpu].foreign = NULL;
   7.283          break;
   7.284  
   7.285      default:
   7.286 @@ -992,7 +985,7 @@ int do_mmu_update(mmu_update_t *ureqs, i
   7.287               * MMU_NORMAL_PT_UPDATE: Normal update to any level of page table.
   7.288               */
   7.289          case MMU_NORMAL_PT_UPDATE:
   7.290 -            if ( unlikely(!get_page_from_pagenr(pfn, PTS)) )
   7.291 +            if ( unlikely(!get_page_from_pagenr(pfn, current)) )
   7.292              {
   7.293                  MEM_LOG("Could not get page for normal update");
   7.294                  break;
   7.295 @@ -1064,7 +1057,7 @@ int do_mmu_update(mmu_update_t *ureqs, i
   7.296              break;
   7.297  
   7.298          case MMU_MACHPHYS_UPDATE:
   7.299 -            if ( unlikely(!get_page_from_pagenr(pfn, GPS)) )
   7.300 +            if ( unlikely(!get_page_from_pagenr(pfn, FOREIGNDOM)) )
   7.301              {
   7.302                  MEM_LOG("Could not get page for mach->phys update");
   7.303                  break;
   7.304 @@ -1121,10 +1114,10 @@ int do_mmu_update(mmu_update_t *ureqs, i
   7.305      if ( deferred_ops & DOP_RELOAD_LDT )
   7.306          (void)map_ldt_shadow_page(0);
   7.307  
   7.308 -    if ( unlikely(percpu_info[cpu].gps != NULL) )
   7.309 +    if ( unlikely(percpu_info[cpu].foreign != NULL) )
   7.310      {
   7.311 -        put_domain(percpu_info[cpu].gps);
   7.312 -        percpu_info[cpu].gps = percpu_info[cpu].pts = NULL;
   7.313 +        put_domain(percpu_info[cpu].foreign);
   7.314 +        percpu_info[cpu].foreign = NULL;
   7.315      }
   7.316  
   7.317      if ( unlikely(success_count != NULL) )
   7.318 @@ -1215,7 +1208,7 @@ int do_update_va_mapping_otherdomain(uns
   7.319  
   7.320      cleanup_writable_pagetable(PTWR_CLEANUP_ACTIVE | PTWR_CLEANUP_INACTIVE);
   7.321  
   7.322 -    percpu_info[cpu].gps = d = find_domain_by_id(domid);
   7.323 +    percpu_info[cpu].foreign = d = find_domain_by_id(domid);
   7.324      if ( unlikely(d == NULL) )
   7.325      {
   7.326          MEM_LOG("Unknown domain '%u'", domid);
   7.327 @@ -1225,7 +1218,7 @@ int do_update_va_mapping_otherdomain(uns
   7.328      rc = do_update_va_mapping(page_nr, val, flags);
   7.329  
   7.330      put_domain(d);
   7.331 -    percpu_info[cpu].gps = NULL;
   7.332 +    percpu_info[cpu].foreign = NULL;
   7.333  
   7.334      return rc;
   7.335  }
   7.336 @@ -1314,7 +1307,7 @@ void ptwr_reconnect_disconnected(unsigne
   7.337          }
   7.338          if (unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT))
   7.339              put_page_from_l1e(ol1e);
   7.340 -        if (unlikely(!get_page_from_l1e(nl1e)))
   7.341 +        if (unlikely(!get_page_from_l1e(nl1e, current)))
   7.342              BUG();
   7.343      }
   7.344      unmap_domain_mem(pl1e);
   7.345 @@ -1381,7 +1374,7 @@ void ptwr_flush_inactive(void)
   7.346                  continue;
   7.347              if (unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT))
   7.348                  put_page_from_l1e(ol1e);
   7.349 -            if (unlikely(!get_page_from_l1e(nl1e)))
   7.350 +            if (unlikely(!get_page_from_l1e(nl1e, current)))
   7.351                  BUG();
   7.352          }
   7.353          unmap_domain_mem(pl1e);
     8.1 --- a/xen/common/dom_mem_ops.c	Wed Aug 18 14:27:38 2004 +0000
     8.2 +++ b/xen/common/dom_mem_ops.c	Wed Aug 18 15:45:19 2004 +0000
     8.3 @@ -96,17 +96,13 @@ long do_dom_mem_op(unsigned int   op,
     8.4  		   domid_t        domid)
     8.5  {
     8.6      struct domain *d;
     8.7 -    long rc = -ENOSYS;
     8.8 +    long           rc;
     8.9  
    8.10 -    if (domid == DOMID_SELF)
    8.11 -	d = current;
    8.12 -    else
    8.13 -	d = find_domain_by_id(domid);
    8.14 -
    8.15 -    if (d==NULL)
    8.16 +    d = (domid == DOMID_SELF) ? current : find_domain_by_id(domid);
    8.17 +    if ( d == NULL )
    8.18  	return -ESRCH;
    8.19  
    8.20 -    switch( op )
    8.21 +    switch ( op )
    8.22      {
    8.23      case MEMOP_increase_reservation:
    8.24          rc = alloc_dom_mem(d, extent_list, nr_extents, extent_order);
    8.25 @@ -114,9 +110,12 @@ long do_dom_mem_op(unsigned int   op,
    8.26      case MEMOP_decrease_reservation:
    8.27          rc = free_dom_mem(d, extent_list, nr_extents, extent_order);
    8.28  	break;
    8.29 +    default:
    8.30 +        rc = -ENOSYS;
    8.31 +        break;
    8.32      }
    8.33  
    8.34 -    if (domid!=DOMID_SELF)
    8.35 +    if ( domid != DOMID_SELF )
    8.36  	put_domain(d);
    8.37  
    8.38      return rc;
     9.1 --- a/xen/include/asm-x86/mm.h	Wed Aug 18 14:27:38 2004 +0000
     9.2 +++ b/xen/include/asm-x86/mm.h	Wed Aug 18 15:45:19 2004 +0000
     9.3 @@ -147,7 +147,7 @@ static inline int get_page(struct pfn_in
     9.4          p  = np;
     9.5          if ( unlikely((x & PGC_count_mask) == 0) ||  /* Not allocated? */
     9.6               unlikely((nx & PGC_count_mask) == 0) || /* Count overflow? */
     9.7 -             unlikely(!IS_PRIV(domain) && p != domain) ) /* Wrong owner? */
     9.8 +             unlikely(p != domain) )                 /* Wrong owner? */
     9.9          {
    9.10              DPRINTK("Error pfn %08lx: ed=%p(%u), sd=%p(%u),"
    9.11                      " caf=%08x, taf=%08x\n",
    9.12 @@ -249,7 +249,8 @@ static inline int get_page_type(struct p
    9.13          /* Try to validate page type; drop the new reference on failure. */
    9.14          if ( unlikely(!alloc_page_type(page, type)) )
    9.15          {
    9.16 -            DPRINTK("Error while validating pfn %08lx for type %08x. caf=%08x taf=%08x\n",
    9.17 +            DPRINTK("Error while validating pfn %08lx for type %08x."
    9.18 +                    " caf=%08x taf=%08x\n",
    9.19                      page_to_pfn(page), type,
    9.20  		    page->u.inuse.count_info,
    9.21  		    page->u.inuse.type_info);
    10.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h	Wed Aug 18 14:27:38 2004 +0000
    10.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h	Wed Aug 18 15:45:19 2004 +0000
    10.3 @@ -19,7 +19,7 @@
    10.4   * This makes sure that old versions of dom0 tools will stop working in a
    10.5   * well-defined way (rather than crashing the machine, for instance).
    10.6   */
    10.7 -#define DOM0_INTERFACE_VERSION   0xAAAA0011
    10.8 +#define DOM0_INTERFACE_VERSION   0xAAAA0012
    10.9  
   10.10  #define MAX_DOMAIN_NAME    16
   10.11  
    11.1 --- a/xen/include/hypervisor-ifs/hypervisor-if.h	Wed Aug 18 14:27:38 2004 +0000
    11.2 +++ b/xen/include/hypervisor-ifs/hypervisor-if.h	Wed Aug 18 15:45:19 2004 +0000
    11.3 @@ -78,66 +78,56 @@
    11.4   * HYPERVISOR_mmu_update() accepts a list of (ptr, val) pairs.
    11.5   * ptr[1:0] specifies the appropriate MMU_* command.
    11.6   * 
    11.7 - * GPS (General-Purpose Subject)
    11.8 - * -----------------------------
    11.9 - *  This domain that must own all non-page-table pages that are involved in
   11.10 - *  MMU updates. By default it is the domain that executes mmu_update(). If the
   11.11 - *  caller has sufficient privilege then it can be changed by executing
   11.12 - *  MMUEXT_SET_SUBJECTDOM.
   11.13 - * 
   11.14 - * PTS (Page-Table Subject)
   11.15 - * ------------------------
   11.16 - *  This domain must own all the page-table pages that are subject to MMU
   11.17 - *  updates. By default it is the domain that executes mmu_update(). If the
   11.18 - *  caller has sufficient privilege then it can be changed by executing
   11.19 - *  MMUEXT_SET_SUBJECTDOM with val[14] (SET_PAGETABLE_SUBJECTDOM) set.
   11.20 + * FOREIGN DOMAIN (FD)
   11.21 + * -------------------
   11.22 + *  Some commands recognise an explicitly-declared foreign domain,
   11.23 + *  in which case they will operate with respect to the foreigner rather than
   11.24 + *  the calling domain. Where the FD has some effect, it is described below.
   11.25   * 
   11.26   * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
   11.27 - * Updates an entry in a page table.
   11.28 - * ptr[:2]  -- machine address of the page-table entry to modify [1]
   11.29 - * val      -- value to write [2]
   11.30 + * Updates an entry in a page table. If updating an L1 table, and the new
   11.31 + * table entry is valid/present, the mapped frame must belong to the FD, if
   11.32 + * an FD has been specified. If attempting to map an I/O page, then the FD
   11.33 + * is ignored, but the calling domain must have sufficient privilege.
   11.34 + * ptr[:2]  -- Machine address of the page-table entry to modify.
   11.35 + * val      -- Value to write.
   11.36   * 
   11.37   * ptr[1:0] == MMU_MACHPHYS_UPDATE:
   11.38   * Updates an entry in the machine->pseudo-physical mapping table.
   11.39 - * ptr[:2]  -- machine address within the frame whose mapping to modify [3]
   11.40 - * val      -- value to write into the mapping entry
   11.41 + * ptr[:2]  -- Machine address within the frame whose mapping to modify.
   11.42 + *             The frame must belong to the FD, if one is specified.
   11.43 + * val      -- Value to write into the mapping entry.
   11.44   *  
   11.45   * ptr[1:0] == MMU_EXTENDED_COMMAND:
   11.46 - * val[7:0] -- MMUEXT_* command
   11.47 + * val[7:0] -- MMUEXT_* command.
   11.48   * 
   11.49   *   val[7:0] == MMUEXT_(UN)PIN_*_TABLE:
   11.50 - *   ptr[:2]  -- machine address of frame to be (un)pinned as a p.t. page [1]
   11.51 + *   ptr[:2]  -- Machine address of frame to be (un)pinned as a p.t. page.
   11.52 + *               The frame must belong to the FD, if one is specified.
   11.53   * 
   11.54   *   val[7:0] == MMUEXT_NEW_BASEPTR:
   11.55 - *   ptr[:2]  -- machine address of new page-table base to install in MMU [1]
   11.56 + *   ptr[:2]  -- Machine address of new page-table base to install in MMU.
   11.57   * 
   11.58   *   val[7:0] == MMUEXT_TLB_FLUSH:
   11.59 - *   no additional arguments
   11.60 + *   No additional arguments.
   11.61   * 
   11.62   *   val[7:0] == MMUEXT_INVLPG:
   11.63 - *   ptr[:2]  -- linear address to be flushed from the TLB
   11.64 + *   ptr[:2]  -- Linear address to be flushed from the TLB.
   11.65   * 
   11.66   *   val[7:0] == MMUEXT_SET_LDT:
   11.67 - *   ptr[:2]  -- linear address of LDT base (NB. must be page-aligned)
   11.68 - *   val[:8]  -- number of entries in LDT
   11.69 + *   ptr[:2]  -- Linear address of LDT base (NB. must be page-aligned).
   11.70 + *   val[:8]  -- Number of entries in LDT.
   11.71   * 
   11.72 - *   val[7:0] == MMUEXT_SET_SUBJECTDOM:
   11.73 - *   val[14]  -- if TRUE then sets the PTS in addition to the GPS.
   11.74 - *   (ptr[31:15],val[31:15]) -- dom[31:0]
   11.75 + *   val[7:0] == MMUEXT_SET_FOREIGNDOM:
   11.76 + *   val[31:15] -- Domain to set as the Foreign Domain (FD).
   11.77 + *                 (NB. DOMID_SELF is not recognised)
   11.78   * 
   11.79   *   val[7:0] == MMUEXT_REASSIGN_PAGE:
   11.80 - *   ptr[:2]  -- machine address within page to be reassigned to the GPS.
   11.81 - * 
   11.82 - *   val[7:0] == MMUEXT_RESET_SUBJECTDOM:
   11.83 - *   Resets both the GPS and the PTS to their defaults (i.e., calling domain).
   11.84 + *   ptr[:2]  -- A machine address within the page to be reassigned to the FD.
   11.85 + *               (NB. page must currently belong to the calling domain).
   11.86   * 
   11.87 - * Notes on constraints on the above arguments:
   11.88 - *  [1] The page frame containing the machine address must belong to the PTS.
   11.89 - *  [2] If the PTE is valid (i.e., bit 0 is set) then the specified page frame
   11.90 - *      must belong to: 
   11.91 - *       (a) the PTS (if the PTE is part of a non-L1 table); or
   11.92 - *       (b) the GPS (if the PTE is part of an L1 table).
   11.93 - *  [3] The page frame containing the machine address must belong to the GPS.
   11.94 + *   val[7:0] == MMUEXT_CLEAR_FOREIGNDOM:
   11.95 + *   Clears the FD.
   11.96   */
   11.97  #define MMU_NORMAL_PT_UPDATE     0 /* checked '*ptr = val'. ptr is MA.       */
   11.98  #define MMU_MACHPHYS_UPDATE      2 /* ptr = MA of frame to modify entry for  */
   11.99 @@ -151,10 +141,9 @@
  11.100  #define MMUEXT_TLB_FLUSH         6 /* ptr = NULL                             */
  11.101  #define MMUEXT_INVLPG            7 /* ptr = VA to invalidate                 */
  11.102  #define MMUEXT_SET_LDT           8 /* ptr = VA of table; val = # entries     */
  11.103 -#define MMUEXT_SET_SUBJECTDOM    9 /* (ptr[31:15],val[31:15]) = dom[31:0]    */
  11.104 -#define SET_PAGETABLE_SUBJECTDOM (1<<14) /* OR into 'val' arg of SUBJECTDOM  */
  11.105 +#define MMUEXT_SET_FOREIGNDOM    9 /* val[31:15] = dom                       */
  11.106  #define MMUEXT_REASSIGN_PAGE    10
  11.107 -#define MMUEXT_RESET_SUBJECTDOM 11
  11.108 +#define MMUEXT_CLEAR_FOREIGNDOM 11
  11.109  #define MMUEXT_CMD_MASK        255
  11.110  #define MMUEXT_CMD_SHIFT         8
  11.111  
  11.112 @@ -198,7 +187,8 @@
  11.113  
  11.114  typedef u16 domid_t;
  11.115  /* DOMID_SELF is used in certain contexts to refer to oneself. */
  11.116 -#define DOMID_SELF (0x7FFEU)
  11.117 +#define DOMID_SELF  (0x7FF0U)
  11.118 +/* NB. IDs >= 0x7FF1 are reserved for future use. */
  11.119  
  11.120  /*
  11.121   * Send an array of these to HYPERVISOR_mmu_update().