ia64/xen-unstable

changeset 14961:f18e1ca69380

hvm: Take care when checking ->is_compat flag now that HVM as well as
PV guests can assert it.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Apr 26 18:33:34 2007 +0100 (2007-04-26)
parents 39383ac1aec8
children c8e01cc58cb1
files xen/arch/x86/domain.c xen/arch/x86/mm/shadow/multi.c xen/include/asm-x86/domain.h xen/include/asm-x86/shadow.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Thu Apr 26 17:30:56 2007 +0100
     1.2 +++ b/xen/arch/x86/domain.c	Thu Apr 26 18:33:34 2007 +0100
     1.3 @@ -237,7 +237,8 @@ static int setup_compat_l4(struct vcpu *
     1.4      l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] =
     1.5          l4e_from_page(pg, __PAGE_HYPERVISOR);
     1.6      l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] =
     1.7 -        l4e_from_paddr(__pa(v->domain->arch.mm_perdomain_l3), __PAGE_HYPERVISOR);
     1.8 +        l4e_from_paddr(__pa(v->domain->arch.mm_perdomain_l3),
     1.9 +                       __PAGE_HYPERVISOR);
    1.10      v->arch.guest_table = pagetable_from_page(pg);
    1.11      v->arch.guest_table_user = v->arch.guest_table;
    1.12  
    1.13 @@ -259,7 +260,7 @@ static void release_compat_l4(struct vcp
    1.14  
    1.15  static inline int may_switch_mode(struct domain *d)
    1.16  {
    1.17 -    return (d->tot_pages == 0);
    1.18 +    return (!is_hvm_domain(d) && (d->tot_pages == 0));
    1.19  }
    1.20  
    1.21  int switch_native(struct domain *d)
    1.22 @@ -371,15 +372,12 @@ int vcpu_initialise(struct vcpu *v)
    1.23      v->arch.perdomain_ptes =
    1.24          d->arch.mm_perdomain_pt + (v->vcpu_id << GDT_LDT_VCPU_SHIFT);
    1.25  
    1.26 -    if ( IS_COMPAT(d) && (rc = setup_compat_l4(v)) != 0 )
    1.27 -        return rc;
    1.28 -
    1.29 -    return 0;
    1.30 +    return (pv_32on64_vcpu(v) ? setup_compat_l4(v) : 0);
    1.31  }
    1.32  
    1.33  void vcpu_destroy(struct vcpu *v)
    1.34  {
    1.35 -    if ( IS_COMPAT(v->domain) )
    1.36 +    if ( pv_32on64_vcpu(v) )
    1.37          release_compat_l4(v);
    1.38  }
    1.39  
    1.40 @@ -491,7 +489,7 @@ void arch_domain_destroy(struct domain *
    1.41      free_domheap_page(virt_to_page(d->arch.mm_perdomain_l3));
    1.42  #endif
    1.43  
    1.44 -    if ( IS_COMPAT(d) )
    1.45 +    if ( pv_32on64_domain(d) )
    1.46          release_arg_xlat_area(d);
    1.47  
    1.48      free_xenheap_page(d->shared_info);
    1.49 @@ -508,7 +506,7 @@ int arch_set_info_guest(
    1.50  
    1.51      /* The context is a compat-mode one if the target domain is compat-mode;
    1.52       * we expect the tools to DTRT even in compat-mode callers. */
    1.53 -    compat = IS_COMPAT(d);
    1.54 +    compat = pv_32on64_domain(d);
    1.55  
    1.56  #ifdef CONFIG_COMPAT
    1.57  #define c(fld) (compat ? (c.cmp->fld) : (c.nat->fld))
    1.58 @@ -1268,7 +1266,7 @@ unsigned long hypercall_create_continuat
    1.59          else
    1.60  #endif
    1.61          {
    1.62 -            if ( supervisor_mode_kernel || is_hvm_vcpu(current) )
    1.63 +            if ( supervisor_mode_kernel )
    1.64                  regs->eip &= ~31; /* re-execute entire hypercall entry stub */
    1.65  
    1.66              for ( i = 0; *p != '\0'; i++ )
    1.67 @@ -1449,14 +1447,11 @@ static void vcpu_destroy_pagetables(stru
    1.68      struct domain *d = v->domain;
    1.69      unsigned long pfn;
    1.70  
    1.71 -#ifdef CONFIG_COMPAT
    1.72 -    if ( IS_COMPAT(d) )
    1.73 +#ifdef __x86_64__
    1.74 +    if ( pv_32on64_vcpu(v) )
    1.75      {
    1.76 -        if ( is_hvm_vcpu(v) )
    1.77 -            pfn = pagetable_get_pfn(v->arch.guest_table);
    1.78 -        else
    1.79 -            pfn = l4e_get_pfn(*(l4_pgentry_t *)
    1.80 -                              __va(pagetable_get_paddr(v->arch.guest_table)));
    1.81 +        pfn = l4e_get_pfn(*(l4_pgentry_t *)
    1.82 +                          __va(pagetable_get_paddr(v->arch.guest_table)));
    1.83  
    1.84          if ( pfn != 0 )
    1.85          {
    1.86 @@ -1466,12 +1461,9 @@ static void vcpu_destroy_pagetables(stru
    1.87                  put_page_and_type(mfn_to_page(pfn));
    1.88          }
    1.89  
    1.90 -        if ( is_hvm_vcpu(v) )
    1.91 -            v->arch.guest_table = pagetable_null();
    1.92 -        else
    1.93 -            l4e_write(
    1.94 -                (l4_pgentry_t *) __va(pagetable_get_paddr(v->arch.guest_table)),
    1.95 -                l4e_empty());
    1.96 +        l4e_write(
    1.97 +            (l4_pgentry_t *)__va(pagetable_get_paddr(v->arch.guest_table)),
    1.98 +            l4e_empty());
    1.99  
   1.100          v->arch.cr3 = 0;
   1.101          return;
     2.1 --- a/xen/arch/x86/mm/shadow/multi.c	Thu Apr 26 17:30:56 2007 +0100
     2.2 +++ b/xen/arch/x86/mm/shadow/multi.c	Thu Apr 26 18:33:34 2007 +0100
     2.3 @@ -1437,7 +1437,7 @@ static void sh_install_xen_entries_in_l2
     2.4      int i;
     2.5  #else
     2.6  
     2.7 -    if ( !pv_32bit_guest(v) )
     2.8 +    if ( !pv_32bit_vcpu(v) )
     2.9          return;
    2.10  #endif
    2.11  
    2.12 @@ -1685,7 +1685,7 @@ sh_make_monitor_table(struct vcpu *v)
    2.13              l4e = sh_map_domain_page(m4mfn);
    2.14              l4e[0] = l4e_from_pfn(mfn_x(m3mfn), __PAGE_HYPERVISOR);
    2.15              sh_unmap_domain_page(l4e);
    2.16 -            if ( pv_32bit_guest(v) )
    2.17 +            if ( pv_32bit_vcpu(v) )
    2.18              {
    2.19                  // Install a monitor l2 table in slot 3 of the l3 table.
    2.20                  // This is used for all Xen entries.
    2.21 @@ -2111,7 +2111,7 @@ void sh_destroy_monitor_table(struct vcp
    2.22          l4_pgentry_t *l4e = sh_map_domain_page(mmfn);
    2.23          ASSERT(l4e_get_flags(l4e[0]) & _PAGE_PRESENT);
    2.24          m3mfn = _mfn(l4e_get_pfn(l4e[0]));
    2.25 -        if ( pv_32bit_guest(v) )
    2.26 +        if ( pv_32bit_vcpu(v) )
    2.27          {
    2.28              /* Need to destroy the l2 monitor page in slot 3 too */
    2.29              l3_pgentry_t *l3e = sh_map_domain_page(m3mfn);
     3.1 --- a/xen/include/asm-x86/domain.h	Thu Apr 26 17:30:56 2007 +0100
     3.2 +++ b/xen/include/asm-x86/domain.h	Thu Apr 26 18:33:34 2007 +0100
     3.3 @@ -7,6 +7,19 @@
     3.4  #include <asm/hvm/domain.h>
     3.5  #include <asm/e820.h>
     3.6  
     3.7 +#ifdef __x86_64__
     3.8 +#define pv_32bit_vcpu(v)    (!is_hvm_vcpu(v) && IS_COMPAT((v)->domain))
     3.9 +#define pv_32bit_domain(d)  (!is_hvm_domain(d) && IS_COMPAT(d))
    3.10 +#define pv_32on64_vcpu(v)   (pv_32bit_vcpu(v))
    3.11 +#define pv_32on64_domain(d) (pv_32bit_domain(d))
    3.12 +#else
    3.13 +#define pv_32bit_vcpu(v)    (!is_hvm_vcpu(v))
    3.14 +#define pv_32bit_domain(d)  (!is_hvm_domain(d))
    3.15 +#define pv_32on64_vcpu(v)   (0)
    3.16 +#define pv_32on64_domain(d) (0)
    3.17 +#endif
    3.18 +
    3.19 +
    3.20  struct trap_bounce {
    3.21      uint32_t      error_code;
    3.22      uint8_t       flags; /* TBF_ */
     4.1 --- a/xen/include/asm-x86/shadow.h	Thu Apr 26 17:30:56 2007 +0100
     4.2 +++ b/xen/include/asm-x86/shadow.h	Thu Apr 26 18:33:34 2007 +0100
     4.3 @@ -48,16 +48,6 @@
     4.4   * not yet supported */
     4.5  #define shadow_mode_trap_reads(_d) ({ (void)(_d); 0; })
     4.6  
     4.7 -/*
     4.8 - * 32on64 support
     4.9 - */
    4.10 -#ifdef __x86_64__
    4.11 -#define pv_32bit_guest(_v) (!is_hvm_vcpu(_v) && IS_COMPAT((_v)->domain))
    4.12 -#else
    4.13 -#define pv_32bit_guest(_v) (!is_hvm_vcpu(_v))
    4.14 -#endif
    4.15 -
    4.16 -
    4.17  /*****************************************************************************
    4.18   * Entry points into the shadow code */
    4.19