ia64/xen-unstable

changeset 4281:4e75e4b2a644

bitkeeper revision 1.1236.1.121 (4241b323XMPDUSRi1JDaRbTNG69CgA)

A few ptwr cleanups/fixes.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Mar 23 18:19:15 2005 +0000 (2005-03-23)
parents 467573b27a0e
children 3f85b523b318 d00a8ce82dcf
files xen/arch/x86/mm.c
line diff
     1.1 --- a/xen/arch/x86/mm.c	Wed Mar 23 18:18:19 2005 +0000
     1.2 +++ b/xen/arch/x86/mm.c	Wed Mar 23 18:19:15 2005 +0000
     1.3 @@ -2398,8 +2398,7 @@ void ptwr_flush(const int which)
     1.4              l1pte_propagate_from_guest(
     1.5                  d, &l1_pgentry_val(nl1e), &l1_pgentry_val(sl1e[i]));
     1.6  
     1.7 -        if ( unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT) )
     1.8 -            put_page_from_l1e(ol1e, d);
     1.9 +        put_page_from_l1e(ol1e, d);
    1.10      }
    1.11      unmap_domain_mem(pl1e);
    1.12  
    1.13 @@ -2443,7 +2442,7 @@ static int ptwr_emulated_update(
    1.14      struct domain *d = current->domain;
    1.15  
    1.16      /* Aligned access only, thank you. */
    1.17 -    if ( (addr & (bytes-1)) != 0 )
    1.18 +    if ( !access_ok(VERIFY_WRITE, addr, bytes) || ((addr & (bytes-1)) != 0) )
    1.19      {
    1.20          MEM_LOG("ptwr_emulate: Unaligned or bad size ptwr access (%d, %p)\n",
    1.21                  bytes, addr);
    1.22 @@ -2481,7 +2480,8 @@ static int ptwr_emulated_update(
    1.23  
    1.24      /* We are looking only for read-only mappings of p.t. pages. */
    1.25      if ( ((pte & (_PAGE_RW | _PAGE_PRESENT)) != _PAGE_PRESENT) ||
    1.26 -         ((page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table) )
    1.27 +         ((page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table) ||
    1.28 +         (page_get_owner(page) != d) )
    1.29      {
    1.30          MEM_LOG("ptwr_emulate: Page is mistyped or bad pte (%p, %x)\n",
    1.31                  pte, page->u.inuse.type_info);
    1.32 @@ -2501,6 +2501,7 @@ static int ptwr_emulated_update(
    1.33          if ( cmpxchg((unsigned long *)pl1e, old, val) != old )
    1.34          {
    1.35              unmap_domain_mem(pl1e);
    1.36 +            put_page_from_l1e(nl1e, d);
    1.37              return X86EMUL_CMPXCHG_FAILED;
    1.38          }
    1.39      }
    1.40 @@ -2526,8 +2527,7 @@ static int ptwr_emulated_update(
    1.41      }
    1.42  
    1.43      /* Finally, drop the old PTE. */
    1.44 -    if ( unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT) )
    1.45 -        put_page_from_l1e(ol1e, d);
    1.46 +    put_page_from_l1e(ol1e, d);
    1.47  
    1.48      return X86EMUL_CONTINUE;
    1.49  }
    1.50 @@ -2587,7 +2587,8 @@ int ptwr_do_page_fault(unsigned long add
    1.51  
    1.52      /* We are looking only for read-only mappings of p.t. pages. */
    1.53      if ( ((pte & (_PAGE_RW | _PAGE_PRESENT)) != _PAGE_PRESENT) ||
    1.54 -         ((page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table) )
    1.55 +         ((page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table) ||
    1.56 +         (page_get_owner(page) != ed->domain) )
    1.57      {
    1.58          return 0;
    1.59      }