debuggers.hg

changeset 21139:4a3e131f7498

x86: use paging_mode_hap() consistently

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 06 06:51:04 2010 +0100 (2010-04-06)
parents 537451477469
children cd6c6c685015
files xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/mm/hap/hap.c xen/arch/x86/mm/mem_sharing.c xen/arch/x86/mm/p2m.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Thu Apr 01 09:55:27 2010 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Tue Apr 06 06:51:04 2010 +0100
     1.3 @@ -92,7 +92,7 @@ static int vmx_domain_initialise(struct 
     1.4  
     1.5  static void vmx_domain_destroy(struct domain *d)
     1.6  {
     1.7 -    if ( d->arch.hvm_domain.hap_enabled )
     1.8 +    if ( paging_mode_hap(d) )
     1.9          on_each_cpu(__ept_sync_domain, d, 1);
    1.10      vmx_free_vlapic_mapping(d);
    1.11  }
    1.12 @@ -678,7 +678,7 @@ static void vmx_ctxt_switch_to(struct vc
    1.13      if ( old_cr4 != new_cr4 )
    1.14          write_cr4(new_cr4);
    1.15  
    1.16 -    if ( d->arch.hvm_domain.hap_enabled )
    1.17 +    if ( paging_mode_hap(d) )
    1.18      {
    1.19          unsigned int cpu = smp_processor_id();
    1.20          /* Test-and-test-and-set this CPU in the EPT-is-synced mask. */
    1.21 @@ -1222,7 +1222,7 @@ static void __ept_sync_domain(void *info
    1.22  void ept_sync_domain(struct domain *d)
    1.23  {
    1.24      /* Only if using EPT and this domain has some VCPUs to dirty. */
    1.25 -    if ( !d->arch.hvm_domain.hap_enabled || !d->vcpu || !d->vcpu[0] )
    1.26 +    if ( !paging_mode_hap(d) || !d->vcpu || !d->vcpu[0] )
    1.27          return;
    1.28  
    1.29      ASSERT(local_irq_is_enabled());
     2.1 --- a/xen/arch/x86/mm/hap/hap.c	Thu Apr 01 09:55:27 2010 +0100
     2.2 +++ b/xen/arch/x86/mm/hap/hap.c	Tue Apr 06 06:51:04 2010 +0100
     2.3 @@ -550,8 +550,13 @@ int hap_enable(struct domain *d, u32 mod
     2.4  {
     2.5      unsigned int old_pages;
     2.6      int rv = 0;
     2.7 +    uint32_t oldmode;
     2.8  
     2.9      domain_pause(d);
    2.10 +
    2.11 +    oldmode = d->arch.paging.mode;
    2.12 +    d->arch.paging.mode = mode | PG_HAP_enable;
    2.13 +
    2.14      /* error check */
    2.15      if ( (d == current->domain) )
    2.16      {
    2.17 @@ -582,9 +587,9 @@ int hap_enable(struct domain *d, u32 mod
    2.18              goto out;
    2.19      }
    2.20  
    2.21 -    d->arch.paging.mode = mode | PG_HAP_enable;
    2.22 -
    2.23   out:
    2.24 +    if (rv)
    2.25 +        d->arch.paging.mode = oldmode;
    2.26      domain_unpause(d);
    2.27      return rv;
    2.28  }
     3.1 --- a/xen/arch/x86/mm/mem_sharing.c	Thu Apr 01 09:55:27 2010 +0100
     3.2 +++ b/xen/arch/x86/mm/mem_sharing.c	Tue Apr 06 06:51:04 2010 +0100
     3.3 @@ -44,7 +44,7 @@ static void mem_sharing_audit(void);
     3.4  
     3.5  
     3.6  #define hap_enabled(d) \
     3.7 -    (is_hvm_domain(d) && (d)->arch.hvm_domain.hap_enabled)
     3.8 +    (is_hvm_domain(d) && paging_mode_hap(d))
     3.9  #define mem_sharing_enabled(d) \
    3.10      (is_hvm_domain(d) && (d)->arch.hvm_domain.mem_sharing_enabled)
    3.11   
     4.1 --- a/xen/arch/x86/mm/p2m.c	Thu Apr 01 09:55:27 2010 +0100
     4.2 +++ b/xen/arch/x86/mm/p2m.c	Tue Apr 06 06:51:04 2010 +0100
     4.3 @@ -1231,7 +1231,7 @@ p2m_set_entry(struct domain *d, unsigned
     4.4      if ( !p2m_next_level(d, &table_mfn, &table, &gfn_remainder, gfn,
     4.5                           L3_PAGETABLE_SHIFT - PAGE_SHIFT,
     4.6                           ((CONFIG_PAGING_LEVELS == 3)
     4.7 -                          ? (d->arch.hvm_domain.hap_enabled ? 4 : 8)
     4.8 +                          ? (paging_mode_hap(d) ? 4 : 8)
     4.9                            : L3_PAGETABLE_ENTRIES),
    4.10                           PGT_l2_page_table) )
    4.11          goto out;
    4.12 @@ -1568,7 +1568,7 @@ int p2m_init(struct domain *d)
    4.13      p2m->get_entry_current = p2m_gfn_to_mfn_current;
    4.14      p2m->change_entry_type_global = p2m_change_type_global;
    4.15  
    4.16 -    if ( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled &&
    4.17 +    if ( is_hvm_domain(d) && paging_mode_hap(d) &&
    4.18           (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) )
    4.19          ept_p2m_init(d);
    4.20  
    4.21 @@ -1595,7 +1595,7 @@ int set_p2m_entry(struct domain *d, unsi
    4.22  
    4.23      while ( todo )
    4.24      {
    4.25 -        if ( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled )
    4.26 +        if ( is_hvm_domain(d) && paging_mode_hap(d) )
    4.27              order = (((gfn | mfn_x(mfn) | todo) & (SUPERPAGE_PAGES - 1)) == 0) ?
    4.28                  9 : 0;
    4.29          else