direct-io.hg

changeset 8736:8aeb417387ca

Fix some more pfn/mfn/gmfn/gpfn inconsistencies. Fix some direct
uses of max_page variable to use the mfn_valid() predicate.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Feb 02 12:18:28 2006 +0100 (2006-02-02)
parents f20c10ecef94
children 1987bb42110a
files linux-2.6-xen-sparse/arch/i386/kernel/cpu/mtrr/main-xen.c tools/libxc/xc_domain.c tools/libxc/xc_linux_build.c tools/libxc/xc_private.c tools/libxc/xenctrl.h xen/arch/x86/audit.c xen/arch/x86/dom0_ops.c xen/arch/x86/domain_build.c xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/mm.c xen/arch/x86/shadow32.c xen/arch/x86/shadow_public.c xen/arch/x86/x86_32/mm.c xen/arch/x86/x86_32/traps.c xen/common/dom0_ops.c xen/common/grant_table.c xen/common/memory.c xen/include/asm-ia64/config.h xen/include/asm-ia64/mm.h xen/include/asm-x86/grant_table.h xen/include/asm-x86/hvm/io.h xen/include/asm-x86/mm.h xen/include/asm-x86/shadow.h xen/include/asm-x86/shadow_64.h xen/include/public/dom0_ops.h xen/include/public/memory.h xen/include/xen/perfc_defn.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/cpu/mtrr/main-xen.c	Thu Feb 02 10:59:20 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/cpu/mtrr/main-xen.c	Thu Feb 02 12:18:28 2006 +0100
     1.3 @@ -17,8 +17,8 @@ void generic_get_mtrr(unsigned int reg, 
     1.4  	op.u.read_memtype.reg = reg;
     1.5  	(void)HYPERVISOR_dom0_op(&op);
     1.6  
     1.7 -	*size = op.u.read_memtype.nr_pfns;
     1.8 -	*base = op.u.read_memtype.pfn;
     1.9 +	*size = op.u.read_memtype.nr_mfns;
    1.10 +	*base = op.u.read_memtype.mfn;
    1.11  	*type = op.u.read_memtype.type;
    1.12  }
    1.13  
    1.14 @@ -64,8 +64,8 @@ int mtrr_add_page(unsigned long base, un
    1.15  	dom0_op_t op;
    1.16  
    1.17  	op.cmd = DOM0_ADD_MEMTYPE;
    1.18 -	op.u.add_memtype.pfn     = base;
    1.19 -	op.u.add_memtype.nr_pfns = size;
    1.20 +	op.u.add_memtype.mfn     = base;
    1.21 +	op.u.add_memtype.nr_mfns = size;
    1.22  	op.u.add_memtype.type    = type;
    1.23  	error = HYPERVISOR_dom0_op(&op);
    1.24  	if (error) {
     2.1 --- a/tools/libxc/xc_domain.c	Thu Feb 02 10:59:20 2006 +0000
     2.2 +++ b/tools/libxc/xc_domain.c	Thu Feb 02 12:18:28 2006 +0100
     2.3 @@ -421,16 +421,16 @@ int xc_domain_irq_permission(int xc_hand
     2.4  
     2.5  int xc_domain_iomem_permission(int xc_handle,
     2.6                                 uint32_t domid,
     2.7 -                               unsigned long first_pfn,
     2.8 -                               unsigned long nr_pfns,
     2.9 +                               unsigned long first_mfn,
    2.10 +                               unsigned long nr_mfns,
    2.11                                 uint8_t allow_access)
    2.12  {
    2.13      dom0_op_t op;
    2.14  
    2.15      op.cmd = DOM0_IOMEM_PERMISSION;
    2.16      op.u.iomem_permission.domain = domid;
    2.17 -    op.u.iomem_permission.first_pfn = first_pfn;
    2.18 -	op.u.iomem_permission.nr_pfns = nr_pfns;
    2.19 +    op.u.iomem_permission.first_mfn = first_mfn;
    2.20 +	op.u.iomem_permission.nr_mfns = nr_mfns;
    2.21      op.u.iomem_permission.allow_access = allow_access;
    2.22  
    2.23      return do_dom0_op(xc_handle, &op);
     3.1 --- a/tools/libxc/xc_linux_build.c	Thu Feb 02 10:59:20 2006 +0000
     3.2 +++ b/tools/libxc/xc_linux_build.c	Thu Feb 02 12:18:28 2006 +0100
     3.3 @@ -767,7 +767,7 @@ static int setup_guest(int xc_handle,
     3.4              PERROR("Cannot find shared info pfn");
     3.5              goto error_out;
     3.6          }
     3.7 -        guest_shared_info_mfn = xrpa.first_pfn;
     3.8 +        guest_shared_info_mfn = xrpa.first_gpfn;
     3.9      }
    3.10      else
    3.11      {
     4.1 --- a/tools/libxc/xc_private.c	Thu Feb 02 10:59:20 2006 +0000
     4.2 +++ b/tools/libxc/xc_private.c	Thu Feb 02 12:18:28 2006 +0100
     4.3 @@ -83,7 +83,7 @@ unsigned int get_pfn_type(int xc_handle,
     4.4  {
     4.5      DECLARE_DOM0_OP;
     4.6      op.cmd = DOM0_GETPAGEFRAMEINFO;
     4.7 -    op.u.getpageframeinfo.pfn    = mfn;
     4.8 +    op.u.getpageframeinfo.mfn    = mfn;
     4.9      op.u.getpageframeinfo.domain = (domid_t)dom;
    4.10      if ( do_dom0_op(xc_handle, &op) < 0 )
    4.11      {
     5.1 --- a/tools/libxc/xenctrl.h	Thu Feb 02 10:59:20 2006 +0000
     5.2 +++ b/tools/libxc/xenctrl.h	Thu Feb 02 12:18:28 2006 +0100
     5.3 @@ -386,8 +386,8 @@ int xc_domain_irq_permission(int xc_hand
     5.4  
     5.5  int xc_domain_iomem_permission(int xc_handle,
     5.6                                 uint32_t domid,
     5.7 -                               unsigned long first_pfn,
     5.8 -                               unsigned long nr_pfns,
     5.9 +                               unsigned long first_mfn,
    5.10 +                               unsigned long nr_mfns,
    5.11                                 uint8_t allow_access);
    5.12  
    5.13  unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid, 
     6.1 --- a/xen/arch/x86/audit.c	Thu Feb 02 10:59:20 2006 +0000
     6.2 +++ b/xen/arch/x86/audit.c	Thu Feb 02 12:18:28 2006 +0100
     6.3 @@ -239,16 +239,16 @@ int audit_adjust_pgtables(struct domain 
     6.4          {
     6.5              if ( l2e_get_flags(pt[i]) & _PAGE_PRESENT )
     6.6              {
     6.7 -                unsigned long gmfn = l2e_get_pfn(pt[i]);
     6.8 -                struct page_info *gpage = mfn_to_page(gmfn);
     6.9 +                unsigned long mfn = l2e_get_pfn(pt[i]);
    6.10 +                struct page_info *gpage = mfn_to_page(mfn);
    6.11  
    6.12 -                if ( gmfn < 0x100 )
    6.13 +                if ( mfn < 0x100 )
    6.14                  {
    6.15                      lowmem_mappings++;
    6.16                      continue;
    6.17                  }
    6.18  
    6.19 -                if ( gmfn > max_page )
    6.20 +                if ( !mfn_valid(mfn) )
    6.21                  {
    6.22                      io_mappings++;
    6.23                      continue;
    6.24 @@ -264,7 +264,7 @@ int audit_adjust_pgtables(struct domain 
    6.25                                 d->domain_id, hl2mfn, i,
    6.26                                 page_get_owner(gpage),
    6.27                                 page_get_owner(gpage)->domain_id,
    6.28 -                               gmfn,
    6.29 +                               mfn,
    6.30                                 gpage->count_info,
    6.31                                 gpage->u.inuse.type_info);
    6.32                          continue;
    6.33 @@ -286,16 +286,16 @@ int audit_adjust_pgtables(struct domain 
    6.34          {
    6.35              if ( l1e_get_flags(pt[i]) & _PAGE_PRESENT )
    6.36              {
    6.37 -                unsigned long gmfn = l1e_get_pfn(pt[i]);
    6.38 -                struct page_info *gpage = mfn_to_page(gmfn);
    6.39 +                unsigned long mfn = l1e_get_pfn(pt[i]);
    6.40 +                struct page_info *gpage = mfn_to_page(mfn);
    6.41  
    6.42 -                if ( gmfn < 0x100 )
    6.43 +                if ( mfn < 0x100 )
    6.44                  {
    6.45                      lowmem_mappings++;
    6.46                      continue;
    6.47                  }
    6.48  
    6.49 -                if ( gmfn > max_page )
    6.50 +                if ( !mfn_valid(mfn) )
    6.51                  {
    6.52                      io_mappings++;
    6.53                      continue;
    6.54 @@ -313,7 +313,7 @@ int audit_adjust_pgtables(struct domain 
    6.55                              printk("Audit %d: [l1mfn=%lx, i=%x] Illegal RW "
    6.56                                     "t=%" PRtype_info " mfn=%lx\n",
    6.57                                     d->domain_id, l1mfn, i,
    6.58 -                                   gpage->u.inuse.type_info, gmfn);
    6.59 +                                   gpage->u.inuse.type_info, mfn);
    6.60                              errors++;
    6.61                          }
    6.62  
    6.63 @@ -322,8 +322,8 @@ int audit_adjust_pgtables(struct domain 
    6.64                               ! page_out_of_sync(gpage) )
    6.65                          {
    6.66                              printk("Audit %d: [l1mfn=%lx, i=%x] Illegal RW of "
    6.67 -                                   "page table gmfn=%lx\n",
    6.68 -                                   d->domain_id, l1mfn, i, gmfn);
    6.69 +                                   "page table mfn=%lx\n",
    6.70 +                                   d->domain_id, l1mfn, i, mfn);
    6.71                              errors++;
    6.72                          }
    6.73                      }		   
    6.74 @@ -336,7 +336,7 @@ int audit_adjust_pgtables(struct domain 
    6.75                                 d->domain_id, l1mfn, i,
    6.76                                 page_get_owner(gpage),
    6.77                                 page_get_owner(gpage)->domain_id,
    6.78 -                               gmfn,
    6.79 +                               mfn,
    6.80                                 gpage->count_info,
    6.81                                 gpage->u.inuse.type_info);
    6.82                          continue;
     7.1 --- a/xen/arch/x86/dom0_ops.c	Thu Feb 02 10:59:20 2006 +0000
     7.2 +++ b/xen/arch/x86/dom0_ops.c	Thu Feb 02 12:18:28 2006 +0100
     7.3 @@ -98,8 +98,8 @@ long arch_do_dom0_op(struct dom0_op *op,
     7.4      case DOM0_ADD_MEMTYPE:
     7.5      {
     7.6          ret = mtrr_add_page(
     7.7 -            op->u.add_memtype.pfn,
     7.8 -            op->u.add_memtype.nr_pfns,
     7.9 +            op->u.add_memtype.mfn,
    7.10 +            op->u.add_memtype.nr_mfns,
    7.11              op->u.add_memtype.type,
    7.12              1);
    7.13          if (ret > 0)
    7.14 @@ -128,16 +128,16 @@ long arch_do_dom0_op(struct dom0_op *op,
    7.15  
    7.16      case DOM0_READ_MEMTYPE:
    7.17      {
    7.18 -        unsigned long pfn;
    7.19 -        unsigned int  nr_pfns;
    7.20 +        unsigned long mfn;
    7.21 +        unsigned int  nr_mfns;
    7.22          mtrr_type     type;
    7.23  
    7.24          ret = -EINVAL;
    7.25          if ( op->u.read_memtype.reg < num_var_ranges )
    7.26          {
    7.27 -            mtrr_if->get(op->u.read_memtype.reg, &pfn, &nr_pfns, &type);
    7.28 -            (void)__put_user(pfn, &u_dom0_op->u.read_memtype.pfn);
    7.29 -            (void)__put_user(nr_pfns, &u_dom0_op->u.read_memtype.nr_pfns);
    7.30 +            mtrr_if->get(op->u.read_memtype.reg, &mfn, &nr_mfns, &type);
    7.31 +            (void)__put_user(mfn, &u_dom0_op->u.read_memtype.mfn);
    7.32 +            (void)__put_user(nr_mfns, &u_dom0_op->u.read_memtype.nr_mfns);
    7.33              (void)__put_user(type, &u_dom0_op->u.read_memtype.type);
    7.34              ret = 0;
    7.35          }
    7.36 @@ -200,17 +200,17 @@ long arch_do_dom0_op(struct dom0_op *op,
    7.37      case DOM0_GETPAGEFRAMEINFO:
    7.38      {
    7.39          struct page_info *page;
    7.40 -        unsigned long pfn = op->u.getpageframeinfo.pfn;
    7.41 +        unsigned long mfn = op->u.getpageframeinfo.mfn;
    7.42          domid_t dom = op->u.getpageframeinfo.domain;
    7.43          struct domain *d;
    7.44  
    7.45          ret = -EINVAL;
    7.46  
    7.47 -        if ( unlikely(pfn >= max_page) || 
    7.48 +        if ( unlikely(!mfn_valid(mfn)) ||
    7.49               unlikely((d = find_domain_by_id(dom)) == NULL) )
    7.50              break;
    7.51  
    7.52 -        page = mfn_to_page(pfn);
    7.53 +        page = mfn_to_page(mfn);
    7.54  
    7.55          if ( likely(get_page(page, d)) )
    7.56          {
    7.57 @@ -337,7 +337,7 @@ long arch_do_dom0_op(struct dom0_op *op,
    7.58          int i;
    7.59          struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
    7.60          unsigned long max_pfns = op->u.getmemlist.max_pfns;
    7.61 -        unsigned long pfn;
    7.62 +        unsigned long mfn;
    7.63          unsigned long *buffer = op->u.getmemlist.buffer;
    7.64          struct list_head *list_ent;
    7.65  
    7.66 @@ -350,14 +350,14 @@ long arch_do_dom0_op(struct dom0_op *op,
    7.67              list_ent = d->page_list.next;
    7.68              for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
    7.69              {
    7.70 -                pfn = page_to_mfn(list_entry(list_ent, struct page_info, list));
    7.71 -                if ( put_user(pfn, buffer) )
    7.72 +                mfn = page_to_mfn(list_entry(list_ent, struct page_info, list));
    7.73 +                if ( put_user(mfn, buffer) )
    7.74                  {
    7.75                      ret = -EFAULT;
    7.76                      break;
    7.77                  }
    7.78                  buffer++;
    7.79 -                list_ent = mfn_to_page(pfn)->list.next;
    7.80 +                list_ent = mfn_to_page(mfn)->list.next;
    7.81              }
    7.82              spin_unlock(&d->page_alloc_lock);
    7.83  
     8.1 --- a/xen/arch/x86/domain_build.c	Thu Feb 02 10:59:20 2006 +0000
     8.2 +++ b/xen/arch/x86/domain_build.c	Thu Feb 02 12:18:28 2006 +0100
     8.3 @@ -644,7 +644,7 @@ int construct_dom0(struct domain *d,
     8.4      if ( opt_dom0_translate )
     8.5      {
     8.6          si->shared_info  = max_page << PAGE_SHIFT;
     8.7 -        set_pfn_from_mfn(virt_to_maddr(d->shared_info) >> PAGE_SHIFT, max_page);
     8.8 +        set_gpfn_from_mfn(virt_to_maddr(d->shared_info) >> PAGE_SHIFT, max_page);
     8.9      }
    8.10  
    8.11      si->flags        = SIF_PRIVILEGED | SIF_INITDOMAIN;
    8.12 @@ -664,7 +664,7 @@ int construct_dom0(struct domain *d,
    8.13              mfn = alloc_epfn - (pfn - REVERSE_START);
    8.14  #endif
    8.15          ((unsigned long *)vphysmap_start)[pfn] = mfn;
    8.16 -        set_pfn_from_mfn(mfn, pfn);
    8.17 +        set_gpfn_from_mfn(mfn, pfn);
    8.18      }
    8.19      while ( pfn < nr_pages )
    8.20      {
    8.21 @@ -677,7 +677,7 @@ int construct_dom0(struct domain *d,
    8.22  #define pfn (nr_pages - 1 - (pfn - (alloc_epfn - alloc_spfn)))
    8.23  #endif
    8.24              ((unsigned long *)vphysmap_start)[pfn] = mfn;
    8.25 -            set_pfn_from_mfn(mfn, pfn);
    8.26 +            set_gpfn_from_mfn(mfn, pfn);
    8.27  #undef pfn
    8.28              page++; pfn++;
    8.29          }
     9.1 --- a/xen/arch/x86/hvm/hvm.c	Thu Feb 02 10:59:20 2006 +0000
     9.2 +++ b/xen/arch/x86/hvm/hvm.c	Thu Feb 02 12:18:28 2006 +0100
     9.3 @@ -64,7 +64,7 @@ static void hvm_map_io_shared_page(struc
     9.4  
     9.5      local_flush_tlb_pge();
     9.6  
     9.7 -    mfn = get_mfn_from_pfn(E820_MAP_PAGE >> PAGE_SHIFT);
     9.8 +    mfn = get_mfn_from_gpfn(E820_MAP_PAGE >> PAGE_SHIFT);
     9.9      if (mfn == INVALID_MFN) {
    9.10          printk("Can not find E820 memory map page for HVM domain.\n");
    9.11          domain_crash_synchronous();
    9.12 @@ -97,7 +97,7 @@ static void hvm_map_io_shared_page(struc
    9.13      unmap_domain_page(p);
    9.14  
    9.15      /* Initialise shared page */
    9.16 -    mfn = get_mfn_from_pfn(gpfn);
    9.17 +    mfn = get_mfn_from_gpfn(gpfn);
    9.18      if (mfn == INVALID_MFN) {
    9.19          printk("Can not find io request shared page for HVM domain.\n");
    9.20          domain_crash_synchronous();
    9.21 @@ -143,7 +143,7 @@ static void hvm_get_info(struct domain *
    9.22      unsigned long mfn;
    9.23      struct hvm_info_table *t;
    9.24  
    9.25 -    mfn = get_mfn_from_pfn(HVM_INFO_PFN);
    9.26 +    mfn = get_mfn_from_gpfn(HVM_INFO_PFN);
    9.27      if ( mfn == INVALID_MFN ) {
    9.28          printk("Can not get info page mfn for HVM domain.\n");
    9.29          domain_crash_synchronous();
    9.30 @@ -255,9 +255,9 @@ hvm_copy(void *buf, unsigned long vaddr,
    9.31  
    9.32          if (hvm_paging_enabled(current)) {
    9.33              gpa = gva_to_gpa(vaddr);
    9.34 -            mfn = get_mfn_from_pfn(gpa >> PAGE_SHIFT);
    9.35 +            mfn = get_mfn_from_gpfn(gpa >> PAGE_SHIFT);
    9.36          } else
    9.37 -            mfn = get_mfn_from_pfn(vaddr >> PAGE_SHIFT);
    9.38 +            mfn = get_mfn_from_gpfn(vaddr >> PAGE_SHIFT);
    9.39          if (mfn == INVALID_MFN)
    9.40              return 0;
    9.41  
    10.1 --- a/xen/arch/x86/hvm/svm/svm.c	Thu Feb 02 10:59:20 2006 +0000
    10.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Thu Feb 02 12:18:28 2006 +0100
    10.3 @@ -1364,7 +1364,7 @@ static int svm_set_cr0(unsigned long val
    10.4      {
    10.5          /* The guest CR3 must be pointing to the guest physical. */
    10.6          if (!VALID_MFN(mfn = 
    10.7 -                    get_mfn_from_pfn(v->arch.hvm_svm.cpu_cr3 >> PAGE_SHIFT))
    10.8 +                    get_mfn_from_gpfn(v->arch.hvm_svm.cpu_cr3 >> PAGE_SHIFT))
    10.9                  || !get_page(mfn_to_page(mfn), v->domain))
   10.10          {
   10.11              printk("Invalid CR3 value = %lx\n", v->arch.hvm_svm.cpu_cr3);
   10.12 @@ -1557,7 +1557,7 @@ static int mov_to_cr(int gpreg, int cr, 
   10.13               * removed some translation or changed page attributes.
   10.14               * We simply invalidate the shadow.
   10.15               */
   10.16 -            mfn = get_mfn_from_pfn(value >> PAGE_SHIFT);
   10.17 +            mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT);
   10.18              if (mfn != pagetable_get_pfn(v->arch.guest_table))
   10.19                  __hvm_bug(regs);
   10.20              shadow_sync_all(v->domain);
   10.21 @@ -1570,7 +1570,7 @@ static int mov_to_cr(int gpreg, int cr, 
   10.22               */
   10.23              HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 value = %lx", value);
   10.24              if (((value >> PAGE_SHIFT) > v->domain->max_pages) 
   10.25 -                    || !VALID_MFN(mfn = get_mfn_from_pfn(value >> PAGE_SHIFT))
   10.26 +                    || !VALID_MFN(mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT))
   10.27                      || !get_page(mfn_to_page(mfn), v->domain))
   10.28              {
   10.29                  printk("Invalid CR3 value=%lx\n", value);
    11.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Thu Feb 02 10:59:20 2006 +0000
    11.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Thu Feb 02 12:18:28 2006 +0100
    11.3 @@ -968,7 +968,7 @@ vmx_world_restore(struct vcpu *v, struct
    11.4           * removed some translation or changed page attributes.
    11.5           * We simply invalidate the shadow.
    11.6           */
    11.7 -        mfn = get_mfn_from_pfn(c->cr3 >> PAGE_SHIFT);
    11.8 +        mfn = get_mfn_from_gpfn(c->cr3 >> PAGE_SHIFT);
    11.9          if (mfn != pagetable_get_pfn(v->arch.guest_table)) {
   11.10              printk("Invalid CR3 value=%x", c->cr3);
   11.11              domain_crash_synchronous();
   11.12 @@ -986,7 +986,7 @@ vmx_world_restore(struct vcpu *v, struct
   11.13              domain_crash_synchronous();
   11.14              return 0;
   11.15          }
   11.16 -        mfn = get_mfn_from_pfn(c->cr3 >> PAGE_SHIFT);
   11.17 +        mfn = get_mfn_from_gpfn(c->cr3 >> PAGE_SHIFT);
   11.18          if(!get_page(mfn_to_page(mfn), v->domain))
   11.19                  return 0;
   11.20          old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
   11.21 @@ -1157,7 +1157,7 @@ static int vmx_set_cr0(unsigned long val
   11.22          /*
   11.23           * The guest CR3 must be pointing to the guest physical.
   11.24           */
   11.25 -        if ( !VALID_MFN(mfn = get_mfn_from_pfn(
   11.26 +        if ( !VALID_MFN(mfn = get_mfn_from_gpfn(
   11.27              v->arch.hvm_vmx.cpu_cr3 >> PAGE_SHIFT)) ||
   11.28               !get_page(mfn_to_page(mfn), v->domain) )
   11.29          {
   11.30 @@ -1232,7 +1232,7 @@ static int vmx_set_cr0(unsigned long val
   11.31  
   11.32      if(!((value & X86_CR0_PE) && (value & X86_CR0_PG)) && paging_enabled)
   11.33          if(v->arch.hvm_vmx.cpu_cr3) {
   11.34 -            put_page(mfn_to_page(get_mfn_from_pfn(
   11.35 +            put_page(mfn_to_page(get_mfn_from_gpfn(
   11.36                        v->arch.hvm_vmx.cpu_cr3 >> PAGE_SHIFT)));
   11.37              v->arch.guest_table = mk_pagetable(0);
   11.38          }
   11.39 @@ -1366,7 +1366,7 @@ static int mov_to_cr(int gp, int cr, str
   11.40               * removed some translation or changed page attributes.
   11.41               * We simply invalidate the shadow.
   11.42               */
   11.43 -            mfn = get_mfn_from_pfn(value >> PAGE_SHIFT);
   11.44 +            mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT);
   11.45              if (mfn != pagetable_get_pfn(v->arch.guest_table))
   11.46                  __hvm_bug(regs);
   11.47              shadow_sync_all(v->domain);
   11.48 @@ -1377,7 +1377,7 @@ static int mov_to_cr(int gp, int cr, str
   11.49               */
   11.50              HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 value = %lx", value);
   11.51              if ( ((value >> PAGE_SHIFT) > v->domain->max_pages ) ||
   11.52 -                 !VALID_MFN(mfn = get_mfn_from_pfn(value >> PAGE_SHIFT)) ||
   11.53 +                 !VALID_MFN(mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT)) ||
   11.54                   !get_page(mfn_to_page(mfn), v->domain) )
   11.55              {
   11.56                  printk("Invalid CR3 value=%lx", value);
    12.1 --- a/xen/arch/x86/mm.c	Thu Feb 02 10:59:20 2006 +0000
    12.2 +++ b/xen/arch/x86/mm.c	Thu Feb 02 12:18:28 2006 +0100
    12.3 @@ -475,7 +475,7 @@ get_page_from_l1e(
    12.4      {
    12.5          MEM_LOG("Error getting mfn %lx (pfn %lx) from L1 entry %" PRIpte
    12.6                  " for dom%d",
    12.7 -                mfn, get_pfn_from_mfn(mfn), l1e_get_intpte(l1e), d->domain_id);
    12.8 +                mfn, get_gpfn_from_mfn(mfn), l1e_get_intpte(l1e), d->domain_id);
    12.9      }
   12.10  
   12.11      return okay;
   12.12 @@ -1507,7 +1507,7 @@ int get_page_type(struct page_info *page
   12.13                                  " != exp %" PRtype_info ") "
   12.14                                  "for mfn %lx (pfn %lx)",
   12.15                                  x, type, page_to_mfn(page),
   12.16 -                                get_pfn_from_mfn(page_to_mfn(page)));
   12.17 +                                get_gpfn_from_mfn(page_to_mfn(page)));
   12.18                      return 0;
   12.19                  }
   12.20                  else if ( (x & PGT_va_mask) == PGT_va_mutable )
   12.21 @@ -1547,7 +1547,7 @@ int get_page_type(struct page_info *page
   12.22          {
   12.23              MEM_LOG("Error while validating mfn %lx (pfn %lx) for type %"
   12.24                      PRtype_info ": caf=%08x taf=%" PRtype_info,
   12.25 -                    page_to_mfn(page), get_pfn_from_mfn(page_to_mfn(page)),
   12.26 +                    page_to_mfn(page), get_gpfn_from_mfn(page_to_mfn(page)),
   12.27                      type, page->count_info, page->u.inuse.type_info);
   12.28              /* Noone else can get a reference. We hold the only ref. */
   12.29              page->u.inuse.type_info = 0;
   12.30 @@ -2152,7 +2152,8 @@ int do_mmu_update(
   12.31  
   12.32          case MMU_MACHPHYS_UPDATE:
   12.33  
   12.34 -            if (shadow_mode_translate(FOREIGNDOM)) {
   12.35 +            if ( shadow_mode_translate(FOREIGNDOM) )
   12.36 +            {
   12.37                  MEM_LOG("can't mutate m2p table of translate mode guest");
   12.38                  break;
   12.39              }
   12.40 @@ -2166,7 +2167,7 @@ int do_mmu_update(
   12.41                  break;
   12.42              }
   12.43  
   12.44 -            set_pfn_from_mfn(mfn, gpfn);
   12.45 +            set_gpfn_from_mfn(mfn, gpfn);
   12.46              okay = 1;
   12.47  
   12.48              mark_dirty(FOREIGNDOM, mfn);
   12.49 @@ -2626,7 +2627,7 @@ long set_gdt(struct vcpu *v,
   12.50      struct domain *d = v->domain;
   12.51      /* NB. There are 512 8-byte entries per GDT page. */
   12.52      int i, nr_pages = (entries + 511) / 512;
   12.53 -    unsigned long pfn;
   12.54 +    unsigned long mfn;
   12.55  
   12.56      if ( entries > FIRST_RESERVED_GDT_ENTRY )
   12.57          return -EINVAL;
   12.58 @@ -2635,9 +2636,9 @@ long set_gdt(struct vcpu *v,
   12.59  
   12.60      /* Check the pages in the new GDT. */
   12.61      for ( i = 0; i < nr_pages; i++ ) {
   12.62 -        pfn = frames[i] = gmfn_to_mfn(d, frames[i]);
   12.63 -        if ((pfn >= max_page) ||
   12.64 -            !get_page_and_type(mfn_to_page(pfn), d, PGT_gdt_page) )
   12.65 +        mfn = frames[i] = gmfn_to_mfn(d, frames[i]);
   12.66 +        if ( !mfn_valid(mfn) ||
   12.67 +             !get_page_and_type(mfn_to_page(mfn), d, PGT_gdt_page) )
   12.68              goto fail;
   12.69      }
   12.70  
   12.71 @@ -2704,7 +2705,7 @@ long do_update_descriptor(u64 pa, u64 de
   12.72  
   12.73      if ( !VALID_MFN(mfn = gmfn_to_mfn(dom, gmfn)) ||
   12.74           (((unsigned int)pa % sizeof(struct desc_struct)) != 0) ||
   12.75 -         (mfn >= max_page) ||
   12.76 +         !mfn_valid(mfn) ||
   12.77           !check_descriptor(&d) )
   12.78      {
   12.79          UNLOCK_BIGLOCK(dom);
   12.80 @@ -2805,8 +2806,8 @@ long arch_memory_op(int op, void *arg)
   12.81          }
   12.82          UNLOCK_BIGLOCK(d);
   12.83  
   12.84 -        xrpa.first_pfn = d->arch.first_reserved_pfn;
   12.85 -        xrpa.nr_pfns   = 32;
   12.86 +        xrpa.first_gpfn = d->arch.first_reserved_pfn;
   12.87 +        xrpa.nr_gpfns   = 32;
   12.88  
   12.89          put_domain(d);
   12.90  
    13.1 --- a/xen/arch/x86/shadow32.c	Thu Feb 02 10:59:20 2006 +0000
    13.2 +++ b/xen/arch/x86/shadow32.c	Thu Feb 02 12:18:28 2006 +0100
    13.3 @@ -870,7 +870,7 @@ alloc_p2m_table(struct domain *d)
    13.4      {
    13.5          page = list_entry(list_ent, struct page_info, list);
    13.6          mfn = page_to_mfn(page);
    13.7 -        pfn = get_pfn_from_mfn(mfn);
    13.8 +        pfn = get_gpfn_from_mfn(mfn);
    13.9          ASSERT(pfn != INVALID_M2P_ENTRY);
   13.10          ASSERT(pfn < (1u<<20));
   13.11  
   13.12 @@ -884,7 +884,7 @@ alloc_p2m_table(struct domain *d)
   13.13      {
   13.14          page = list_entry(list_ent, struct page_info, list);
   13.15          mfn = page_to_mfn(page);
   13.16 -        pfn = get_pfn_from_mfn(mfn);
   13.17 +        pfn = get_gpfn_from_mfn(mfn);
   13.18          if ( (pfn != INVALID_M2P_ENTRY) &&
   13.19               (pfn < (1u<<20)) )
   13.20          {
   13.21 @@ -1410,7 +1410,7 @@ int shadow_mode_control(struct domain *d
   13.22  }
   13.23  
   13.24  unsigned long
   13.25 -get_mfn_from_pfn_foreign(struct domain *d, unsigned long gpfn)
   13.26 +get_mfn_from_gpfn_foreign(struct domain *d, unsigned long gpfn)
   13.27  {
   13.28      unsigned long va, tabpfn;
   13.29      l1_pgentry_t *l1, l1e;
   13.30 @@ -1418,7 +1418,7 @@ get_mfn_from_pfn_foreign(struct domain *
   13.31  
   13.32      ASSERT(shadow_mode_translate(d));
   13.33  
   13.34 -    perfc_incrc(get_mfn_from_pfn_foreign);
   13.35 +    perfc_incrc(get_mfn_from_gpfn_foreign);
   13.36  
   13.37      va = gpfn << PAGE_SHIFT;
   13.38      tabpfn = pagetable_get_pfn(d->arch.phys_table);
    14.1 --- a/xen/arch/x86/shadow_public.c	Thu Feb 02 10:59:20 2006 +0000
    14.2 +++ b/xen/arch/x86/shadow_public.c	Thu Feb 02 12:18:28 2006 +0100
    14.3 @@ -1397,7 +1397,7 @@ alloc_p2m_table(struct domain *d)
    14.4      {
    14.5          page = list_entry(list_ent, struct page_info, list);
    14.6          mfn = page_to_mfn(page);
    14.7 -        pfn = get_pfn_from_mfn(mfn);
    14.8 +        pfn = get_gpfn_from_mfn(mfn);
    14.9          ASSERT(pfn != INVALID_M2P_ENTRY);
   14.10          ASSERT(pfn < (1u<<20));
   14.11  
   14.12 @@ -1411,7 +1411,7 @@ alloc_p2m_table(struct domain *d)
   14.13      {
   14.14          page = list_entry(list_ent, struct page_info, list);
   14.15          mfn = page_to_mfn(page);
   14.16 -        pfn = get_pfn_from_mfn(mfn);
   14.17 +        pfn = get_gpfn_from_mfn(mfn);
   14.18          if ( (pfn != INVALID_M2P_ENTRY) &&
   14.19               (pfn < (1u<<20)) )
   14.20          {
   14.21 @@ -1599,7 +1599,7 @@ remove_shadow(struct domain *d, unsigned
   14.22  }
   14.23  
   14.24  unsigned long
   14.25 -get_mfn_from_pfn_foreign(struct domain *d, unsigned long gpfn)
   14.26 +get_mfn_from_gpfn_foreign(struct domain *d, unsigned long gpfn)
   14.27  {
   14.28      unsigned long va, tabpfn;
   14.29      l1_pgentry_t *l1, l1e;
   14.30 @@ -1607,7 +1607,7 @@ get_mfn_from_pfn_foreign(struct domain *
   14.31  
   14.32      ASSERT(shadow_mode_translate(d));
   14.33  
   14.34 -    perfc_incrc(get_mfn_from_pfn_foreign);
   14.35 +    perfc_incrc(get_mfn_from_gpfn_foreign);
   14.36  
   14.37      va = gpfn << PAGE_SHIFT;
   14.38      tabpfn = pagetable_get_pfn(d->arch.phys_table);
    15.1 --- a/xen/arch/x86/x86_32/mm.c	Thu Feb 02 10:59:20 2006 +0000
    15.2 +++ b/xen/arch/x86/x86_32/mm.c	Thu Feb 02 12:18:28 2006 +0100
    15.3 @@ -108,7 +108,7 @@ void __init paging_init(void)
    15.4  
    15.5      /* Fill with an obvious debug pattern. */
    15.6      for ( i = 0; i < (mpt_size / BYTES_PER_LONG); i++)
    15.7 -        set_pfn_from_mfn(i, 0x55555555);
    15.8 +        set_gpfn_from_mfn(i, 0x55555555);
    15.9  
   15.10      /* Create page tables for ioremap(). */
   15.11      for ( i = 0; i < (IOREMAP_MBYTES >> (L2_PAGETABLE_SHIFT - 20)); i++ )
    16.1 --- a/xen/arch/x86/x86_32/traps.c	Thu Feb 02 10:59:20 2006 +0000
    16.2 +++ b/xen/arch/x86/x86_32/traps.c	Thu Feb 02 12:18:28 2006 +0100
    16.3 @@ -84,7 +84,7 @@ void show_page_walk(unsigned long addr)
    16.4  #ifdef CONFIG_X86_PAE
    16.5      ptab = map_domain_page(mfn);
    16.6      ent  = ptab[l3_table_offset(addr)];
    16.7 -    pfn  = get_pfn_from_mfn((u32)(ent >> PAGE_SHIFT)); 
    16.8 +    pfn  = get_gpfn_from_mfn((u32)(ent >> PAGE_SHIFT)); 
    16.9      printk(" L3 = %"PRIpte" %08lx\n", ent, pfn);
   16.10      unmap_domain_page(ptab);
   16.11      if ( !(ent & _PAGE_PRESENT) )
   16.12 @@ -94,7 +94,7 @@ void show_page_walk(unsigned long addr)
   16.13  
   16.14      ptab = map_domain_page(mfn);
   16.15      ent  = ptab[l2_table_offset(addr)];
   16.16 -    pfn  = get_pfn_from_mfn((u32)(ent >> PAGE_SHIFT));
   16.17 +    pfn  = get_gpfn_from_mfn((u32)(ent >> PAGE_SHIFT));
   16.18      printk("  L2 = %"PRIpte" %08lx %s\n", ent, pfn, 
   16.19             (ent & _PAGE_PSE) ? "(PSE)" : "");
   16.20      unmap_domain_page(ptab);
   16.21 @@ -104,7 +104,7 @@ void show_page_walk(unsigned long addr)
   16.22  
   16.23      ptab = map_domain_page(ent >> PAGE_SHIFT);
   16.24      ent  = ptab[l1_table_offset(addr)];
   16.25 -    pfn  = get_pfn_from_mfn((u32)(ent >> PAGE_SHIFT));
   16.26 +    pfn  = get_gpfn_from_mfn((u32)(ent >> PAGE_SHIFT));
   16.27      printk("   L1 = %"PRIpte" %08lx\n", ent, pfn);
   16.28      unmap_domain_page(ptab);
   16.29  }
    17.1 --- a/xen/common/dom0_ops.c	Thu Feb 02 10:59:20 2006 +0000
    17.2 +++ b/xen/common/dom0_ops.c	Thu Feb 02 12:18:28 2006 +0100
    17.3 @@ -628,11 +628,11 @@ long do_dom0_op(struct dom0_op *u_dom0_o
    17.4      case DOM0_IOMEM_PERMISSION:
    17.5      {
    17.6          struct domain *d;
    17.7 -        unsigned long pfn = op->u.iomem_permission.first_pfn;
    17.8 -        unsigned long nr_pfns = op->u.iomem_permission.nr_pfns;
    17.9 +        unsigned long mfn = op->u.iomem_permission.first_mfn;
   17.10 +        unsigned long nr_mfns = op->u.iomem_permission.nr_mfns;
   17.11  
   17.12          ret = -EINVAL;
   17.13 -        if ( (pfn + nr_pfns - 1) < pfn ) /* wrap? */
   17.14 +        if ( (mfn + nr_mfns - 1) < mfn ) /* wrap? */
   17.15              break;
   17.16  
   17.17          ret = -ESRCH;
   17.18 @@ -641,9 +641,9 @@ long do_dom0_op(struct dom0_op *u_dom0_o
   17.19              break;
   17.20  
   17.21          if ( op->u.iomem_permission.allow_access )
   17.22 -            ret = iomem_permit_access(d, pfn, pfn + nr_pfns - 1);
   17.23 +            ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
   17.24          else
   17.25 -            ret = iomem_deny_access(d, pfn, pfn + nr_pfns - 1);
   17.26 +            ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1);
   17.27  
   17.28          put_domain(d);
   17.29      }
    18.1 --- a/xen/common/grant_table.c	Thu Feb 02 10:59:20 2006 +0000
    18.2 +++ b/xen/common/grant_table.c	Thu Feb 02 12:18:28 2006 +0100
    18.3 @@ -629,7 +629,6 @@ gnttab_prepare_for_transfer(
    18.4      u16            sflags;
    18.5      u32            scombo, prev_scombo;
    18.6      int            retries = 0;
    18.7 -    unsigned long  target_pfn;
    18.8  
    18.9      if ( unlikely((rgt = rd->grant_table) == NULL) ||
   18.10           unlikely(ref >= NR_GRANT_ENTRIES) )
   18.11 @@ -648,14 +647,6 @@ gnttab_prepare_for_transfer(
   18.12  
   18.13      for ( ; ; )
   18.14      {
   18.15 -        target_pfn = sha->frame;
   18.16 -
   18.17 -        if ( unlikely(target_pfn >= max_page ) )
   18.18 -        {
   18.19 -            DPRINTK("Bad pfn (%lx)\n", target_pfn);
   18.20 -            goto fail;
   18.21 -        }
   18.22 -
   18.23          if ( unlikely(sflags != GTF_accept_transfer) ||
   18.24               unlikely(sdom != ld->domain_id) )
   18.25          {
    19.1 --- a/xen/common/memory.c	Thu Feb 02 10:59:20 2006 +0000
    19.2 +++ b/xen/common/memory.c	Thu Feb 02 12:18:28 2006 +0100
    19.3 @@ -76,7 +76,7 @@ populate_physmap(
    19.4      int           *preempted)
    19.5  {
    19.6      struct page_info *page;
    19.7 -    unsigned long    i, j, pfn, mfn;
    19.8 +    unsigned long    i, j, gpfn, mfn;
    19.9  
   19.10      if ( !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) )
   19.11          return 0;
   19.12 @@ -104,18 +104,18 @@ populate_physmap(
   19.13  
   19.14          mfn = page_to_mfn(page);
   19.15  
   19.16 -        if ( unlikely(__get_user(pfn, &extent_list[i]) != 0) )
   19.17 +        if ( unlikely(__get_user(gpfn, &extent_list[i]) != 0) )
   19.18              goto out;
   19.19  
   19.20          if ( unlikely(shadow_mode_translate(d)) )
   19.21          {
   19.22              for ( j = 0; j < (1 << extent_order); j++ )
   19.23 -                guest_physmap_add_page(d, pfn + j, mfn + j);
   19.24 +                guest_physmap_add_page(d, gpfn + j, mfn + j);
   19.25          }
   19.26          else
   19.27          {
   19.28              for ( j = 0; j < (1 << extent_order); j++ )
   19.29 -                set_pfn_from_mfn(mfn + j, pfn + j);
   19.30 +                set_gpfn_from_mfn(mfn + j, gpfn + j);
   19.31  
   19.32              /* Inform the domain of the new page's machine address. */ 
   19.33              if ( __put_user(mfn, &extent_list[i]) != 0 )
   19.34 @@ -156,10 +156,10 @@ decrease_reservation(
   19.35          for ( j = 0; j < (1 << extent_order); j++ )
   19.36          {
   19.37              mfn = gmfn_to_mfn(d, gmfn + j);
   19.38 -            if ( unlikely(mfn >= max_page) )
   19.39 +            if ( unlikely(!mfn_valid(mfn)) )
   19.40              {
   19.41 -                DPRINTK("Domain %u page number out of range (%lx >= %lx)\n",
   19.42 -                        d->domain_id, mfn, max_page);
   19.43 +                DPRINTK("Domain %u page number %lx invalid\n",
   19.44 +                        d->domain_id, mfn);
   19.45                  return i;
   19.46              }
   19.47              
    20.1 --- a/xen/include/asm-ia64/config.h	Thu Feb 02 10:59:20 2006 +0000
    20.2 +++ b/xen/include/asm-ia64/config.h	Thu Feb 02 12:18:28 2006 +0100
    20.3 @@ -216,7 +216,7 @@ void sort_main_extable(void);
    20.4  #define page_info page
    20.5  
    20.6  // see common/memory.c
    20.7 -#define set_pfn_from_mfn(x,y)	do { } while (0)
    20.8 +#define set_gpfn_from_mfn(x,y)	do { } while (0)
    20.9  
   20.10  // see common/keyhandler.c
   20.11  #define	nop()	asm volatile ("nop 0")
    21.1 --- a/xen/include/asm-ia64/mm.h	Thu Feb 02 10:59:20 2006 +0000
    21.2 +++ b/xen/include/asm-ia64/mm.h	Thu Feb 02 12:18:28 2006 +0100
    21.3 @@ -415,8 +415,8 @@ extern unsigned long lookup_domain_mpa(s
    21.4  #define VALID_M2P(_e)            (!((_e) & (1U<<63)))
    21.5  #define IS_INVALID_M2P_ENTRY(_e) (!VALID_M2P(_e))
    21.6  
    21.7 -#define set_pfn_from_mfn(mfn, pfn) (machine_to_phys_mapping[(mfn)] = (pfn))
    21.8 -#define get_pfn_from_mfn(mfn)      (machine_to_phys_mapping[(mfn)])
    21.9 +#define set_gpfn_from_mfn(mfn, pfn) (machine_to_phys_mapping[(mfn)] = (pfn))
   21.10 +#define get_gpfn_from_mfn(mfn)      (machine_to_phys_mapping[(mfn)])
   21.11  
   21.12  /* If pmt table is provided by control pannel later, we need __get_user
   21.13  * here. However if it's allocated by HV, we should access it directly
    22.1 --- a/xen/include/asm-x86/grant_table.h	Thu Feb 02 10:59:20 2006 +0000
    22.2 +++ b/xen/include/asm-x86/grant_table.h	Thu Feb 02 12:18:28 2006 +0100
    22.3 @@ -25,7 +25,7 @@ int steal_page_for_grant_transfer(
    22.4      do {                                                                 \
    22.5          SHARE_PFN_WITH_DOMAIN(                                           \
    22.6              virt_to_page((char *)(t)->shared + ((i) * PAGE_SIZE)), (d)); \
    22.7 -        set_pfn_from_mfn(                                                \
    22.8 +        set_gpfn_from_mfn(                                               \
    22.9              (virt_to_maddr((t)->shared) >> PAGE_SHIFT) + (i),            \
   22.10              INVALID_M2P_ENTRY);                                          \
   22.11      } while ( 0 )
    23.1 --- a/xen/include/asm-x86/hvm/io.h	Thu Feb 02 10:59:20 2006 +0000
    23.2 +++ b/xen/include/asm-x86/hvm/io.h	Thu Feb 02 12:18:28 2006 +0100
    23.3 @@ -154,7 +154,7 @@ extern void hvm_pic_assist(struct vcpu *
    23.4  extern int cpu_get_interrupt(struct vcpu *v, int *type);
    23.5  
    23.6  // XXX - think about this, maybe use bit 30 of the mfn to signify an MMIO frame.
    23.7 -#define mmio_space(gpa) (!VALID_MFN(get_mfn_from_pfn((gpa) >> PAGE_SHIFT)))
    23.8 +#define mmio_space(gpa) (!VALID_MFN(get_mfn_from_gpfn((gpa) >> PAGE_SHIFT)))
    23.9  
   23.10  #endif /* __ASM_X86_HVM_IO_H__ */
   23.11  
    24.1 --- a/xen/include/asm-x86/mm.h	Thu Feb 02 10:59:20 2006 +0000
    24.2 +++ b/xen/include/asm-x86/mm.h	Thu Feb 02 12:18:28 2006 +0100
    24.3 @@ -262,8 +262,8 @@ int check_descriptor(struct desc_struct 
    24.4  #define VALID_M2P(_e)            (!((_e) & (1UL<<(BITS_PER_LONG-1))))
    24.5  #define IS_INVALID_M2P_ENTRY(_e) (!VALID_M2P(_e))
    24.6  
    24.7 -#define set_pfn_from_mfn(mfn, pfn) (machine_to_phys_mapping[(mfn)] = (pfn))
    24.8 -#define get_pfn_from_mfn(mfn)      (machine_to_phys_mapping[(mfn)])
    24.9 +#define set_gpfn_from_mfn(mfn, pfn) (machine_to_phys_mapping[(mfn)] = (pfn))
   24.10 +#define get_gpfn_from_mfn(mfn)      (machine_to_phys_mapping[(mfn)])
   24.11  
   24.12  /*
   24.13   * The phys_to_machine_mapping is the reversed mapping of MPT for full
   24.14 @@ -275,8 +275,8 @@ int check_descriptor(struct desc_struct 
   24.15  #define INVALID_MFN             (~0UL)
   24.16  #define VALID_MFN(_mfn)         (!((_mfn) & (1U<<31)))
   24.17  
   24.18 -#define set_mfn_from_pfn(pfn, mfn) (phys_to_machine_mapping[(pfn)] = (mfn))
   24.19 -static inline unsigned long get_mfn_from_pfn(unsigned long pfn)
   24.20 +#define set_mfn_from_gpfn(pfn, mfn) (phys_to_machine_mapping[(pfn)] = (mfn))
   24.21 +static inline unsigned long get_mfn_from_gpfn(unsigned long pfn)
   24.22  {
   24.23      unsigned long mfn;
   24.24      l1_pgentry_t pte;
    25.1 --- a/xen/include/asm-x86/shadow.h	Thu Feb 02 10:59:20 2006 +0000
    25.2 +++ b/xen/include/asm-x86/shadow.h	Thu Feb 02 12:18:28 2006 +0100
    25.3 @@ -285,19 +285,19 @@ static inline void shadow_mode_disable(s
    25.4  
    25.5  #define mfn_to_gmfn(_d, mfn)                         \
    25.6      ( (shadow_mode_translate(_d))                      \
    25.7 -      ? get_pfn_from_mfn(mfn)                          \
    25.8 +      ? get_gpfn_from_mfn(mfn)                          \
    25.9        : (mfn) )
   25.10  
   25.11  #define gmfn_to_mfn(_d, gpfn)                        \
   25.12      ({                                                 \
   25.13          unlikely(shadow_mode_translate(_d))            \
   25.14          ? (likely(current->domain == (_d))             \
   25.15 -           ? get_mfn_from_pfn(gpfn)                    \
   25.16 -           : get_mfn_from_pfn_foreign(_d, gpfn))       \
   25.17 +           ? get_mfn_from_gpfn(gpfn)                    \
   25.18 +           : get_mfn_from_gpfn_foreign(_d, gpfn))       \
   25.19          : (gpfn);                                      \
   25.20      })
   25.21  
   25.22 -extern unsigned long get_mfn_from_pfn_foreign(
   25.23 +extern unsigned long get_mfn_from_gpfn_foreign(
   25.24      struct domain *d, unsigned long gpfn);
   25.25  
   25.26  /************************************************************************/
   25.27 @@ -471,7 +471,7 @@ static inline void __mark_dirty(struct d
   25.28      ASSERT(d->arch.shadow_dirty_bitmap != NULL);
   25.29  
   25.30      /* We /really/ mean PFN here, even for non-translated guests. */
   25.31 -    pfn = get_pfn_from_mfn(mfn);
   25.32 +    pfn = get_gpfn_from_mfn(mfn);
   25.33  
   25.34      /*
   25.35       * Values with the MSB set denote MFNs that aren't really part of the 
   25.36 @@ -488,7 +488,7 @@ static inline void __mark_dirty(struct d
   25.37          d->arch.shadow_dirty_count++;
   25.38      }
   25.39  #ifndef NDEBUG
   25.40 -    else if ( mfn < max_page )
   25.41 +    else if ( mfn_valid(mfn) )
   25.42      {
   25.43          SH_VLOG("mark_dirty OOR! mfn=%lx pfn=%lx max=%x (dom %p)",
   25.44                 mfn, pfn, d->arch.shadow_dirty_bitmap_size, d);
   25.45 @@ -567,7 +567,7 @@ update_hl2e(struct vcpu *v, unsigned lon
   25.46      old_hl2e = v->arch.hl2_vtable[index];
   25.47  
   25.48      if ( (l2e_get_flags(gl2e) & _PAGE_PRESENT) &&
   25.49 -         VALID_MFN(mfn = get_mfn_from_pfn(l2e_get_pfn(gl2e))) )
   25.50 +         VALID_MFN(mfn = get_mfn_from_gpfn(l2e_get_pfn(gl2e))) )
   25.51          new_hl2e = l1e_from_pfn(mfn, __PAGE_HYPERVISOR);
   25.52      else
   25.53          new_hl2e = l1e_empty();
   25.54 @@ -649,7 +649,7 @@ static inline void guest_physmap_add_pag
   25.55      shadow_lock(d);
   25.56      shadow_sync_and_drop_references(d, mfn_to_page(mfn));
   25.57      set_p2m_entry(d, gpfn, mfn, &c1, &c2);
   25.58 -    set_pfn_from_mfn(mfn, gpfn);
   25.59 +    set_gpfn_from_mfn(mfn, gpfn);
   25.60      shadow_unlock(d);
   25.61      domain_mmap_cache_destroy(&c1);
   25.62      domain_mmap_cache_destroy(&c2);
   25.63 @@ -668,7 +668,7 @@ static inline void guest_physmap_remove_
   25.64      shadow_lock(d);
   25.65      shadow_sync_and_drop_references(d, mfn_to_page(mfn));
   25.66      set_p2m_entry(d, gpfn, -1, &c1, &c2);
   25.67 -    set_pfn_from_mfn(mfn, INVALID_M2P_ENTRY);
   25.68 +    set_gpfn_from_mfn(mfn, INVALID_M2P_ENTRY);
   25.69      shadow_unlock(d);
   25.70      domain_mmap_cache_destroy(&c1);
   25.71      domain_mmap_cache_destroy(&c2);
   25.72 @@ -894,7 +894,7 @@ static inline void hl2e_propagate_from_g
   25.73      if ( l2e_get_flags(gpde) & _PAGE_PRESENT )
   25.74      {
   25.75          mfn = gmfn_to_mfn(d, pfn);
   25.76 -        if ( VALID_MFN(mfn) && (mfn < max_page) )
   25.77 +        if ( VALID_MFN(mfn) && mfn_valid(mfn) )
   25.78              hl2e = l1e_from_pfn(mfn, __PAGE_HYPERVISOR);
   25.79      }
   25.80  
   25.81 @@ -1233,7 +1233,7 @@ static inline unsigned long ___shadow_st
   25.82  static inline unsigned long __shadow_status(
   25.83      struct domain *d, unsigned long gpfn, unsigned long stype)
   25.84  {
   25.85 -    unsigned long gmfn = ((current->domain == d)
   25.86 +    unsigned long mfn = ((current->domain == d)
   25.87                            ? gmfn_to_mfn(d, gpfn)
   25.88                            : INVALID_MFN);
   25.89  
   25.90 @@ -1241,22 +1241,22 @@ static inline unsigned long __shadow_sta
   25.91      ASSERT(gpfn == (gpfn & PGT_mfn_mask));
   25.92      ASSERT(stype && !(stype & ~PGT_type_mask));
   25.93  
   25.94 -    if ( VALID_MFN(gmfn) && (gmfn < max_page) &&
   25.95 +    if ( VALID_MFN(mfn) && mfn_valid(mfn) &&
   25.96           (stype != PGT_writable_pred) &&
   25.97           ((stype == PGT_snapshot)
   25.98 -          ? !mfn_out_of_sync(gmfn)
   25.99 -          : !mfn_is_page_table(gmfn)) )
  25.100 +          ? !mfn_out_of_sync(mfn)
  25.101 +          : !mfn_is_page_table(mfn)) )
  25.102      {
  25.103          perfc_incrc(shadow_status_shortcut);
  25.104  #ifndef NDEBUG
  25.105          if ( ___shadow_status(d, gpfn, stype) != 0 )
  25.106          {
  25.107 -            printk("d->id=%d gpfn=%lx gmfn=%lx stype=%lx c=%x t=%" PRtype_info " "
  25.108 -                   "mfn_out_of_sync(gmfn)=%d mfn_is_page_table(gmfn)=%d\n",
  25.109 -                   d->domain_id, gpfn, gmfn, stype,
  25.110 -                   mfn_to_page(gmfn)->count_info,
  25.111 -                   mfn_to_page(gmfn)->u.inuse.type_info,
  25.112 -                   mfn_out_of_sync(gmfn), mfn_is_page_table(gmfn));
  25.113 +            printk("d->id=%d gpfn=%lx mfn=%lx stype=%lx c=%x t=%" PRtype_info " "
  25.114 +                   "mfn_out_of_sync(mfn)=%d mfn_is_page_table(mfn)=%d\n",
  25.115 +                   d->domain_id, gpfn, mfn, stype,
  25.116 +                   mfn_to_page(mfn)->count_info,
  25.117 +                   mfn_to_page(mfn)->u.inuse.type_info,
  25.118 +                   mfn_out_of_sync(mfn), mfn_is_page_table(mfn));
  25.119              BUG();
  25.120          }
  25.121  
    26.1 --- a/xen/include/asm-x86/shadow_64.h	Thu Feb 02 10:59:20 2006 +0000
    26.2 +++ b/xen/include/asm-x86/shadow_64.h	Thu Feb 02 12:18:28 2006 +0100
    26.3 @@ -176,7 +176,7 @@ static inline int __entry(
    26.4          }
    26.5          mfn = entry_get_pfn(*le_e);
    26.6          if ( (flag & GUEST_ENTRY) && shadow_mode_translate(d) )
    26.7 -            mfn = get_mfn_from_pfn(mfn);
    26.8 +            mfn = get_mfn_from_gpfn(mfn);
    26.9          if ( le_p )
   26.10              unmap_domain_page(le_p);
   26.11          le_p = (pgentry_64_t *)map_domain_page(mfn);
   26.12 @@ -301,7 +301,7 @@ static inline int  __guest_set_l1e(
   26.13                  if (unlikely(!(l2e_get_flags_32(gl2e) & _PAGE_PRESENT)))
   26.14                      return 0;
   26.15  
   26.16 -                l1mfn = get_mfn_from_pfn(
   26.17 +                l1mfn = get_mfn_from_gpfn(
   26.18                    l2e_get_pfn(gl2e));
   26.19  
   26.20                  l1va = (l1_pgentry_32_t *)map_domain_page(l1mfn);
   26.21 @@ -343,7 +343,7 @@ static inline int  __guest_get_l1e(
   26.22                      return 0;
   26.23  
   26.24  
   26.25 -                l1mfn = get_mfn_from_pfn(
   26.26 +                l1mfn = get_mfn_from_gpfn(
   26.27                    l2e_get_pfn(gl2e));
   26.28                  l1va = (l1_pgentry_32_t *) map_domain_page(l1mfn);
   26.29                  if (gl1e)
    27.1 --- a/xen/include/public/dom0_ops.h	Thu Feb 02 10:59:20 2006 +0000
    27.2 +++ b/xen/include/public/dom0_ops.h	Thu Feb 02 12:18:28 2006 +0100
    27.3 @@ -141,11 +141,11 @@ typedef struct dom0_settime {
    27.4  
    27.5  typedef struct dom0_getpageframeinfo {
    27.6      /* IN variables. */
    27.7 -    unsigned long pfn;     /* Machine page frame number to query.       */
    27.8 +    unsigned long mfn;     /* Machine page frame number to query.       */
    27.9      domid_t domain;        /* To which domain does the frame belong?    */
   27.10      /* OUT variables. */
   27.11      /* Is the page PINNED to a type? */
   27.12 -    uint32_t type;              /* see above type defs */
   27.13 +    uint32_t type;         /* see above type defs */
   27.14  } dom0_getpageframeinfo_t;
   27.15  
   27.16  /*
   27.17 @@ -263,7 +263,7 @@ typedef struct dom0_getpageframeinfo2 {
   27.18  } dom0_getpageframeinfo2_t;
   27.19  
   27.20  /*
   27.21 - * Request memory range (@pfn, @pfn+@nr_pfns-1) to have type @type.
   27.22 + * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
   27.23   * On x86, @type is an architecture-defined MTRR memory type.
   27.24   * On success, returns the MTRR that was used (@reg) and a handle that can
   27.25   * be passed to DOM0_DEL_MEMTYPE to accurately tear down the new setting.
   27.26 @@ -272,8 +272,8 @@ typedef struct dom0_getpageframeinfo2 {
   27.27  #define DOM0_ADD_MEMTYPE         31
   27.28  typedef struct dom0_add_memtype {
   27.29      /* IN variables. */
   27.30 -    unsigned long pfn;
   27.31 -    unsigned long nr_pfns;
   27.32 +    unsigned long mfn;
   27.33 +    unsigned long nr_mfns;
   27.34      uint32_t      type;
   27.35      /* OUT variables. */
   27.36      uint32_t      handle;
   27.37 @@ -300,8 +300,8 @@ typedef struct dom0_read_memtype {
   27.38      /* IN variables. */
   27.39      uint32_t reg;
   27.40      /* OUT variables. */
   27.41 -    unsigned long pfn;
   27.42 -    unsigned long nr_pfns;
   27.43 +    unsigned long mfn;
   27.44 +    unsigned long nr_mfns;
   27.45      uint32_t type;
   27.46  } dom0_read_memtype_t;
   27.47  
   27.48 @@ -419,8 +419,8 @@ typedef struct dom0_irq_permission {
   27.49  #define DOM0_IOMEM_PERMISSION 47
   27.50  typedef struct dom0_iomem_permission {
   27.51      domid_t  domain;          /* domain to be affected */
   27.52 -    unsigned long first_pfn;  /* first page (physical page number) in range */
   27.53 -    unsigned long nr_pfns;    /* number of pages in range (>0) */
   27.54 +    unsigned long first_mfn;  /* first page (physical page number) in range */
   27.55 +    unsigned long nr_mfns;    /* number of pages in range (>0) */
   27.56      uint8_t allow_access;     /* allow (!0) or deny (0) access to range? */
   27.57  } dom0_iomem_permission_t;
   27.58   
    28.1 --- a/xen/include/public/memory.h	Thu Feb 02 10:59:20 2006 +0000
    28.2 +++ b/xen/include/public/memory.h	Thu Feb 02 12:18:28 2006 +0100
    28.3 @@ -21,12 +21,12 @@ typedef struct xen_memory_reservation {
    28.4  
    28.5      /*
    28.6       * XENMEM_increase_reservation:
    28.7 -     *   OUT: MFN bases of extents that were allocated
    28.8 +     *   OUT: MFN (*not* GMFN) bases of extents that were allocated
    28.9       * XENMEM_decrease_reservation:
   28.10 -     *   IN:  MFN bases of extents to free
   28.11 +     *   IN:  GMFN bases of extents to free
   28.12       * XENMEM_populate_physmap:
   28.13 -     *   IN:  PFN bases of extents to populate with memory
   28.14 -     *   OUT: MFN bases of extents that were allocated
   28.15 +     *   IN:  GPFN bases of extents to populate with memory
   28.16 +     *   OUT: GMFN bases of extents that were allocated
   28.17       *   (NB. This command also updates the mach_to_phys translation table)
   28.18       */
   28.19      unsigned long *extent_start;
   28.20 @@ -36,7 +36,7 @@ typedef struct xen_memory_reservation {
   28.21      unsigned int   extent_order;
   28.22  
   28.23      /*
   28.24 -     * Mmaximum # bits addressable by the user of the allocated region (e.g., 
   28.25 +     * Maximum # bits addressable by the user of the allocated region (e.g., 
   28.26       * I/O devices often have a 32-bit limitation even in 64-bit systems). If 
   28.27       * zero then the user has no addressing restriction.
   28.28       * This field is not used by XENMEM_decrease_reservation.
   28.29 @@ -111,7 +111,7 @@ typedef struct xen_reserved_phys_area {
   28.30      unsigned int idx;
   28.31  
   28.32      /* Base and size of the specified reserved area. */
   28.33 -    unsigned long first_pfn, nr_pfns;
   28.34 +    unsigned long first_gpfn, nr_gpfns;
   28.35  } xen_reserved_phys_area_t;
   28.36  
   28.37  #endif /* __XEN_PUBLIC_MEMORY_H__ */
    29.1 --- a/xen/include/xen/perfc_defn.h	Thu Feb 02 10:59:20 2006 +0000
    29.2 +++ b/xen/include/xen/perfc_defn.h	Thu Feb 02 12:18:28 2006 +0100
    29.3 @@ -114,7 +114,7 @@ PERFCOUNTER_CPU(shadow_get_page_fail,   
    29.4  PERFCOUNTER_CPU(validate_hl2e_calls,    "calls to validate_hl2e_change")
    29.5  PERFCOUNTER_CPU(validate_hl2e_changes,  "validate_hl2e makes changes")
    29.6  PERFCOUNTER_CPU(exception_fixed,        "pre-exception fixed")
    29.7 -PERFCOUNTER_CPU(get_mfn_from_pfn_foreign, "calls to get_mfn_from_pfn_foreign")
    29.8 +PERFCOUNTER_CPU(get_mfn_from_gpfn_foreign, "calls to get_mfn_from_gpfn_foreign")
    29.9  PERFCOUNTER_CPU(remove_all_access,      "calls to remove_all_access")
   29.10  PERFCOUNTER_CPU(remove_write_access,    "calls to remove_write_access")
   29.11  PERFCOUNTER_CPU(remove_write_access_easy, "easy outs of remove_write_access")