ia64/xen-unstable

changeset 14962:c8e01cc58cb1

[XEN] Replace IS_COMPAT() in the shadow code with pv_32on64_*()
which test for the actual case we're interested in (PV PAE
pagetables disguised as 64bit ones by the compat mm code).
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Fri Apr 27 10:24:09 2007 +0100 (2007-04-27)
parents f18e1ca69380
children 80c458bb1b6d 7f5a804d8a68
files xen/arch/x86/mm/shadow/common.c xen/arch/x86/mm/shadow/multi.c
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/common.c	Thu Apr 26 18:33:34 2007 +0100
     1.2 +++ b/xen/arch/x86/mm/shadow/common.c	Fri Apr 27 10:24:09 2007 +0100
     1.3 @@ -1577,9 +1577,7 @@ void sh_destroy_shadow(struct vcpu *v, m
     1.4             t == SH_type_fl1_pae_shadow ||  
     1.5             t == SH_type_fl1_64_shadow  || 
     1.6             t == SH_type_monitor_table  || 
     1.7 -#ifdef CONFIG_COMPAT
     1.8 -           (IS_COMPAT(v->domain) && t == SH_type_l4_64_shadow) ||
     1.9 -#endif
    1.10 +           (pv_32on64_vcpu(v) && t == SH_type_l4_64_shadow) ||
    1.11             (page_get_owner(mfn_to_page(_mfn(sp->backpointer))) 
    1.12              == v->domain)); 
    1.13  
    1.14 @@ -1622,7 +1620,7 @@ void sh_destroy_shadow(struct vcpu *v, m
    1.15          SHADOW_INTERNAL_NAME(sh_destroy_l1_shadow, 4, 4)(v, smfn);
    1.16          break;
    1.17      case SH_type_l2h_64_shadow:
    1.18 -        ASSERT( IS_COMPAT(v->domain) );
    1.19 +        ASSERT(pv_32on64_vcpu(v));
    1.20          /* Fall through... */
    1.21      case SH_type_l2_64_shadow:
    1.22          SHADOW_INTERNAL_NAME(sh_destroy_l2_shadow, 4, 4)(v, smfn);
    1.23 @@ -2716,7 +2714,10 @@ static int shadow_log_dirty_enable(struc
    1.24      }
    1.25  
    1.26  #if (SHADOW_OPTIMIZATIONS & SHOPT_LINUX_L3_TOPLEVEL)
    1.27 -    if ( IS_COMPAT(d) )
    1.28 +    /* 32bit PV guests on 64bit xen behave like older 64bit linux: they
    1.29 +     * change an l4e instead of cr3 to switch tables.  Give them the
    1.30 +     * same optimization */
    1.31 +    if ( pv_32on64_domain(d) )
    1.32          d->arch.paging.shadow.opt_flags = SHOPT_LINUX_L3_TOPLEVEL;
    1.33  #endif
    1.34  
     2.1 --- a/xen/arch/x86/mm/shadow/multi.c	Thu Apr 26 18:33:34 2007 +0100
     2.2 +++ b/xen/arch/x86/mm/shadow/multi.c	Fri Apr 27 10:24:09 2007 +0100
     2.3 @@ -134,9 +134,8 @@ set_shadow_status(struct vcpu *v, mfn_t 
     2.4                     d->domain_id, v->vcpu_id, mfn_x(gmfn),
     2.5                     shadow_type, mfn_x(smfn));
     2.6  
     2.7 -#ifdef CONFIG_COMPAT
     2.8 -    if ( !IS_COMPAT(d) || shadow_type != SH_type_l4_64_shadow )
     2.9 -#endif
    2.10 +    /* 32-on-64 PV guests don't own their l4 pages so can't get_page them */
    2.11 +    if ( !pv_32on64_vcpu(v) || shadow_type != SH_type_l4_64_shadow )
    2.12      {
    2.13          res = get_page(mfn_to_page(gmfn), d);
    2.14          ASSERT(res == 1);
    2.15 @@ -162,9 +161,8 @@ delete_shadow_status(struct vcpu *v, mfn
    2.16                     v->domain->domain_id, v->vcpu_id,
    2.17                     mfn_x(gmfn), shadow_type, mfn_x(smfn));
    2.18      shadow_hash_delete(v, mfn_x(gmfn), shadow_type, smfn);
    2.19 -#ifdef CONFIG_COMPAT
    2.20 -    if ( !IS_COMPAT(v->domain) || shadow_type != SH_type_l4_64_shadow )
    2.21 -#endif
    2.22 +    /* 32-on-64 PV guests don't own their l4 pages; see set_shadow_status */
    2.23 +    if ( !pv_32on64_vcpu(v) || shadow_type != SH_type_l4_64_shadow )
    2.24          put_page(mfn_to_page(gmfn));
    2.25  }
    2.26  
    2.27 @@ -746,7 +744,8 @@ static always_inline void
    2.28      // PV guests in 64-bit mode use two different page tables for user vs
    2.29      // supervisor permissions, making the guest's _PAGE_USER bit irrelevant.
    2.30      // It is always shadowed as present...
    2.31 -    if ( (GUEST_PAGING_LEVELS == 4) && !IS_COMPAT(d) && !is_hvm_domain(d) )
    2.32 +    if ( (GUEST_PAGING_LEVELS == 4) && !pv_32on64_domain(d) 
    2.33 +         && !is_hvm_domain(d) )
    2.34      {
    2.35          sflags |= _PAGE_USER;
    2.36      }
    2.37 @@ -1300,7 +1299,7 @@ do {                                    
    2.38      for ( _i = 0; _i < SHADOW_L2_PAGETABLE_ENTRIES; _i++ )                  \
    2.39      {                                                                       \
    2.40          if ( (!(_xen))                                                      \
    2.41 -             || !IS_COMPAT(_dom)                                            \
    2.42 +             || !pv_32on64_domain(_dom)                                     \
    2.43               || mfn_to_shadow_page(_sl2mfn)->type != SH_type_l2h_64_shadow  \
    2.44               || (_i < COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(_dom)) )           \
    2.45          {                                                                   \
    2.46 @@ -1411,7 +1410,7 @@ void sh_install_xen_entries_in_l4(struct
    2.47                                  __PAGE_HYPERVISOR);
    2.48      }
    2.49  
    2.50 -    if ( IS_COMPAT(v->domain) )
    2.51 +    if ( pv_32on64_domain(v->domain) )
    2.52      {
    2.53          /* install compat arg xlat entry */
    2.54          sl4e[shadow_l4_table_offset(COMPAT_ARG_XLAT_VIRT_BASE)] =
    2.55 @@ -1437,7 +1436,7 @@ static void sh_install_xen_entries_in_l2
    2.56      int i;
    2.57  #else
    2.58  
    2.59 -    if ( !pv_32bit_vcpu(v) )
    2.60 +    if ( !pv_32on64_vcpu(v) )
    2.61          return;
    2.62  #endif
    2.63  
    2.64 @@ -1622,9 +1621,6 @@ sh_make_shadow(struct vcpu *v, mfn_t gmf
    2.65  #endif
    2.66  #if CONFIG_PAGING_LEVELS >= 3 && GUEST_PAGING_LEVELS >= 3
    2.67          case SH_type_l2h_shadow:
    2.68 -#ifdef CONFIG_COMPAT
    2.69 -            ASSERT( IS_COMPAT(v->domain) );
    2.70 -#endif
    2.71              sh_install_xen_entries_in_l2h(v, smfn); break;
    2.72  #endif
    2.73  #if CONFIG_PAGING_LEVELS == 2 && GUEST_PAGING_LEVELS == 2
    2.74 @@ -1685,7 +1681,7 @@ sh_make_monitor_table(struct vcpu *v)
    2.75              l4e = sh_map_domain_page(m4mfn);
    2.76              l4e[0] = l4e_from_pfn(mfn_x(m3mfn), __PAGE_HYPERVISOR);
    2.77              sh_unmap_domain_page(l4e);
    2.78 -            if ( pv_32bit_vcpu(v) )
    2.79 +            if ( pv_32on64_vcpu(v) )
    2.80              {
    2.81                  // Install a monitor l2 table in slot 3 of the l3 table.
    2.82                  // This is used for all Xen entries.
    2.83 @@ -1840,13 +1836,12 @@ static shadow_l2e_t * shadow_get_and_cre
    2.84          shadow_l3e_t new_sl3e;
    2.85          unsigned int t = SH_type_l2_shadow;
    2.86  
    2.87 -#ifdef CONFIG_COMPAT
    2.88          /* Tag compat L2 containing hypervisor (m2p) mappings */
    2.89 -        if ( IS_COMPAT(v->domain) &&
    2.90 +        if ( pv_32on64_domain(v->domain) &&
    2.91               guest_l4_table_offset(gw->va) == 0 &&
    2.92               guest_l3_table_offset(gw->va) == 3 )
    2.93              t = SH_type_l2h_shadow;
    2.94 -#endif
    2.95 +
    2.96          /* No l2 shadow installed: find and install it. */
    2.97          *sl2mfn = get_shadow_status(v, gw->l2mfn, t);
    2.98          if ( !mfn_valid(*sl2mfn) ) 
    2.99 @@ -2111,7 +2106,7 @@ void sh_destroy_monitor_table(struct vcp
   2.100          l4_pgentry_t *l4e = sh_map_domain_page(mmfn);
   2.101          ASSERT(l4e_get_flags(l4e[0]) & _PAGE_PRESENT);
   2.102          m3mfn = _mfn(l4e_get_pfn(l4e[0]));
   2.103 -        if ( pv_32bit_vcpu(v) )
   2.104 +        if ( pv_32on64_vcpu(v) )
   2.105          {
   2.106              /* Need to destroy the l2 monitor page in slot 3 too */
   2.107              l3_pgentry_t *l3e = sh_map_domain_page(m3mfn);
   2.108 @@ -3474,7 +3469,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
   2.109                     (unsigned long)pagetable_get_pfn(v->arch.guest_table));
   2.110  
   2.111  #if GUEST_PAGING_LEVELS == 4
   2.112 -    if ( !(v->arch.flags & TF_kernel_mode) && !IS_COMPAT(v->domain) )
   2.113 +    if ( !(v->arch.flags & TF_kernel_mode) && !pv_32on64_vcpu(v) )
   2.114          gmfn = pagetable_get_mfn(v->arch.guest_table_user);
   2.115      else
   2.116  #endif
   2.117 @@ -4285,7 +4280,7 @@ int sh_audit_l3_table(struct vcpu *v, mf
   2.118              mfn = shadow_l3e_get_mfn(*sl3e);
   2.119              gmfn = get_shadow_status(v, audit_gfn_to_mfn(v, gfn, gl3mfn), 
   2.120                                       ((GUEST_PAGING_LEVELS == 3 ||
   2.121 -                                       IS_COMPAT(v->domain))
   2.122 +                                       pv_32on64_vcpu(v))
   2.123                                        && !shadow_mode_external(v->domain)
   2.124                                        && (guest_index(gl3e) % 4) == 3)
   2.125                                       ? SH_type_l2h_shadow