ia64/xen-unstable

changeset 3708:9e80fc0dcac5

bitkeeper revision 1.1159.212.121 (42081031Gcfd1G5fgexBl7vd4XfmLQ)

Use 1:1 pagetables used for guest physical mode emulation for doing
phys_to_machine_mapping as well.

Signed-off-by: Arun Sharma <arun.sharma@intel.com>
Signed-off-by: ian@xensource.com
author iap10@labyrinth.cl.cam.ac.uk
date Tue Feb 08 01:04:49 2005 +0000 (2005-02-08)
parents ef5e5cd10778
children e8b4923ca943 045b1c9e9f1b
files xen/arch/x86/domain.c xen/arch/x86/vmx_vmcs.c xen/include/asm-x86/domain.h xen/include/asm-x86/mm.h xen/include/asm-x86/x86_32/uaccess.h xen/include/asm-x86/x86_64/uaccess.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Tue Feb 08 01:03:26 2005 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Tue Feb 08 01:04:49 2005 +0000
     1.3 @@ -304,7 +304,7 @@ void arch_vmx_do_launch(struct exec_doma
     1.4  static void monitor_mk_pagetable(struct exec_domain *ed)
     1.5  {
     1.6      unsigned long mpfn;
     1.7 -    l2_pgentry_t *mpl2e;
     1.8 +    l2_pgentry_t *mpl2e, *phys_table;
     1.9      struct pfn_info *mpfn_info;
    1.10      struct domain *d = ed->domain;
    1.11  
    1.12 @@ -326,6 +326,12 @@ static void monitor_mk_pagetable(struct 
    1.13          mk_l2_pgentry((__pa(d->arch.mm_perdomain_pt) & PAGE_MASK) 
    1.14                        | __PAGE_HYPERVISOR);
    1.15  
    1.16 +    phys_table = (l2_pgentry_t *) map_domain_mem(pagetable_val(
    1.17 +                                        ed->arch.phys_table));
    1.18 +    memcpy(d->arch.mm_perdomain_pt, phys_table,
    1.19 +           ENTRIES_PER_L2_PAGETABLE * sizeof(l2_pgentry_t));
    1.20 +
    1.21 +    unmap_domain_mem(phys_table);
    1.22      unmap_domain_mem(mpl2e);
    1.23  }
    1.24  
    1.25 @@ -466,6 +472,7 @@ int arch_final_setup_guestos(
    1.26      
    1.27      phys_basetab = c->pt_base;
    1.28      d->arch.pagetable = mk_pagetable(phys_basetab);
    1.29 +    d->arch.phys_table = d->arch.pagetable;
    1.30      if ( !get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], d->domain, 
    1.31                              PGT_base_page_table) )
    1.32          return -EINVAL;
    1.33 @@ -749,8 +756,6 @@ static void relinquish_list(struct domai
    1.34  #ifdef CONFIG_VMX
    1.35  static void vmx_domain_relinquish_memory(struct exec_domain *ed)
    1.36  {
    1.37 -    struct domain *d = ed->domain;
    1.38 -
    1.39      /*
    1.40       * Free VMCS
    1.41       */
    1.42 @@ -759,22 +764,6 @@ static void vmx_domain_relinquish_memory
    1.43      ed->arch.arch_vmx.vmcs = 0;
    1.44      
    1.45      monitor_rm_pagetable(ed);
    1.46 -
    1.47 -    if (ed == d->exec_domain[0]) {
    1.48 -        int i;
    1.49 -        unsigned long pfn;
    1.50 -
    1.51 -        for (i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++) {
    1.52 -            unsigned long l1e;
    1.53 -            
    1.54 -            l1e = l1_pgentry_val(d->arch.mm_perdomain_pt[i]);
    1.55 -            if (l1e & _PAGE_PRESENT) {
    1.56 -                pfn = l1e >> PAGE_SHIFT;
    1.57 -                free_domheap_page(&frame_table[pfn]);
    1.58 -            }
    1.59 -        }
    1.60 -    }
    1.61 -
    1.62  }
    1.63  #endif
    1.64  
     2.1 --- a/xen/arch/x86/vmx_vmcs.c	Tue Feb 08 01:03:26 2005 +0000
     2.2 +++ b/xen/arch/x86/vmx_vmcs.c	Tue Feb 08 01:04:49 2005 +0000
     2.3 @@ -131,52 +131,20 @@ int vmx_setup_platform(struct exec_domai
     2.4      }
     2.5  
     2.6      if (gpfn == 0) {
     2.7 -        VMX_DBG_LOG(DBG_LEVEL_1, "No shared Page ?\n");
     2.8 +        printk("No shared Page ?\n");
     2.9 +        unmap_domain_mem(p);        
    2.10          return -1;
    2.11      }   
    2.12      unmap_domain_mem(p);        
    2.13  
    2.14      mpfn = phys_to_machine_mapping(gpfn);
    2.15      p = map_domain_mem(mpfn << PAGE_SHIFT);
    2.16 +    ASSERT(p != NULL);
    2.17      d->arch.arch_vmx.vmx_platform.shared_page_va = (unsigned long) p;
    2.18  
    2.19      return 0;
    2.20  }
    2.21  
    2.22 -
    2.23 -/*
    2.24 - * Add <guest pfn, machine pfn> mapping to per-domain mapping. Full
    2.25 - * virtualization does not need per-domain mapping.
    2.26 - */
    2.27 -static int add_mapping_perdomain(struct exec_domain *d, unsigned long gpfn, 
    2.28 -                                 unsigned long mpfn)
    2.29 -{
    2.30 -    struct pfn_info *page;
    2.31 -    unsigned long pfn = 0;
    2.32 -
    2.33 -    /*
    2.34 -     * We support up to 4GB memory for a guest at this point
    2.35 -     */
    2.36 -    if (gpfn > ENTRIES_PER_L2_PAGETABLE * ENTRIES_PER_L1_PAGETABLE)
    2.37 -        return -1;
    2.38 -
    2.39 -    if (!(l1_pgentry_val(d->domain->arch.mm_perdomain_pt[
    2.40 -            gpfn >> (L2_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT)]) & _PAGE_PRESENT))
    2.41 -    {
    2.42 -        page = (struct pfn_info *) alloc_domheap_page(NULL);
    2.43 -        if (!page) {
    2.44 -            return -1;
    2.45 -        }
    2.46 -
    2.47 -        pfn = (unsigned long) (page - frame_table);
    2.48 -        d->domain->arch.mm_perdomain_pt[gpfn >> (L2_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT)] = 
    2.49 -            mk_l1_pgentry((pfn << PAGE_SHIFT) | __PAGE_HYPERVISOR);
    2.50 -    }
    2.51 -    __phys_to_machine_mapping[gpfn] = mpfn;
    2.52 -
    2.53 -    return 0;
    2.54 -}
    2.55 -
    2.56  void vmx_do_launch(struct exec_domain *ed) 
    2.57  {
    2.58  /* Update CR3, GDT, LDT, TR */
    2.59 @@ -204,7 +172,6 @@ void vmx_do_launch(struct exec_domain *e
    2.60          d->arch.min_pfn = min(d->arch.min_pfn, pfn);
    2.61          d->arch.max_pfn = max(d->arch.max_pfn, pfn);
    2.62          list_ent = frame_table[pfn].list.next;
    2.63 -        add_mapping_perdomain(ed, i, pfn);
    2.64      }
    2.65  
    2.66      spin_unlock(&d->page_alloc_lock);
     3.1 --- a/xen/include/asm-x86/domain.h	Tue Feb 08 01:03:26 2005 +0000
     3.2 +++ b/xen/include/asm-x86/domain.h	Tue Feb 08 01:04:49 2005 +0000
     3.3 @@ -96,6 +96,7 @@ struct arch_exec_domain
     3.4      pagetable_t  pagetable;
     3.5  
     3.6      pagetable_t  monitor_table;
     3.7 +    pagetable_t  phys_table;            /* 1:1 pagetable */
     3.8      pagetable_t  shadow_table;
     3.9      l2_pgentry_t *vpagetable;	        /* virtual address of pagetable */
    3.10      l2_pgentry_t *shadow_vtable;	/* virtual address of shadow_table */
     4.1 --- a/xen/include/asm-x86/mm.h	Tue Feb 08 01:03:26 2005 +0000
     4.2 +++ b/xen/include/asm-x86/mm.h	Tue Feb 08 01:04:49 2005 +0000
     4.3 @@ -13,6 +13,7 @@
     4.4  #include <asm/desc.h>
     4.5  #include <asm/flushtlb.h>
     4.6  #include <asm/io.h>
     4.7 +#include <asm/uaccess.h>
     4.8  
     4.9  #include <public/xen.h>
    4.10  
    4.11 @@ -245,7 +246,15 @@ void synchronise_pagetables(unsigned lon
    4.12  /* Returns the machine physical */
    4.13  static inline unsigned long phys_to_machine_mapping(unsigned long pfn) 
    4.14  {
    4.15 -        return __phys_to_machine_mapping[pfn];
    4.16 +    unsigned long mfn;
    4.17 +    l1_pgentry_t pte;
    4.18 +
    4.19 +   if (__get_user(l1_pgentry_val(pte), (__phys_to_machine_mapping + pfn))) {
    4.20 +       return 0;
    4.21 +   }
    4.22 +               
    4.23 +   mfn = l1_pgentry_to_phys(pte) >> PAGE_SHIFT;
    4.24 +   return mfn; 
    4.25  }
    4.26  #define set_machinetophys(_mfn, _pfn) machine_to_phys_mapping[(_mfn)] = (_pfn)
    4.27  
     5.1 --- a/xen/include/asm-x86/x86_32/uaccess.h	Tue Feb 08 01:03:26 2005 +0000
     5.2 +++ b/xen/include/asm-x86/x86_32/uaccess.h	Tue Feb 08 01:04:49 2005 +0000
     5.3 @@ -8,7 +8,6 @@
     5.4  #include <xen/errno.h>
     5.5  #include <xen/prefetch.h>
     5.6  #include <xen/string.h>
     5.7 -#include <xen/sched.h>
     5.8  
     5.9  #define __user
    5.10  
     6.1 --- a/xen/include/asm-x86/x86_64/uaccess.h	Tue Feb 08 01:03:26 2005 +0000
     6.2 +++ b/xen/include/asm-x86/x86_64/uaccess.h	Tue Feb 08 01:04:49 2005 +0000
     6.3 @@ -7,7 +7,6 @@
     6.4  #include <xen/config.h>
     6.5  #include <xen/compiler.h>
     6.6  #include <xen/errno.h>
     6.7 -#include <xen/sched.h>
     6.8  #include <xen/prefetch.h>
     6.9  #include <asm/page.h>
    6.10