ia64/xen-unstable

changeset 11188:395bfcf84451

Fix handling of PS bit in 64-bit pagetables

Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author tdeegan@york.uk.xensource.com
date Thu Aug 17 16:05:51 2006 +0100 (2006-08-17)
parents b9af81884b99
children 0882db2677b0
files xen/arch/x86/shadow2-common.c xen/arch/x86/shadow2.c xen/include/asm-x86/shadow2-private.h
line diff
     1.1 --- a/xen/arch/x86/shadow2-common.c	Thu Aug 17 12:08:26 2006 +0100
     1.2 +++ b/xen/arch/x86/shadow2-common.c	Thu Aug 17 16:05:51 2006 +0100
     1.3 @@ -2165,9 +2165,6 @@ void sh2_remove_shadows(struct vcpu *v, 
     1.4          0  /* unused  */
     1.5      };
     1.6  
     1.7 -    SHADOW2_PRINTK("d=%d, v=%d, gmfn=%05lx\n",
     1.8 -                   v->domain->domain_id, v->vcpu_id, mfn_x(gmfn));
     1.9 -
    1.10      ASSERT(shadow2_lock_is_acquired(v->domain));
    1.11  
    1.12      pg = mfn_to_page(gmfn);
    1.13 @@ -2176,6 +2173,9 @@ void sh2_remove_shadows(struct vcpu *v, 
    1.14      if ( (pg->count_info & PGC_page_table) == 0 )
    1.15          return;
    1.16  
    1.17 +    SHADOW2_PRINTK("d=%d, v=%d, gmfn=%05lx\n",
    1.18 +                   v->domain->domain_id, v->vcpu_id, mfn_x(gmfn));
    1.19 +
    1.20      /* Search for this shadow in all appropriate shadows */
    1.21      perfc_incrc(shadow2_unshadow);
    1.22      sh_flags = pg->shadow2_flags;
    1.23 @@ -2843,7 +2843,7 @@ sh2_p2m_remove_page(struct domain *d, un
    1.24          v = d->vcpu[0];
    1.25  
    1.26  
    1.27 -    SHADOW2_PRINTK("removing gfn=%#lx mfn=%#lx\n", gfn, mfn);
    1.28 +    SHADOW2_DEBUG(P2M, "removing gfn=%#lx mfn=%#lx\n", gfn, mfn);
    1.29  
    1.30      ASSERT(mfn_x(sh2_gfn_to_mfn(d, gfn)) == mfn);
    1.31      //ASSERT(sh2_mfn_to_gfn(d, mfn) == gfn);
     2.1 --- a/xen/arch/x86/shadow2.c	Thu Aug 17 12:08:26 2006 +0100
     2.2 +++ b/xen/arch/x86/shadow2.c	Thu Aug 17 16:05:51 2006 +0100
     2.3 @@ -234,6 +234,28 @@ delete_shadow2_status(struct vcpu *v, mf
     2.4      put_page(mfn_to_page(gmfn));
     2.5  }
     2.6  
     2.7 +/**************************************************************************/
     2.8 +/* CPU feature support querying */
     2.9 +
    2.10 +static inline int
    2.11 +guest_supports_superpages(struct vcpu *v)
    2.12 +{
    2.13 +    /* The _PAGE_PSE bit must be honoured in HVM guests, whenever
    2.14 +     * CR4.PSE is set or the guest is in PAE or long mode */
    2.15 +    return (hvm_guest(v) && (GUEST_PAGING_LEVELS != 2 
    2.16 +                             || (hvm_get_guest_ctrl_reg(v, 4) & X86_CR4_PSE)));
    2.17 +}
    2.18 +
    2.19 +static inline int
    2.20 +guest_supports_nx(struct vcpu *v)
    2.21 +{
    2.22 +    if ( !hvm_guest(v) )
    2.23 +        return cpu_has_nx;
    2.24 +
    2.25 +    // XXX - fix this!
    2.26 +    return 1;
    2.27 +}
    2.28 +
    2.29  
    2.30  /**************************************************************************/
    2.31  /* Functions for walking the guest page tables */
    2.32 @@ -482,9 +504,11 @@ static u32 guest_set_ad_bits(struct vcpu
    2.33      if ( unlikely(GUEST_PAGING_LEVELS == 3 && level == 3) )
    2.34          return flags;
    2.35  
    2.36 -    /* Need the D bit as well for writes, in l1es and PSE l2es. */
    2.37 +    /* Need the D bit as well for writes, in l1es and 32bit/PAE PSE l2es. */
    2.38      if ( ft == ft_demand_write  
    2.39 -         && (level == 1 || (level == 2 && (flags & _PAGE_PSE))) )
    2.40 +         && (level == 1 || 
    2.41 +             (level == 2 && GUEST_PAGING_LEVELS < 4 
    2.42 +              && (flags & _PAGE_PSE) && guest_supports_superpages(v))) )
    2.43      {
    2.44          if ( (flags & (_PAGE_DIRTY | _PAGE_ACCESSED)) 
    2.45               == (_PAGE_DIRTY | _PAGE_ACCESSED) )
    2.46 @@ -709,7 +733,6 @@ sh2_propagate_flags(struct vcpu *v, mfn_
    2.47      struct domain *d = v->domain;
    2.48      u32 pass_thru_flags;
    2.49      u32 sflags;
    2.50 -    int lowest_level_guest_mapping;
    2.51  
    2.52      // XXX -- might want to think about PAT support for HVM guests...
    2.53  
    2.54 @@ -782,10 +805,6 @@ sh2_propagate_flags(struct vcpu *v, mfn_
    2.55      if ( (level > 1) && !((SHADOW_PAGING_LEVELS == 3) && (level == 3)) )
    2.56          sflags |= _PAGE_ACCESSED | _PAGE_DIRTY;
    2.57  
    2.58 -    lowest_level_guest_mapping =
    2.59 -        ((level == 1) ||
    2.60 -         ((level == 2) && guest_supports_superpages(v) &&
    2.61 -          (gflags & _PAGE_PSE)));
    2.62  
    2.63      // Set the A and D bits in the guest entry, if we need to.
    2.64      if ( guest_entry_ptr && (ft & FETCH_TYPE_DEMAND) )
    2.65 @@ -798,8 +817,12 @@ sh2_propagate_flags(struct vcpu *v, mfn_
    2.66                    !(gflags & _PAGE_ACCESSED)) )
    2.67          sflags &= ~_PAGE_PRESENT;
    2.68  
    2.69 -    if ( unlikely(lowest_level_guest_mapping &&
    2.70 -                  !(gflags & _PAGE_DIRTY)) )
    2.71 +    /* D bits exist in l1es, and 32bit/PAE PSE l2es, but not 64bit PSE l2es */
    2.72 +    if ( unlikely( ((level == 1) 
    2.73 +                    || ((level == 2) && (GUEST_PAGING_LEVELS < 4) 
    2.74 +                        && guest_supports_superpages(v) &&
    2.75 +                        (gflags & _PAGE_PSE)))
    2.76 +                   && !(gflags & _PAGE_DIRTY)) )
    2.77          sflags &= ~_PAGE_RW;
    2.78  
    2.79      // MMIO caching
     3.1 --- a/xen/include/asm-x86/shadow2-private.h	Thu Aug 17 12:08:26 2006 +0100
     3.2 +++ b/xen/include/asm-x86/shadow2-private.h	Thu Aug 17 16:05:51 2006 +0100
     3.3 @@ -533,25 +533,6 @@ static inline void sh2_unpin(struct vcpu
     3.4  }
     3.5  
     3.6  /**************************************************************************/
     3.7 -/* CPU feature support querying */
     3.8 -
     3.9 -static inline int
    3.10 -guest_supports_superpages(struct vcpu *v)
    3.11 -{
    3.12 -    return hvm_guest(v) && (hvm_get_guest_ctrl_reg(v, 4) & X86_CR4_PSE);
    3.13 -}
    3.14 -
    3.15 -static inline int
    3.16 -guest_supports_nx(struct vcpu *v)
    3.17 -{
    3.18 -    if ( !hvm_guest(v) )
    3.19 -        return cpu_has_nx;
    3.20 -
    3.21 -    // XXX - fix this!
    3.22 -    return 1;
    3.23 -}
    3.24 -
    3.25 -/**************************************************************************/
    3.26  /* Guest physmap (p2m) support */
    3.27  
    3.28  /* Read our own P2M table, checking in the linear pagetables first to be