ia64/xen-unstable

changeset 7998:52bddfb334ae

Make sure that accesses to the machine_to_phys table all go through
suitable macros.

Signed-off-by: Steven Smith, sos22@cam.ac.uk
author sos22@douglas.cl.cam.ac.uk
date Wed Nov 23 13:34:25 2005 +0100 (2005-11-23)
parents 393256b2ead0
children 9cc161c08b59
files tools/libxc/xc_linux_save.c xen/arch/x86/x86_32/mm.c xen/arch/x86/x86_32/traps.c
line diff
     1.1 --- a/tools/libxc/xc_linux_save.c	Tue Nov 22 19:10:50 2005 +0100
     1.2 +++ b/tools/libxc/xc_linux_save.c	Wed Nov 23 13:34:25 2005 +0100
     1.3 @@ -44,6 +44,9 @@ static unsigned long *live_p2m = NULL;
     1.4  /* Live mapping of system MFN to PFN table. */
     1.5  static unsigned long *live_m2p = NULL;
     1.6  
     1.7 +/* grep fodder: machine_to_phys */
     1.8 +
     1.9 +#define mfn_to_pfn(_mfn) live_m2p[(_mfn)]
    1.10  
    1.11  /*
    1.12   * Returns TRUE if the given machine frame number has a unique mapping
    1.13 @@ -51,8 +54,8 @@ static unsigned long *live_m2p = NULL;
    1.14   */
    1.15  #define MFN_IS_IN_PSEUDOPHYS_MAP(_mfn)          \
    1.16  (((_mfn) < (max_mfn)) &&                        \
    1.17 - ((live_m2p[_mfn] < (max_pfn)) &&               \
    1.18 -  (live_p2m[live_m2p[_mfn]] == (_mfn))))
    1.19 + ((mfn_to_pfn(_mfn) < (max_pfn)) &&               \
    1.20 +  (live_p2m[mfn_to_pfn(_mfn)] == (_mfn))))
    1.21      
    1.22   
    1.23  /* Returns TRUE if MFN is successfully converted to a PFN. */
    1.24 @@ -63,7 +66,7 @@ static unsigned long *live_m2p = NULL;
    1.25      if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) )                       \
    1.26          _res = 0;                                               \
    1.27      else                                                        \
    1.28 -        *(_pmfn) = live_m2p[mfn];                               \
    1.29 +        *(_pmfn) = mfn_to_pfn(mfn);                             \
    1.30      _res;                                                       \
    1.31  })
    1.32  
    1.33 @@ -477,9 +480,7 @@ void canonicalize_pagetable(unsigned lon
    1.34                          type, i, (unsigned long long)pte, mfn); 
    1.35                  pfn = 0; /* zap it - we'll retransmit this page later */
    1.36              } else 
    1.37 -                pfn = live_m2p[mfn];
    1.38 -            
    1.39 -
    1.40 +                pfn = mfn_to_pfn(mfn);
    1.41              
    1.42              pte &= 0xffffff0000000fffULL;
    1.43              pte |= (uint64_t)pfn << PAGE_SHIFT;
    1.44 @@ -815,9 +816,9 @@ int xc_linux_save(int xc_handle, int io_
    1.45          for (i = 0; i < max_pfn; i++) {
    1.46  
    1.47              mfn = live_p2m[i];
    1.48 -            if((mfn != 0xffffffffUL) && (live_m2p[mfn] != i)) { 
    1.49 +            if((mfn != 0xffffffffUL) && (mfn_to_pfn(mfn) != i)) { 
    1.50                  DPRINTF("i=0x%x mfn=%lx live_m2p=%lx\n", i, 
    1.51 -                        mfn, live_m2p[mfn]);
    1.52 +                        mfn, mfn_to_pfn(mfn));
    1.53                  err++;
    1.54              }
    1.55          }
    1.56 @@ -882,7 +883,7 @@ int xc_linux_save(int xc_handle, int io_
    1.57                      DPRINTF("%d pfn= %08lx mfn= %08lx %d  [mfn]= %08lx\n",
    1.58                              iter, (unsigned long)n, live_p2m[n],
    1.59                              test_bit(n, to_send), 
    1.60 -                            live_m2p[live_p2m[n]&0xFFFFF]);
    1.61 +                            mfn_to_pfn(live_p2m[n]&0xFFFFF));
    1.62                  }
    1.63                  
    1.64                  if (!last_iter && test_bit(n, to_send)&& test_bit(n, to_skip)) 
    1.65 @@ -954,7 +955,7 @@ int xc_linux_save(int xc_handle, int io_
    1.66                              iter, 
    1.67                              (pfn_type[j] & LTAB_MASK) | pfn_batch[j],
    1.68                              pfn_type[j],
    1.69 -                            live_m2p[pfn_type[j]&(~LTAB_MASK)],
    1.70 +                            mfn_to_pfn(pfn_type[j]&(~LTAB_MASK)),
    1.71                              csum_page(region_base + (PAGE_SIZE*j)));
    1.72                  
    1.73                  /* canonicalise mfn->pfn */
    1.74 @@ -1141,7 +1142,7 @@ int xc_linux_save(int xc_handle, int io_
    1.75          ERR("PT base is not in range of pseudophys map");
    1.76          goto out;
    1.77      }
    1.78 -    ctxt.ctrlreg[3] = live_m2p[ctxt.ctrlreg[3] >> PAGE_SHIFT] <<
    1.79 +    ctxt.ctrlreg[3] = mfn_to_pfn(ctxt.ctrlreg[3] >> PAGE_SHIFT) <<
    1.80          PAGE_SHIFT;
    1.81  
    1.82      if (!write_exact(io_fd, &ctxt, sizeof(ctxt)) ||
     2.1 --- a/xen/arch/x86/x86_32/mm.c	Tue Nov 22 19:10:50 2005 +0100
     2.2 +++ b/xen/arch/x86/x86_32/mm.c	Wed Nov 23 13:34:25 2005 +0100
     2.3 @@ -106,7 +106,9 @@ void __init paging_init(void)
     2.4          idle_pg_table_l2[l2_linear_offset(RO_MPT_VIRT_START) + i] =
     2.5              l2e_from_page(pg, (__PAGE_HYPERVISOR | _PAGE_PSE) & ~_PAGE_RW);
     2.6      }
     2.7 -    memset((void *)RDWR_MPT_VIRT_START, 0x55, mpt_size);
     2.8 +
     2.9 +    for ( i = 0; i < max_page; i++)
    2.10 +        set_pfn_from_mfn(i, 0x55555555);
    2.11  
    2.12      /* Create page tables for ioremap(). */
    2.13      for ( i = 0; i < (IOREMAP_MBYTES >> (L2_PAGETABLE_SHIFT - 20)); i++ )
     3.1 --- a/xen/arch/x86/x86_32/traps.c	Tue Nov 22 19:10:50 2005 +0100
     3.2 +++ b/xen/arch/x86/x86_32/traps.c	Wed Nov 23 13:34:25 2005 +0100
     3.3 @@ -103,7 +103,7 @@ void show_page_walk(unsigned long addr)
     3.4  
     3.5      ptab = map_domain_page(mfn);
     3.6      ent  = ptab[l2_table_offset(addr)];
     3.7 -    pfn  = machine_to_phys_mapping[(u32)(ent >> PAGE_SHIFT)]; 
     3.8 +    pfn  = get_pfn_from_mfn(ent >> PAGE_SHIFT);
     3.9      printk("  L2 = %"PRIpte" %08lx %s\n", ent, pfn, 
    3.10             (ent & _PAGE_PSE) ? "(PSE)" : "");
    3.11      unmap_domain_page(ptab);
    3.12 @@ -113,7 +113,7 @@ void show_page_walk(unsigned long addr)
    3.13  
    3.14      ptab = map_domain_page(ent >> PAGE_SHIFT);
    3.15      ent  = ptab[l1_table_offset(addr)];
    3.16 -    pfn  = machine_to_phys_mapping[(u32)(ent >> PAGE_SHIFT)]; 
    3.17 +    pfn  = get_pfn_from_mfn(ent >> PAGE_SHIFT);
    3.18      printk("   L1 = %"PRIpte" %08lx\n", ent, pfn);
    3.19      unmap_domain_page(ptab);
    3.20  }