ia64/xen-unstable

changeset 8950:1fd6e9c32b03

Fix cleanup path if an HVM guest fails very early, before direct map is built.

Signed-off-by: Xin Li <xin.b.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Feb 21 18:21:13 2006 +0100 (2006-02-21)
parents e8d044119316
children f33e537c4ac5
files xen/arch/x86/shadow32.c xen/arch/x86/shadow_public.c
line diff
     1.1 --- a/xen/arch/x86/shadow32.c	Tue Feb 21 18:19:16 2006 +0100
     1.2 +++ b/xen/arch/x86/shadow32.c	Tue Feb 21 18:21:13 2006 +0100
     1.3 @@ -1110,22 +1110,30 @@ fail:
     1.4  void shadow_direct_map_clean(struct vcpu *v)
     1.5  {
     1.6      int i;
     1.7 +    unsigned long mfn;
     1.8 +    struct domain *d = v->domain;
     1.9      l2_pgentry_t *l2e;
    1.10  
    1.11 -    l2e = map_domain_page(
    1.12 -      pagetable_get_pfn(v->domain->arch.phys_table));
    1.13 +    mfn =  pagetable_get_pfn(d->arch.phys_table);
    1.14 +
    1.15 +    /*
    1.16 +     * We may fail very early before direct map is built.
    1.17 +     */
    1.18 +    if ( !mfn )
    1.19 +        return;
    1.20 +
    1.21 +    l2e = map_domain_page(mfn);
    1.22  
    1.23      for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ )
    1.24      {
    1.25          if ( l2e_get_flags(l2e[i]) & _PAGE_PRESENT )
    1.26              free_domheap_page(mfn_to_page(l2e_get_pfn(l2e[i])));
    1.27      }
    1.28 -
    1.29 -    free_domheap_page(
    1.30 -            mfn_to_page(pagetable_get_pfn(v->domain->arch.phys_table)));
    1.31 +    free_domheap_page(mfn_to_page(mfn));
    1.32  
    1.33      unmap_domain_page(l2e);
    1.34 -    v->domain->arch.phys_table = mk_pagetable(0);
    1.35 +
    1.36 +    d->arch.phys_table = mk_pagetable(0);
    1.37  }
    1.38  
    1.39  int __shadow_mode_enable(struct domain *d, unsigned int mode)
     2.1 --- a/xen/arch/x86/shadow_public.c	Tue Feb 21 18:19:16 2006 +0100
     2.2 +++ b/xen/arch/x86/shadow_public.c	Tue Feb 21 18:21:13 2006 +0100
     2.3 @@ -59,12 +59,21 @@ fail:
     2.4  
     2.5  void shadow_direct_map_clean(struct vcpu *v)
     2.6  {
     2.7 +    unsigned long mfn;
     2.8 +    struct domain *d = v->domain;
     2.9      l2_pgentry_t *l2e;
    2.10      l3_pgentry_t *l3e;
    2.11      int i, j;
    2.12  
    2.13 -    l3e = (l3_pgentry_t *)map_domain_page(
    2.14 -        pagetable_get_pfn(v->domain->arch.phys_table));
    2.15 +    mfn = pagetable_get_pfn(d->arch.phys_table);
    2.16 +
    2.17 +    /*
    2.18 +     * We may fail very early before direct map is built.
    2.19 +     */
    2.20 +    if ( !mfn )
    2.21 +        return;
    2.22 +
    2.23 +    l3e = (l3_pgentry_t *)map_domain_page(mfn);
    2.24  
    2.25      for ( i = 0; i < PAE_L3_PAGETABLE_ENTRIES; i++ )
    2.26      {
    2.27 @@ -81,12 +90,11 @@ void shadow_direct_map_clean(struct vcpu
    2.28              free_domheap_page(mfn_to_page(l3e_get_pfn(l3e[i])));
    2.29          }
    2.30      }
    2.31 -
    2.32 -    free_domheap_page(
    2.33 -        mfn_to_page(pagetable_get_pfn(v->domain->arch.phys_table)));
    2.34 +    free_domheap_page(mfn_to_page(mfn));
    2.35  
    2.36      unmap_domain_page(l3e);
    2.37 -    v->domain->arch.phys_table = mk_pagetable(0);
    2.38 +
    2.39 +    d->arch.phys_table = mk_pagetable(0);
    2.40  }
    2.41  
    2.42  /****************************************************************************/