ia64/xen-unstable

changeset 8854:de0408f095f8

Fix building the p2m table for shadow translate mode guests.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed Feb 15 09:43:14 2006 +0000 (2006-02-15)
parents 166322cd55df
children 75af08f657be
files xen/arch/x86/shadow32.c
line diff
     1.1 --- a/xen/arch/x86/shadow32.c	Wed Feb 15 00:37:15 2006 +0100
     1.2 +++ b/xen/arch/x86/shadow32.c	Wed Feb 15 09:43:14 2006 +0000
     1.3 @@ -842,7 +842,7 @@ set_p2m_entry(struct domain *d, unsigned
     1.4      unmap_domain_page_with_cache(l2, l2cache);
     1.5  
     1.6      l1 = map_domain_page_with_cache(l2e_get_pfn(l2e), l1cache);
     1.7 -    l1[l1_table_offset(va)] = l1e_from_pfn(mfn, __PAGE_HYPERVISOR);
     1.8 +    l1[l1_table_offset(va)] = (l1_pgentry_t) { mfn };
     1.9      unmap_domain_page_with_cache(l1, l1cache);
    1.10  
    1.11      return 1;
    1.12 @@ -860,42 +860,48 @@ alloc_p2m_table(struct domain *d)
    1.13      l2_pgentry_t l2e = { 0 };
    1.14      l1_pgentry_t l1e = { 0 };
    1.15  
    1.16 +    struct page_info *page;
    1.17      unsigned long pfn;
    1.18      int i;
    1.19  
    1.20 -    ASSERT ( pagetable_get_pfn(d->vcpu[0]->arch.monitor_table));
    1.21 -
    1.22 -    l2tab = map_domain_page(
    1.23 -        pagetable_get_pfn(d->vcpu[0]->arch.monitor_table));
    1.24 +    if ( pagetable_get_pfn(d->vcpu[0]->arch.monitor_table) )
    1.25 +    {
    1.26 +        l2tab = map_domain_page(
    1.27 +            pagetable_get_pfn(d->vcpu[0]->arch.monitor_table));
    1.28 +        l2e = l2tab[l2_table_offset(va)];
    1.29 +        if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) )
    1.30 +        {
    1.31 +            page = alloc_domheap_page(NULL);
    1.32 +
    1.33 +            l1tab = map_domain_page(page_to_mfn(page));
    1.34 +            memset(l1tab, 0, PAGE_SIZE);
    1.35 +            l2e = l2tab[l2_table_offset(va)] =
    1.36 +                l2e_from_page(page, __PAGE_HYPERVISOR);
    1.37 +        }
    1.38 +        else
    1.39 +            l1tab = map_domain_page(l2e_get_pfn(l2e));
    1.40 +    }
    1.41 +    else
    1.42 +    {
    1.43 +        page = alloc_domheap_page(NULL);
    1.44 +
    1.45 +        l1tab = map_domain_page(page_to_mfn(page));
    1.46 +        memset(l1tab, 0, PAGE_SIZE);
    1.47 +        d->arch.phys_table = mk_pagetable(page_to_maddr(page));
    1.48 +    }
    1.49  
    1.50      list_ent = d->page_list.next;
    1.51  
    1.52      for ( i = 0; list_ent != &d->page_list; i++ )
    1.53      {
    1.54 -        struct page_info *page;
    1.55          page = list_entry(list_ent, struct page_info, list);
    1.56          pfn = page_to_mfn(page);
    1.57  
    1.58 -        l2e = l2tab[l2_table_offset(va)];
    1.59 -        if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) )
    1.60 -        {
    1.61 -            page = alloc_domheap_page(NULL);
    1.62 -
    1.63 -            if ( !l1tab )
    1.64 -                unmap_domain_page(l1tab);
    1.65 -            l1tab = map_domain_page(page_to_mfn(page));
    1.66 -            memset(l1tab, 0, PAGE_SIZE);
    1.67 -            l2e = l2tab[l2_table_offset(va)] =
    1.68 -                l2e_from_page(page, __PAGE_HYPERVISOR);
    1.69 -        }
    1.70 -        else if ( l1tab == NULL)
    1.71 -            l1tab = map_domain_page(l2e_get_pfn(l2e));
    1.72 -
    1.73          l1e = l1tab[l1_table_offset(va)];
    1.74          if ( !(l1e_get_flags(l1e) & _PAGE_PRESENT) )
    1.75          {
    1.76              page = alloc_domheap_page(NULL);
    1.77 -            if ( !l0tab  )
    1.78 +            if ( l0tab  )
    1.79                  unmap_domain_page(l0tab);
    1.80              l0tab = map_domain_page(page_to_mfn(page));
    1.81              memset(l0tab, 0, PAGE_SIZE );
    1.82 @@ -910,7 +916,8 @@ alloc_p2m_table(struct domain *d)
    1.83          va += sizeof(pfn);
    1.84      }
    1.85  
    1.86 -    unmap_domain_page(l2tab);
    1.87 +    if (l2tab)
    1.88 +        unmap_domain_page(l2tab);
    1.89      unmap_domain_page(l1tab);
    1.90      unmap_domain_page(l0tab);
    1.91  
    1.92 @@ -1582,14 +1589,7 @@ get_mfn_from_gpfn_foreign(struct domain 
    1.93             __func__, d->domain_id, gpfn, l1_pgentry_val(l1e) >> PAGE_SHIFT, tabpfn, l2e, l1tab, l1e);
    1.94  #endif
    1.95  
    1.96 -    if ( !(l1e_get_flags(l1e) & _PAGE_PRESENT) )
    1.97 -    {
    1.98 -        printk("%s(d->id=%d, gpfn=%lx) => 0 l1e=%" PRIpte "\n",
    1.99 -               __func__, d->domain_id, gpfn, l1e_get_intpte(l1e));
   1.100 -        return INVALID_MFN;
   1.101 -    }
   1.102 -
   1.103 -    return l1e_get_pfn(l1e);
   1.104 +    return l1e_get_intpte(l1e);
   1.105  }
   1.106  
   1.107  static unsigned long
   1.108 @@ -1704,6 +1704,7 @@ static unsigned long shadow_l2_table(
   1.109          {
   1.110              unsigned long hl2mfn;
   1.111  
   1.112 +            ASSERT(pagetable_get_paddr(d->arch.phys_table));
   1.113              spl2e[l2_table_offset(RO_MPT_VIRT_START)] =
   1.114                  l2e_from_paddr(pagetable_get_paddr(d->arch.phys_table),
   1.115                                  __PAGE_HYPERVISOR);