ia64/xen-unstable

changeset 18699:066c84c7018a

Fix guest_physmap_add_entry sanity checking logic

Fix the logic of the p->m and m->p mapping sanity checks and fixup in
guest_physmap_add_entry().

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Oct 22 11:56:44 2008 +0100 (2008-10-22)
parents 008505c3c65a
children 96d8b7f40dc7
files xen/arch/x86/mm/p2m.c
line diff
     1.1 --- a/xen/arch/x86/mm/p2m.c	Wed Oct 22 11:55:33 2008 +0100
     1.2 +++ b/xen/arch/x86/mm/p2m.c	Wed Oct 22 11:56:44 2008 +0100
     1.3 @@ -956,18 +956,18 @@ guest_physmap_add_entry(struct domain *d
     1.4      /* First, remove m->p mappings for existing p->m mappings */
     1.5      for ( i = 0; i < (1UL << page_order); i++ )
     1.6      {
     1.7 -        omfn = gfn_to_mfn(d, gfn, &ot);
     1.8 +        omfn = gfn_to_mfn(d, gfn + i, &ot);
     1.9          if ( p2m_is_ram(ot) )
    1.10          {
    1.11              ASSERT(mfn_valid(omfn));
    1.12 -            set_gpfn_from_mfn(mfn_x(omfn)+i, INVALID_M2P_ENTRY);
    1.13 +            set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY);
    1.14          }
    1.15      }
    1.16  
    1.17      /* Then, look for m->p mappings for this range and deal with them */
    1.18      for ( i = 0; i < (1UL << page_order); i++ )
    1.19      {
    1.20 -        ogfn = mfn_to_gfn(d, _mfn(mfn));
    1.21 +        ogfn = mfn_to_gfn(d, _mfn(mfn+i));
    1.22          if (
    1.23  #ifdef __x86_64__
    1.24              (ogfn != 0x5555555555555555L)
    1.25 @@ -975,20 +975,20 @@ guest_physmap_add_entry(struct domain *d
    1.26              (ogfn != 0x55555555L)
    1.27  #endif
    1.28              && (ogfn != INVALID_M2P_ENTRY)
    1.29 -            && (ogfn != gfn) )
    1.30 +            && (ogfn != gfn + i) )
    1.31          {
    1.32              /* This machine frame is already mapped at another physical
    1.33               * address */
    1.34              P2M_DEBUG("aliased! mfn=%#lx, old gfn=%#lx, new gfn=%#lx\n",
    1.35 -                      mfn, ogfn, gfn);
    1.36 +                      mfn + i, ogfn, gfn + i);
    1.37              omfn = gfn_to_mfn(d, ogfn, &ot);
    1.38              if ( p2m_is_ram(ot) )
    1.39              {
    1.40                  ASSERT(mfn_valid(omfn));
    1.41                  P2M_DEBUG("old gfn=%#lx -> mfn %#lx\n",
    1.42                            ogfn , mfn_x(omfn));
    1.43 -                if ( mfn_x(omfn) == mfn )
    1.44 -                    p2m_remove_page(d, ogfn, mfn, 0);
    1.45 +                if ( mfn_x(omfn) == (mfn + i) )
    1.46 +                    p2m_remove_page(d, ogfn, mfn + i, 0);
    1.47              }
    1.48          }
    1.49      }