ia64/xen-unstable

changeset 18185:7f65527eacd6

x86: fix a few page table handling issues

- adjust_guest_l?e() shouldn't be called on non-guest entries
- unadjust_guest_l3e() should be called in the back-out loop of
alloc_l3_table()
- create_pae_xen_mappings() and pae_flush_pgd() shouldn't be called in
the failure case of mod_l3_entry()

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 29 10:05:32 2008 +0100 (2008-07-29)
parents b25fa9df7375
children 507045f254e9
files xen/arch/x86/mm.c
line diff
     1.1 --- a/xen/arch/x86/mm.c	Tue Jul 29 09:57:14 2008 +0100
     1.2 +++ b/xen/arch/x86/mm.c	Tue Jul 29 10:05:32 2008 +0100
     1.3 @@ -1138,8 +1138,10 @@ static int alloc_l2_table(struct page_in
     1.4  
     1.5      for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ )
     1.6      {
     1.7 -        if ( is_guest_l2_slot(d, type, i) &&
     1.8 -             unlikely(!get_page_from_l2e(pl2e[i], pfn, d)) )
     1.9 +        if ( !is_guest_l2_slot(d, type, i) )
    1.10 +            continue;
    1.11 +
    1.12 +        if ( unlikely(!get_page_from_l2e(pl2e[i], pfn, d)) )
    1.13              goto fail;
    1.14          
    1.15          adjust_guest_l2e(pl2e[i], d);
    1.16 @@ -1206,8 +1208,9 @@ static int alloc_l3_table(struct page_in
    1.17                                                  d) )
    1.18                  goto fail;
    1.19          }
    1.20 -        else if ( is_guest_l3_slot(i) &&
    1.21 -                  unlikely(!get_page_from_l3e(pl3e[i], pfn, d)) )
    1.22 +        else if ( !is_guest_l3_slot(i) )
    1.23 +            continue;
    1.24 +        else if ( unlikely(!get_page_from_l3e(pl3e[i], pfn, d)) )
    1.25              goto fail;
    1.26  
    1.27          adjust_guest_l3e(pl3e[i], d);
    1.28 @@ -1222,8 +1225,12 @@ static int alloc_l3_table(struct page_in
    1.29   fail:
    1.30      MEM_LOG("Failure in alloc_l3_table: entry %d", i);
    1.31      while ( i-- > 0 )
    1.32 -        if ( is_guest_l3_slot(i) )
    1.33 -            put_page_from_l3e(pl3e[i], pfn);
    1.34 +    {
    1.35 +        if ( !is_guest_l3_slot(i) )
    1.36 +            continue;
    1.37 +        unadjust_guest_l3e(pl3e[i], d);
    1.38 +        put_page_from_l3e(pl3e[i], pfn);
    1.39 +    }
    1.40  
    1.41      unmap_domain_page(pl3e);
    1.42      return 0;
    1.43 @@ -1242,8 +1249,10 @@ static int alloc_l4_table(struct page_in
    1.44  
    1.45      for ( i = 0; i < L4_PAGETABLE_ENTRIES; i++ )
    1.46      {
    1.47 -        if ( is_guest_l4_slot(d, i) &&
    1.48 -             unlikely(!get_page_from_l4e(pl4e[i], pfn, d)) )
    1.49 +        if ( !is_guest_l4_slot(d, i) )
    1.50 +            continue;
    1.51 +
    1.52 +        if ( unlikely(!get_page_from_l4e(pl4e[i], pfn, d)) )
    1.53              goto fail;
    1.54  
    1.55          adjust_guest_l4e(pl4e[i], d);
    1.56 @@ -1585,7 +1594,7 @@ static int mod_l3_entry(l3_pgentry_t *pl
    1.57      struct vcpu *curr = current;
    1.58      struct domain *d = curr->domain;
    1.59      struct page_info *l3pg = mfn_to_page(pfn);
    1.60 -    int okay, rc = 1;
    1.61 +    int rc = 1;
    1.62  
    1.63      if ( unlikely(!is_guest_l3_slot(pgentry_ptr_to_slot(pl3e))) )
    1.64      {
    1.65 @@ -1642,10 +1651,13 @@ static int mod_l3_entry(l3_pgentry_t *pl
    1.66          return 0;
    1.67      }
    1.68  
    1.69 -    okay = create_pae_xen_mappings(d, pl3e);
    1.70 -    BUG_ON(!okay);
    1.71 -
    1.72 -    pae_flush_pgd(pfn, pgentry_ptr_to_slot(pl3e), nl3e);
    1.73 +    if ( likely(rc) )
    1.74 +    {
    1.75 +        if ( !create_pae_xen_mappings(d, pl3e) )
    1.76 +            BUG();
    1.77 +
    1.78 +        pae_flush_pgd(pfn, pgentry_ptr_to_slot(pl3e), nl3e);
    1.79 +    }
    1.80  
    1.81      page_unlock(l3pg);
    1.82      put_page_from_l3e(ol3e, pfn);