ia64/xen-unstable

changeset 13449:fd2667419c53

[XEN] Fix early-unshadow detection for 3- or 4-level guest pagetables.
Early-unshadow will unshadow whenever 2 zero values are written
to the same page; for PAE, one PTE takes 2 writes. Only check
for the early unshadow when writing the low half of the PTE.
author George Dunlap <dunlapg@umich.edu>
date Tue Jan 16 14:04:12 2007 -0500 (2007-01-16)
parents 895d873a00b4
children 2ff7dedde1e3
files xen/arch/x86/mm/shadow/multi.c xen/arch/x86/mm/shadow/private.h
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/multi.c	Tue Jan 16 10:02:50 2007 +0000
     1.2 +++ b/xen/arch/x86/mm/shadow/multi.c	Tue Jan 16 14:04:12 2007 -0500
     1.3 @@ -3944,7 +3944,7 @@ sh_x86_emulate_write(struct vcpu *v, uns
     1.4      if ( !skip ) sh_validate_guest_pt_write(v, mfn, addr, bytes);
     1.5  
     1.6      /* If we are writing zeros to this page, might want to unshadow */
     1.7 -    if ( likely(bytes >= 4) && (*(u32 *)addr == 0) )
     1.8 +    if ( likely(bytes >= 4) && (*(u32 *)addr == 0) && is_lo_pte(vaddr) )
     1.9          check_for_early_unshadow(v, mfn);
    1.10  
    1.11      sh_unmap_domain_page(addr);
    1.12 @@ -3996,7 +3996,7 @@ sh_x86_emulate_cmpxchg(struct vcpu *v, u
    1.13                    vaddr, prev, old, new, *(unsigned long *)addr, bytes);
    1.14  
    1.15      /* If we are writing zeros to this page, might want to unshadow */
    1.16 -    if ( likely(bytes >= 4) && (*(u32 *)addr == 0) )
    1.17 +    if ( likely(bytes >= 4) && (*(u32 *)addr == 0) && is_lo_pte(vaddr) )
    1.18          check_for_early_unshadow(v, mfn);
    1.19  
    1.20      sh_unmap_domain_page(addr);
     2.1 --- a/xen/arch/x86/mm/shadow/private.h	Tue Jan 16 10:02:50 2007 +0000
     2.2 +++ b/xen/arch/x86/mm/shadow/private.h	Tue Jan 16 14:04:12 2007 -0500
     2.3 @@ -427,6 +427,11 @@ extern int sh_remove_write_access(struct
     2.4  #undef mfn_valid
     2.5  #define mfn_valid(_mfn) (mfn_x(_mfn) < max_page)
     2.6  
     2.7 +#if GUEST_PAGING_LEVELS >= 3
     2.8 +# define is_lo_pte(_vaddr) (((_vaddr)&0x4)==0)
     2.9 +#else
    2.10 +# define is_lo_pte(_vaddr) (1)
    2.11 +#endif
    2.12  
    2.13  static inline int
    2.14  sh_mfn_is_a_page_table(mfn_t gmfn)