ia64/xen-unstable

changeset 9074:bd816eee9cf6

Clean wrpt state when emulating CR3 write.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Mar 01 14:49:31 2006 +0100 (2006-03-01)
parents a376bab39768
children d8451bb6278c
files xen/arch/x86/mm.c xen/arch/x86/traps.c xen/include/asm-x86/mm.h
line diff
     1.1 --- a/xen/arch/x86/mm.c	Tue Feb 28 22:57:38 2006 +0100
     1.2 +++ b/xen/arch/x86/mm.c	Wed Mar 01 14:49:31 2006 +0100
     1.3 @@ -475,7 +475,8 @@ get_page_from_l1e(
     1.4      {
     1.5          MEM_LOG("Error getting mfn %lx (pfn %lx) from L1 entry %" PRIpte
     1.6                  " for dom%d",
     1.7 -                mfn, get_gpfn_from_mfn(mfn), l1e_get_intpte(l1e), d->domain_id);
     1.8 +                mfn, get_gpfn_from_mfn(mfn),
     1.9 +                l1e_get_intpte(l1e), d->domain_id);
    1.10      }
    1.11  
    1.12      return okay;
    1.13 @@ -515,7 +516,6 @@ get_page_from_l2e(
    1.14  
    1.15  
    1.16  #if CONFIG_PAGING_LEVELS >= 3
    1.17 -
    1.18  static int 
    1.19  get_page_from_l3e(
    1.20      l3_pgentry_t l3e, unsigned long pfn,
    1.21 @@ -545,11 +545,9 @@ get_page_from_l3e(
    1.22  #endif
    1.23      return rc;
    1.24  }
    1.25 -
    1.26  #endif /* 3 level */
    1.27  
    1.28  #if CONFIG_PAGING_LEVELS >= 4
    1.29 -
    1.30  static int 
    1.31  get_page_from_l4e(
    1.32      l4_pgentry_t l4e, unsigned long pfn, 
    1.33 @@ -579,7 +577,6 @@ get_page_from_l4e(
    1.34  
    1.35      return rc;
    1.36  }
    1.37 -
    1.38  #endif /* 4 level */
    1.39  
    1.40  
    1.41 @@ -649,28 +646,23 @@ static void put_page_from_l2e(l2_pgentry
    1.42  
    1.43  
    1.44  #if CONFIG_PAGING_LEVELS >= 3
    1.45 -
    1.46  static void put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn)
    1.47  {
    1.48      if ( (l3e_get_flags(l3e) & _PAGE_PRESENT) && 
    1.49           (l3e_get_pfn(l3e) != pfn) )
    1.50          put_page_and_type(mfn_to_page(l3e_get_pfn(l3e)));
    1.51  }
    1.52 -
    1.53  #endif
    1.54  
    1.55  #if CONFIG_PAGING_LEVELS >= 4
    1.56 -
    1.57  static void put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn)
    1.58  {
    1.59      if ( (l4e_get_flags(l4e) & _PAGE_PRESENT) && 
    1.60           (l4e_get_pfn(l4e) != pfn) )
    1.61          put_page_and_type(mfn_to_page(l4e_get_pfn(l4e)));
    1.62  }
    1.63 -
    1.64  #endif
    1.65  
    1.66 -
    1.67  static int alloc_l1_table(struct page_info *page)
    1.68  {
    1.69      struct domain *d = page_get_owner(page);
    1.70 @@ -1569,6 +1561,8 @@ int new_guest_cr3(unsigned long mfn)
    1.71      int okay;
    1.72      unsigned long old_base_mfn;
    1.73  
    1.74 +    ASSERT(writable_pagetable_in_sync(d));
    1.75 +
    1.76      if ( shadow_mode_refcounts(d) )
    1.77      {
    1.78          okay = get_page_from_pagenr(mfn, d);
     2.1 --- a/xen/arch/x86/traps.c	Tue Feb 28 22:57:38 2006 +0100
     2.2 +++ b/xen/arch/x86/traps.c	Wed Mar 01 14:49:31 2006 +0100
     2.3 @@ -951,6 +951,7 @@ static int emulate_privileged_op(struct 
     2.4              
     2.5          case 3: /* Write CR3 */
     2.6              LOCK_BIGLOCK(v->domain);
     2.7 +            cleanup_writable_pagetable(v->domain);
     2.8              (void)new_guest_cr3(gmfn_to_mfn(v->domain, paddr_to_pfn(*reg)));
     2.9              UNLOCK_BIGLOCK(v->domain);
    2.10              break;
     3.1 --- a/xen/include/asm-x86/mm.h	Tue Feb 28 22:57:38 2006 +0100
     3.2 +++ b/xen/include/asm-x86/mm.h	Wed Mar 01 14:49:31 2006 +0100
     3.3 @@ -337,6 +337,10 @@ void cleanup_writable_pagetable(struct d
     3.4          UNLOCK_BIGLOCK(d);                                      \
     3.5      } while ( 0 )
     3.6  
     3.7 +#define writable_pagetable_in_sync(d)           \
     3.8 +    (!((d)->arch.ptwr[PTWR_PT_ACTIVE].l1va |    \
     3.9 +       (d)->arch.ptwr[PTWR_PT_INACTIVE].l1va))
    3.10 +
    3.11  int audit_adjust_pgtables(struct domain *d, int dir, int noisy);
    3.12  
    3.13  #ifndef NDEBUG