ia64/xen-unstable

changeset 12900:c0d41ac21486

merge with xen-unstable.hg
author awilliam@xenbuild2.aw
date Tue Dec 12 15:25:02 2006 -0700 (2006-12-12)
parents e948333c2c38 37141c3a3d39
children ed56ef3e9716 de3d55c10f16
files
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Dec 12 15:23:51 2006 -0700
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Dec 12 15:25:02 2006 -0700
     1.3 @@ -183,7 +183,7 @@ static struct sk_buff *netbk_copy_skb(st
     1.4  
     1.5  	BUG_ON(skb_shinfo(skb)->frag_list != NULL);
     1.6  
     1.7 -	nskb = alloc_skb(SKB_MAX_HEAD(0), GFP_ATOMIC);
     1.8 +	nskb = alloc_skb(SKB_MAX_HEAD(0), GFP_ATOMIC | __GFP_NOWARN);
     1.9  	if (unlikely(!nskb))
    1.10  		goto err;
    1.11  
    1.12 @@ -1224,7 +1224,8 @@ static void net_tx_action(unsigned long 
    1.13  			    ret < MAX_SKB_FRAGS) ?
    1.14  			PKT_PROT_LEN : txreq.size;
    1.15  
    1.16 -		skb = alloc_skb(data_len + 16 + NET_IP_ALIGN, GFP_ATOMIC);
    1.17 +		skb = alloc_skb(data_len + 16 + NET_IP_ALIGN,
    1.18 +				GFP_ATOMIC | __GFP_NOWARN);
    1.19  		if (unlikely(skb == NULL)) {
    1.20  			DPRINTK("Can't allocate a skb in start_xmit.\n");
    1.21  			netbk_tx_err(netif, &txreq, i);
     2.1 --- a/tools/libxc/xc_linux_build.c	Tue Dec 12 15:23:51 2006 -0700
     2.2 +++ b/tools/libxc/xc_linux_build.c	Tue Dec 12 15:25:02 2006 -0700
     2.3 @@ -175,11 +175,10 @@ static int load_initrd(int xc_handle, do
     2.4      return 0;
     2.5  }
     2.6  
     2.7 -#define alloc_pt(ltab, vltab, pltab)                                    \
     2.8 +#define alloc_pt(ltab, vltab)                                           \
     2.9  do {                                                                    \
    2.10 -    pltab = ppt_alloc++;                                                \
    2.11 -    ltab = (uint64_t)page_array[pltab] << PAGE_SHIFT;                   \
    2.12 -    pltab <<= PAGE_SHIFT;                                               \
    2.13 +    ltab = ppt_alloc++;                                                 \
    2.14 +    ltab = (uint64_t)page_array[ltab] << PAGE_SHIFT;                    \
    2.15      if ( vltab != NULL )                                                \
    2.16          munmap(vltab, PAGE_SIZE);                                       \
    2.17      if ( (vltab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,       \
    2.18 @@ -202,43 +201,32 @@ static int setup_pg_tables(int xc_handle
    2.19  {
    2.20      l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
    2.21      l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
    2.22 -    unsigned long l1tab = 0, pl1tab;
    2.23 -    unsigned long l2tab = 0, pl2tab;
    2.24 +    unsigned long l1tab = 0;
    2.25 +    unsigned long l2tab = 0;
    2.26      unsigned long ppt_alloc;
    2.27      unsigned long count;
    2.28  
    2.29      ppt_alloc = (vpt_start - dsi_v_start) >> PAGE_SHIFT;
    2.30 -    alloc_pt(l2tab, vl2tab, pl2tab);
    2.31 +    alloc_pt(l2tab, vl2tab);
    2.32      vl2e = &vl2tab[l2_table_offset(dsi_v_start)];
    2.33 -    if (shadow_mode_enabled)
    2.34 -        ctxt->ctrlreg[3] = xen_pfn_to_cr3(pl2tab >> PAGE_SHIFT);
    2.35 -    else
    2.36 -        ctxt->ctrlreg[3] = xen_pfn_to_cr3(l2tab >> PAGE_SHIFT);
    2.37 +    ctxt->ctrlreg[3] = xen_pfn_to_cr3(l2tab >> PAGE_SHIFT);
    2.38  
    2.39      for ( count = 0; count < ((v_end - dsi_v_start) >> PAGE_SHIFT); count++ )
    2.40      {
    2.41          if ( ((unsigned long)vl1e & (PAGE_SIZE-1)) == 0 )
    2.42          {
    2.43 -            alloc_pt(l1tab, vl1tab, pl1tab);
    2.44 +            alloc_pt(l1tab, vl1tab);
    2.45              vl1e = &vl1tab[l1_table_offset(dsi_v_start + (count<<PAGE_SHIFT))];
    2.46 -            if (shadow_mode_enabled)
    2.47 -                *vl2e = pl1tab | L2_PROT;
    2.48 -            else
    2.49 -                *vl2e = l1tab | L2_PROT;
    2.50 -            vl2e++;
    2.51 +            *vl2e++ = l1tab | L2_PROT;
    2.52          }
    2.53  
    2.54 -        if ( shadow_mode_enabled )
    2.55 -        {
    2.56 -            *vl1e = (count << PAGE_SHIFT) | L1_PROT;
    2.57 -        }
    2.58 -        else
    2.59 -        {
    2.60 -            *vl1e = (page_array[count] << PAGE_SHIFT) | L1_PROT;
    2.61 +        *vl1e = (page_array[count] << PAGE_SHIFT) | L1_PROT;
    2.62 +
    2.63 +        if ( !shadow_mode_enabled )
    2.64              if ( (count >= ((vpt_start-dsi_v_start)>>PAGE_SHIFT)) &&
    2.65                   (count <  ((vpt_end  -dsi_v_start)>>PAGE_SHIFT)) )
    2.66                  *vl1e &= ~_PAGE_RW;
    2.67 -        }
    2.68 +
    2.69          vl1e++;
    2.70      }
    2.71      munmap(vl1tab, PAGE_SIZE);
    2.72 @@ -266,7 +254,7 @@ static int setup_pg_tables_pae(int xc_ha
    2.73      l1_pgentry_64_t *vl1tab = NULL, *vl1e = NULL;
    2.74      l2_pgentry_64_t *vl2tab = NULL, *vl2e = NULL;
    2.75      l3_pgentry_64_t *vl3tab = NULL, *vl3e = NULL;
    2.76 -    uint64_t l1tab, l2tab, l3tab, pl1tab, pl2tab, pl3tab;
    2.77 +    uint64_t l1tab, l2tab, l3tab;
    2.78      unsigned long ppt_alloc, count, nmfn;
    2.79  
    2.80      /* First allocate page for page dir. */
    2.81 @@ -287,12 +275,9 @@ static int setup_pg_tables_pae(int xc_ha
    2.82          page_array[ppt_alloc] = nmfn;
    2.83      }
    2.84  
    2.85 -    alloc_pt(l3tab, vl3tab, pl3tab);
    2.86 +    alloc_pt(l3tab, vl3tab);
    2.87      vl3e = &vl3tab[l3_table_offset_pae(dsi_v_start)];
    2.88 -    if (shadow_mode_enabled)
    2.89 -        ctxt->ctrlreg[3] = xen_pfn_to_cr3(pl3tab >> PAGE_SHIFT);
    2.90 -    else
    2.91 -        ctxt->ctrlreg[3] = xen_pfn_to_cr3(l3tab >> PAGE_SHIFT);
    2.92 +    ctxt->ctrlreg[3] = xen_pfn_to_cr3(l3tab >> PAGE_SHIFT);
    2.93  
    2.94      for ( count = 0; count < ((v_end - dsi_v_start) >> PAGE_SHIFT); count++)
    2.95      {
    2.96 @@ -300,42 +285,33 @@ static int setup_pg_tables_pae(int xc_ha
    2.97          {
    2.98              if ( !((unsigned long)vl2e & (PAGE_SIZE-1)) )
    2.99              {
   2.100 -                alloc_pt(l2tab, vl2tab, pl2tab);
   2.101 +                alloc_pt(l2tab, vl2tab);
   2.102                  vl2e = &vl2tab[l2_table_offset_pae(
   2.103                      dsi_v_start + (count << PAGE_SHIFT))];
   2.104 -                if (shadow_mode_enabled)
   2.105 -                    *vl3e = pl2tab | L3_PROT;
   2.106 -                else
   2.107 -                    *vl3e++ = l2tab | L3_PROT;
   2.108 +                *vl3e++ = l2tab | L3_PROT;
   2.109              }
   2.110  
   2.111 -            alloc_pt(l1tab, vl1tab, pl1tab);
   2.112 +            alloc_pt(l1tab, vl1tab);
   2.113              vl1e = &vl1tab[l1_table_offset_pae(
   2.114                  dsi_v_start + (count << PAGE_SHIFT))];
   2.115 -            if (shadow_mode_enabled)
   2.116 -                *vl2e = pl1tab | L2_PROT;
   2.117 -            else
   2.118 -                *vl2e++ = l1tab | L2_PROT;
   2.119 +            *vl2e++ = l1tab | L2_PROT;
   2.120 +
   2.121          }
   2.122  
   2.123 -        if ( shadow_mode_enabled )
   2.124 -        {
   2.125 -            *vl1e = (count << PAGE_SHIFT) | L1_PROT;
   2.126 -        }
   2.127 -        else
   2.128 -        {
   2.129 -            *vl1e = ((uint64_t)page_array[count] << PAGE_SHIFT) | L1_PROT;
   2.130 +        *vl1e = ((uint64_t)page_array[count] << PAGE_SHIFT) | L1_PROT;
   2.131 +
   2.132 +        if ( !shadow_mode_enabled )
   2.133              if ( (count >= ((vpt_start-dsi_v_start)>>PAGE_SHIFT)) &&
   2.134                   (count <  ((vpt_end  -dsi_v_start)>>PAGE_SHIFT)) )
   2.135                  *vl1e &= ~_PAGE_RW;
   2.136 -        }
   2.137 +
   2.138          vl1e++;
   2.139      }
   2.140  
   2.141      /* Xen requires a mid-level pgdir mapping 0xC0000000 region. */
   2.142      if ( (vl3tab[3] & _PAGE_PRESENT) == 0 )
   2.143      {
   2.144 -        alloc_pt(l2tab, vl2tab, pl2tab);
   2.145 +        alloc_pt(l2tab, vl2tab);
   2.146          vl3tab[3] = l2tab | L3_PROT;
   2.147      }
   2.148  
   2.149 @@ -371,69 +347,48 @@ static int setup_pg_tables_64(int xc_han
   2.150      l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
   2.151      l3_pgentry_t *vl3tab=NULL, *vl3e=NULL;
   2.152      l4_pgentry_t *vl4tab=NULL, *vl4e=NULL;
   2.153 -    unsigned long l2tab = 0, pl2tab;
   2.154 -    unsigned long l1tab = 0, pl1tab;
   2.155 -    unsigned long l3tab = 0, pl3tab;
   2.156 -    unsigned long l4tab = 0, pl4tab;
   2.157 +    unsigned long l2tab = 0;
   2.158 +    unsigned long l1tab = 0;
   2.159 +    unsigned long l3tab = 0;
   2.160 +    unsigned long l4tab = 0;
   2.161      unsigned long ppt_alloc;
   2.162      unsigned long count;
   2.163  
   2.164      /* First allocate page for page dir. */
   2.165      ppt_alloc = (vpt_start - dsi_v_start) >> PAGE_SHIFT;
   2.166 -    alloc_pt(l4tab, vl4tab, pl4tab);
   2.167 +    alloc_pt(l4tab, vl4tab);
   2.168      vl4e = &vl4tab[l4_table_offset(dsi_v_start)];
   2.169 -    if (shadow_mode_enabled)
   2.170 -        ctxt->ctrlreg[3] = xen_pfn_to_cr3(pl4tab >> PAGE_SHIFT);
   2.171 -    else
   2.172 -        ctxt->ctrlreg[3] = xen_pfn_to_cr3(l4tab >> PAGE_SHIFT);
   2.173 +    ctxt->ctrlreg[3] = xen_pfn_to_cr3(l4tab >> PAGE_SHIFT);
   2.174  
   2.175      for ( count = 0; count < ((v_end-dsi_v_start)>>PAGE_SHIFT); count++)
   2.176      {
   2.177          if ( !((unsigned long)vl1e & (PAGE_SIZE-1)) )
   2.178          {
   2.179 -            alloc_pt(l1tab, vl1tab, pl1tab);
   2.180 +            alloc_pt(l1tab, vl1tab);
   2.181  
   2.182              if ( !((unsigned long)vl2e & (PAGE_SIZE-1)) )
   2.183              {
   2.184 -                alloc_pt(l2tab, vl2tab, pl2tab);
   2.185 +                alloc_pt(l2tab, vl2tab);
   2.186                  if ( !((unsigned long)vl3e & (PAGE_SIZE-1)) )
   2.187                  {
   2.188 -                    alloc_pt(l3tab, vl3tab, pl3tab);
   2.189 +                    alloc_pt(l3tab, vl3tab);
   2.190                      vl3e = &vl3tab[l3_table_offset(dsi_v_start + (count<<PAGE_SHIFT))];
   2.191 -                    if (shadow_mode_enabled)
   2.192 -                        *vl4e = pl3tab | L4_PROT;
   2.193 -                    else
   2.194 -                        *vl4e = l3tab | L4_PROT;
   2.195 -                    vl4e++;
   2.196 +                    *vl4e++ = l3tab | L4_PROT;
   2.197                  }
   2.198                  vl2e = &vl2tab[l2_table_offset(dsi_v_start + (count<<PAGE_SHIFT))];
   2.199 -                if (shadow_mode_enabled)
   2.200 -                    *vl3e = pl2tab | L3_PROT;
   2.201 -                else
   2.202 -                    *vl3e = l2tab | L3_PROT;
   2.203 -                vl3e++;
   2.204 +                *vl3e++ = l2tab | L3_PROT;
   2.205              }
   2.206              vl1e = &vl1tab[l1_table_offset(dsi_v_start + (count<<PAGE_SHIFT))];
   2.207 -            if (shadow_mode_enabled)
   2.208 -                *vl2e = pl1tab | L2_PROT;
   2.209 -            else
   2.210 -                *vl2e = l1tab | L2_PROT;
   2.211 -            vl2e++;
   2.212 +            *vl2e++ = l1tab | L2_PROT;
   2.213          }
   2.214  
   2.215 -        if ( shadow_mode_enabled )
   2.216 -        {
   2.217 -            *vl1e = (count << PAGE_SHIFT) | L1_PROT;
   2.218 -        }
   2.219 -        else
   2.220 -        {
   2.221 -            *vl1e = (page_array[count] << PAGE_SHIFT) | L1_PROT;
   2.222 +        *vl1e = (page_array[count] << PAGE_SHIFT) | L1_PROT;
   2.223 +
   2.224 +        if ( !shadow_mode_enabled )
   2.225              if ( (count >= ((vpt_start-dsi_v_start)>>PAGE_SHIFT)) &&
   2.226                   (count <  ((vpt_end  -dsi_v_start)>>PAGE_SHIFT)) )
   2.227 -                {
   2.228 -                    *vl1e &= ~_PAGE_RW;
   2.229 -                }
   2.230 -        }
   2.231 +                *vl1e &= ~_PAGE_RW;
   2.232 +
   2.233          vl1e++;
   2.234      }
   2.235  
   2.236 @@ -772,6 +727,27 @@ static int setup_guest(int xc_handle,
   2.237          goto error_out;
   2.238      }
   2.239  
   2.240 +
   2.241 +    if ( shadow_mode_enabled )
   2.242 +    {
   2.243 +        /*
   2.244 +         * Enable shadow translate mode. This must happen after
   2.245 +         * populate physmap because the p2m reservation is based on
   2.246 +         * the domains current memory allocation.
   2.247 +         */
   2.248 +        if ( xc_shadow_control(xc_handle, dom,
   2.249 +                           XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE,
   2.250 +                           NULL, 0, NULL, 0, NULL) < 0 )
   2.251 +        {
   2.252 +            PERROR("Could not enable translation mode");
   2.253 +            goto error_out;
   2.254 +        }
   2.255 +
   2.256 +        /* Reinitialise the gpfn->gmfn array. */
   2.257 +        for ( i = 0; i < nr_pages; i++ )
   2.258 +            page_array[i] = i;
   2.259 +    }
   2.260 +
   2.261      rc = (load_funcs.loadimage)(image, image_size,
   2.262                             xc_handle, dom, page_array,
   2.263                             &dsi);
   2.264 @@ -973,15 +949,6 @@ static int setup_guest(int xc_handle,
   2.265      {
   2.266          struct xen_add_to_physmap xatp;
   2.267  
   2.268 -        /* Enable shadow translate mode */
   2.269 -        if ( xc_shadow_control(xc_handle, dom,
   2.270 -                               XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE,
   2.271 -                               NULL, 0, NULL, 0, NULL) < 0 )
   2.272 -        {
   2.273 -            PERROR("Could not enable translation mode");
   2.274 -            goto error_out;
   2.275 -        }
   2.276 -
   2.277          guest_shared_info_mfn = (vsharedinfo_start-dsi.v_start) >> PAGE_SHIFT;
   2.278  
   2.279          /* Map shared info frame into guest physmap. */
   2.280 @@ -1083,8 +1050,7 @@ static int setup_guest(int xc_handle,
   2.281          if ( pfn >= nr_pages )
   2.282              goto error_out;
   2.283          domctl.domain = (domid_t)dom;
   2.284 -        domctl.u.hypercall_init.gmfn   = shadow_mode_enabled ?
   2.285 -            pfn : page_array[pfn];
   2.286 +        domctl.u.hypercall_init.gmfn = page_array[pfn];
   2.287          domctl.cmd = XEN_DOMCTL_hypercall_init;
   2.288          if ( xc_domctl(xc_handle, &domctl) )
   2.289              goto error_out;
     3.1 --- a/xen/arch/x86/mm.c	Tue Dec 12 15:23:51 2006 -0700
     3.2 +++ b/xen/arch/x86/mm.c	Tue Dec 12 15:25:02 2006 -0700
     3.3 @@ -435,15 +435,6 @@ int map_ldt_shadow_page(unsigned int off
     3.4          return 0;
     3.5  
     3.6      okay = get_page_and_type(mfn_to_page(mfn), d, PGT_ldt_page);
     3.7 -
     3.8 -    if ( !okay && unlikely(shadow_mode_refcounts(d)) )
     3.9 -    {
    3.10 -        shadow_lock(d);
    3.11 -        shadow_remove_write_access(d->vcpu[0], _mfn(mfn), 0, 0);
    3.12 -        okay = get_page_and_type(mfn_to_page(mfn), d, PGT_ldt_page);
    3.13 -        shadow_unlock(d);
    3.14 -    }
    3.15 -
    3.16      if ( unlikely(!okay) )
    3.17          return 0;
    3.18  
    3.19 @@ -509,8 +500,6 @@ get_linear_pagetable(
    3.20      struct page_info *page;
    3.21      unsigned long pfn;
    3.22  
    3.23 -    ASSERT( !shadow_mode_refcounts(d) );
    3.24 -
    3.25      if ( (root_get_flags(re) & _PAGE_RW) )
    3.26      {
    3.27          MEM_LOG("Attempt to create linear p.t. with write perms");
    3.28 @@ -821,8 +810,6 @@ static int alloc_l1_table(struct page_in
    3.29      l1_pgentry_t  *pl1e;
    3.30      int            i;
    3.31  
    3.32 -    ASSERT(!shadow_mode_refcounts(d));
    3.33 -
    3.34      pl1e = map_domain_page(pfn);
    3.35  
    3.36      for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
    3.37 @@ -873,8 +860,6 @@ static int create_pae_xen_mappings(l3_pg
    3.38       *  2. Cannot appear in another page table's L3:
    3.39       *     a. alloc_l3_table() calls this function and this check will fail
    3.40       *     b. mod_l3_entry() disallows updates to slot 3 in an existing table
    3.41 -     *
    3.42 -     * XXX -- this needs revisiting for shadow_mode_refcount()==true...
    3.43       */
    3.44      page = l3e_get_page(l3e3);
    3.45      BUG_ON(page->u.inuse.type_info & PGT_pinned);
    3.46 @@ -959,8 +944,6 @@ static int alloc_l2_table(struct page_in
    3.47      l2_pgentry_t  *pl2e;
    3.48      int            i;
    3.49  
    3.50 -    ASSERT(!shadow_mode_refcounts(d));
    3.51 -    
    3.52      pl2e = map_domain_page(pfn);
    3.53  
    3.54      for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ )
    3.55 @@ -1008,8 +991,6 @@ static int alloc_l3_table(struct page_in
    3.56      l3_pgentry_t  *pl3e;
    3.57      int            i;
    3.58  
    3.59 -    ASSERT(!shadow_mode_refcounts(d));
    3.60 -
    3.61  #ifdef CONFIG_X86_PAE
    3.62      /*
    3.63       * PAE pgdirs above 4GB are unacceptable if the guest does not understand
    3.64 @@ -1075,8 +1056,6 @@ static int alloc_l4_table(struct page_in
    3.65      l4_pgentry_t  *pl4e = page_to_virt(page);
    3.66      int            i;
    3.67  
    3.68 -    ASSERT(!shadow_mode_refcounts(d));
    3.69 -
    3.70      for ( i = 0; i < L4_PAGETABLE_ENTRIES; i++ )
    3.71      {
    3.72          if ( is_guest_l4_slot(i) &&