ia64/xen-unstable

changeset 3858:5b63436f25fe

bitkeeper revision 1.1205.1.2 (421527deX3t0INFwjrOweq0E7Le7pw)

Rename fields in arch_exec_domain to be more uniform.
Promote vmx_shadow_invlpg() to shadow_invlpg().
author maf46@burn.cl.cam.ac.uk
date Thu Feb 17 23:25:18 2005 +0000 (2005-02-17)
parents 0fe3bb5ed3aa
children ea5144e1109e
files xen/arch/x86/domain.c xen/arch/x86/shadow.c xen/arch/x86/vmx.c xen/arch/x86/vmx_io.c xen/arch/x86/vmx_vmcs.c xen/include/asm-x86/domain.h xen/include/asm-x86/shadow.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Thu Feb 17 21:14:30 2005 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Thu Feb 17 23:25:18 2005 +0000
     1.3 @@ -328,7 +328,7 @@ static void alloc_monitor_pagetable(stru
     1.4  }
     1.5  
     1.6  /*
     1.7 - * Free the pages for monitor_table and guest_pl2e_cache
     1.8 + * Free the pages for monitor_table and hl2_table
     1.9   */
    1.10  static void free_monitor_pagetable(struct exec_domain *ed)
    1.11  {
    1.12 @@ -340,7 +340,7 @@ static void free_monitor_pagetable(struc
    1.13      mpl2e = (l2_pgentry_t *)
    1.14          map_domain_mem(pagetable_val(ed->arch.monitor_table));
    1.15      /*
    1.16 -     * First get the pfn for guest_pl2e_cache by looking at monitor_table
    1.17 +     * First get the pfn for hl2_table by looking at monitor_table
    1.18       */
    1.19      mpfn = l2_pgentry_val(mpl2e[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT])
    1.20          >> PAGE_SHIFT;
    1.21 @@ -410,7 +410,7 @@ static int vmx_final_setup_guest(struct 
    1.22      /* We don't call update_pagetables() as we actively want fields such as 
    1.23       * the linear_pg_table to be null so that we bail out early of 
    1.24       * shadow_fault in case the vmx guest tries illegal accesses with
    1.25 -     * paging turned of. 
    1.26 +     * paging turned off. 
    1.27       */
    1.28      //update_pagetables(ed);     /* this assigns shadow_pagetable */
    1.29      alloc_monitor_pagetable(ed); /* this assigns monitor_pagetable */
     2.1 --- a/xen/arch/x86/shadow.c	Thu Feb 17 21:14:30 2005 +0000
     2.2 +++ b/xen/arch/x86/shadow.c	Thu Feb 17 23:25:18 2005 +0000
     2.3 @@ -584,14 +584,15 @@ static void shadow_map_l1_into_current_l
     2.4      }              
     2.5  }
     2.6  
     2.7 -#ifdef CONFIG_VMX
     2.8 -void vmx_shadow_invlpg(struct domain *d, unsigned long va)
     2.9 +void shadow_invlpg(struct exec_domain *ed, unsigned long va)
    2.10  {
    2.11 -    unsigned long gpte, spte, host_pfn;
    2.12 +    unsigned long gpte, spte;
    2.13 +
    2.14 +    ASSERT(shadow_mode_enabled(ed->domain));
    2.15  
    2.16      if (__put_user(0L, (unsigned long *)
    2.17                     &shadow_linear_pg_table[va >> PAGE_SHIFT])) {
    2.18 -        vmx_shadow_clear_state(d);
    2.19 +        vmx_shadow_clear_state(ed->domain);
    2.20          return;
    2.21      }
    2.22  
    2.23 @@ -600,15 +601,13 @@ void vmx_shadow_invlpg(struct domain *d,
    2.24          return;
    2.25      }
    2.26  
    2.27 -    host_pfn = phys_to_machine_mapping(gpte >> PAGE_SHIFT);
    2.28 -    spte = (host_pfn << PAGE_SHIFT) | (gpte & ~PAGE_MASK);
    2.29 +    l1pte_propagate_from_guest(ed->domain, &gpte, &spte);
    2.30  
    2.31      if (__put_user(spte, (unsigned long *)
    2.32                     &shadow_linear_pg_table[va >> PAGE_SHIFT])) {
    2.33          return;
    2.34      }
    2.35  }
    2.36 -#endif
    2.37  
    2.38  int shadow_fault(unsigned long va, long error_code)
    2.39  {
    2.40 @@ -616,7 +615,7 @@ int shadow_fault(unsigned long va, long 
    2.41      struct exec_domain *ed = current;
    2.42      struct domain *d = ed->domain;
    2.43  
    2.44 -    SH_VVLOG("shadow_fault( va=%p, code=%ld )", va, error_code );
    2.45 +    SH_VVLOG("shadow_fault( va=%p, code=%lu )", va, error_code );
    2.46  
    2.47      check_pagetable(d, ed->arch.guest_table, "pre-sf");
    2.48  
     3.1 --- a/xen/arch/x86/vmx.c	Thu Feb 17 21:14:30 2005 +0000
     3.2 +++ b/xen/arch/x86/vmx.c	Thu Feb 17 23:25:18 2005 +0000
     3.3 @@ -114,7 +114,6 @@ static int vmx_do_page_fault(unsigned lo
     3.4      unsigned long eip;
     3.5      unsigned long gpa;
     3.6      int result;
     3.7 -    struct exec_domain *ed = current;
     3.8  
     3.9  #if VMX_DEBUG
    3.10      {
    3.11 @@ -129,7 +128,7 @@ static int vmx_do_page_fault(unsigned lo
    3.12       * If vpagetable is zero, then we are still emulating 1:1 page tables,
    3.13       * and we should have never gotten here.
    3.14       */
    3.15 -    if ( !ed->arch.vpagetable )
    3.16 +    if ( !current->arch.guest_vtable )
    3.17      {
    3.18          printk("vmx_do_page_fault while still running on 1:1 page table\n");
    3.19          return 0;
    3.20 @@ -277,18 +276,18 @@ static void vmx_vmexit_do_invlpg(unsigne
    3.21       * We do the safest things first, then try to update the shadow
    3.22       * copying from guest
    3.23       */
    3.24 -    vmx_shadow_invlpg(ed->domain, va);
    3.25 +    shadow_invlpg(ed, va);
    3.26      index = (va >> L2_PAGETABLE_SHIFT);
    3.27 -    ed->arch.guest_pl2e_cache[index] = 
    3.28 +    ed->arch.hl2_vtable[index] = 
    3.29          mk_l2_pgentry(0); /* invalidate pgd cache */
    3.30  }
    3.31  
    3.32 -static inline void guest_pl2e_cache_invalidate(struct exec_domain *ed)
    3.33 +static inline void hl2_table_invalidate(struct exec_domain *ed)
    3.34  {
    3.35      /*
    3.36       * Need to optimize this
    3.37       */
    3.38 -    memset(ed->arch.guest_pl2e_cache, 0, PAGE_SIZE);
    3.39 +    memset(ed->arch.hl2_vtable, 0, PAGE_SIZE);
    3.40  }
    3.41  
    3.42  static void vmx_io_instruction(struct xen_regs *regs, 
    3.43 @@ -474,7 +473,7 @@ static void mov_to_cr(int gp, int cr, st
    3.44              break;
    3.45          }
    3.46          
    3.47 -        guest_pl2e_cache_invalidate(d);
    3.48 +        hl2_table_invalidate(d);
    3.49          /*
    3.50           * We make a new one if the shadow does not exist.
    3.51           */
    3.52 @@ -531,7 +530,7 @@ static void mov_to_cr(int gp, int cr, st
    3.53          if ((old_cr ^ value) & (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE)) {
    3.54              vmx_shadow_clear_state(d->domain);
    3.55              shadow_invalidate(d);
    3.56 -            guest_pl2e_cache_invalidate(d);
    3.57 +            hl2_table_invalidate(d);
    3.58          }
    3.59          break;
    3.60      default:
     4.1 --- a/xen/arch/x86/vmx_io.c	Thu Feb 17 21:14:30 2005 +0000
     4.2 +++ b/xen/arch/x86/vmx_io.c	Thu Feb 17 23:25:18 2005 +0000
     4.3 @@ -380,7 +380,7 @@ void vmx_intr_assist(struct exec_domain 
     4.4  
     4.5  void vmx_do_resume(struct exec_domain *d) 
     4.6  {
     4.7 -    if ( d->arch.vpagetable )
     4.8 +    if ( d->arch.guest_vtable )
     4.9          __vmwrite(GUEST_CR3, pagetable_val(d->arch.shadow_table));
    4.10      else
    4.11          // we haven't switched off the 1:1 pagetable yet...
     5.1 --- a/xen/arch/x86/vmx_vmcs.c	Thu Feb 17 21:14:30 2005 +0000
     5.2 +++ b/xen/arch/x86/vmx_vmcs.c	Thu Feb 17 23:25:18 2005 +0000
     5.3 @@ -158,7 +158,7 @@ void vmx_do_launch(struct exec_domain *e
     5.4      struct host_execution_env host_env;
     5.5      struct Xgt_desc_struct desc;
     5.6      struct list_head *list_ent;
     5.7 -    l2_pgentry_t *mpl2e, *guest_pl2e_cache;
     5.8 +    l2_pgentry_t *mpl2e, *hl2_vtable;
     5.9      unsigned long i, pfn = 0;
    5.10      struct pfn_info *page;
    5.11      execution_context_t *ec = get_execution_context();
    5.12 @@ -191,9 +191,9 @@ void vmx_do_launch(struct exec_domain *e
    5.13      mpl2e[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] =
    5.14          mk_l2_pgentry((pfn << PAGE_SHIFT)| __PAGE_HYPERVISOR);
    5.15  
    5.16 -    guest_pl2e_cache = map_domain_mem(pfn << PAGE_SHIFT);
    5.17 -    memset(guest_pl2e_cache, 0, PAGE_SIZE); /* clean it up */
    5.18 -    ed->arch.guest_pl2e_cache = guest_pl2e_cache; 
    5.19 +    hl2_vtable = map_domain_mem(pfn << PAGE_SHIFT);
    5.20 +    memset(hl2_vtable, 0, PAGE_SIZE); /* clean it up */
    5.21 +    ed->arch.hl2_vtable = hl2_vtable; 
    5.22          
    5.23      unmap_domain_mem(mpl2e);
    5.24  
     6.1 --- a/xen/include/asm-x86/domain.h	Thu Feb 17 21:14:30 2005 +0000
     6.2 +++ b/xen/include/asm-x86/domain.h	Thu Feb 17 23:25:18 2005 +0000
     6.3 @@ -66,7 +66,7 @@ struct arch_exec_domain
     6.4       * The stack frame for events is exactly that of an x86 hardware interrupt.
     6.5       * The stack frame for a failsafe callback is augmented with saved values
     6.6       * for segment registers %ds, %es, %fs and %gs:
     6.7 -     * 	%ds, %es, %fs, %gs, %eip, %cs, %eflags [, %oldesp, %oldss]
     6.8 +     *  %ds, %es, %fs, %gs, %eip, %cs, %eflags [, %oldesp, %oldss]
     6.9       */
    6.10  
    6.11      unsigned long event_selector;    /* entry CS  (x86/32 only) */
    6.12 @@ -104,13 +104,15 @@ struct arch_exec_domain
    6.13      pagetable_t  guest_table_user;      /* x86/64: user-space pagetable. */
    6.14      pagetable_t  guest_table;           /* guest notion of cr3 */
    6.15      pagetable_t  shadow_table;          /* shadow of guest */
    6.16 +    pagetable_t  hl2_table;             /* shortcut to guest's L1 PTEs */
    6.17      pagetable_t  monitor_table;         /* used in hypervisor */
    6.18  
    6.19      pagetable_t  phys_table;            /* guest 1:1 pagetable */
    6.20  
    6.21 -    l2_pgentry_t *vpagetable;	        /* virtual address of pagetable */
    6.22 -    l2_pgentry_t *shadow_vtable;	/* virtual address of shadow_table */
    6.23 -    l2_pgentry_t *guest_pl2e_cache;	/* guest page directory cache */
    6.24 +    l2_pgentry_t *guest_vtable;         /* virtual address of pagetable */
    6.25 +    l2_pgentry_t *shadow_vtable;        /* virtual address of shadow_table */
    6.26 +    l2_pgentry_t *hl2_vtable;			/* virtual address of hl2_table */
    6.27 +    l2_pgentry_t *monitor_vtable;		/* virtual address of monitor_table */
    6.28  
    6.29      /* Virtual CR2 value. Can be read/written by guest. */
    6.30      unsigned long guest_cr2;
     7.1 --- a/xen/include/asm-x86/shadow.h	Thu Feb 17 21:14:30 2005 +0000
     7.2 +++ b/xen/include/asm-x86/shadow.h	Thu Feb 17 23:25:18 2005 +0000
     7.3 @@ -46,10 +46,10 @@ extern void shadow_l2_normal_pt_update(u
     7.4  extern void unshadow_table(unsigned long gpfn, unsigned int type);
     7.5  extern int shadow_mode_enable(struct domain *p, unsigned int mode);
     7.6  extern void free_shadow_state(struct domain *d);
     7.7 +extern void shadow_invlpg(struct exec_domain *, unsigned long);
     7.8  
     7.9  #ifdef CONFIG_VMX
    7.10  extern void vmx_shadow_clear_state(struct domain *);
    7.11 -extern void vmx_shadow_invlpg(struct domain *, unsigned long);
    7.12  #endif
    7.13  
    7.14  #define __mfn_to_gpfn(_d, mfn)                         \
    7.15 @@ -131,10 +131,8 @@ static inline void __shadow_get_l2e(
    7.16              *sl2e = l2_pgentry_val(
    7.17                  shadow_linear_l2_table[l2_table_offset(va)]);
    7.18      }
    7.19 -    else {
    7.20 -        BUG(); /* why do we need this case? */
    7.21 -        *sl2e = l2_pgentry_val(linear_l2_table[l2_table_offset(va)]);
    7.22 -    }
    7.23 +    else
    7.24 +        BUG();
    7.25  }
    7.26  
    7.27  static inline void __shadow_set_l2e(
    7.28 @@ -147,17 +145,14 @@ static inline void __shadow_set_l2e(
    7.29              shadow_linear_l2_table[l2_table_offset(va)] = mk_l2_pgentry(value);
    7.30      }
    7.31      else
    7.32 -    {
    7.33 -        BUG(); /* why do we need this case? */
    7.34 -        linear_l2_table[l2_table_offset(va)] = mk_l2_pgentry(value);
    7.35 -    }
    7.36 +        BUG();
    7.37  }
    7.38  
    7.39  static inline void __guest_get_l2e(
    7.40      struct exec_domain *ed, unsigned long va, unsigned long *l2e)
    7.41  {
    7.42      *l2e = ( shadow_mode_translate(ed->domain) ) ?
    7.43 -        l2_pgentry_val(ed->arch.vpagetable[l2_table_offset(va)]) :
    7.44 +        l2_pgentry_val(ed->arch.guest_vtable[l2_table_offset(va)]) :
    7.45          l2_pgentry_val(linear_l2_table[l2_table_offset(va)]);
    7.46  }
    7.47  
    7.48 @@ -169,10 +164,10 @@ static inline void __guest_set_l2e(
    7.49          unsigned long pfn;
    7.50  
    7.51          pfn = phys_to_machine_mapping(value >> PAGE_SHIFT);
    7.52 -        ed->arch.guest_pl2e_cache[l2_table_offset(va)] =
    7.53 +        ed->arch.hl2_vtable[l2_table_offset(va)] =
    7.54              mk_l2_pgentry((pfn << PAGE_SHIFT) | __PAGE_HYPERVISOR);
    7.55  
    7.56 -        ed->arch.vpagetable[l2_table_offset(va)] = mk_l2_pgentry(value);
    7.57 +        ed->arch.guest_vtable[l2_table_offset(va)] = mk_l2_pgentry(value);
    7.58      }
    7.59      else
    7.60      {
    7.61 @@ -671,13 +666,16 @@ static inline void vmx_update_shadow_sta
    7.62      /* unmap the old mappings */
    7.63      if ( ed->arch.shadow_vtable )
    7.64          unmap_domain_mem(ed->arch.shadow_vtable);
    7.65 -    if ( ed->arch.vpagetable )
    7.66 -        unmap_domain_mem(ed->arch.vpagetable);
    7.67 +    if ( ed->arch.guest_vtable )
    7.68 +        unmap_domain_mem(ed->arch.guest_vtable);
    7.69  
    7.70      /* new mapping */
    7.71      mpl2e = (l2_pgentry_t *)
    7.72          map_domain_mem(pagetable_val(ed->arch.monitor_table));
    7.73  
    7.74 +    // mafetter: why do we need to keep setting up shadow_linear_pg_table for
    7.75 +    // this monitor page table?  Seems unnecessary...
    7.76 +    //
    7.77      mpl2e[l2_table_offset(SH_LINEAR_PT_VIRT_START)] =
    7.78          mk_l2_pgentry((smfn << PAGE_SHIFT) | __PAGE_HYPERVISOR);
    7.79      __flush_tlb_one(SH_LINEAR_PT_VIRT_START);
    7.80 @@ -687,7 +685,7 @@ static inline void vmx_update_shadow_sta
    7.81      memset(spl2e, 0, L2_PAGETABLE_ENTRIES * sizeof(l2_pgentry_t));
    7.82  
    7.83      ed->arch.shadow_vtable = spl2e;
    7.84 -    ed->arch.vpagetable = gpl2e; /* expect the guest did clean this up */
    7.85 +    ed->arch.guest_vtable = gpl2e; /* expect the guest did clean this up */
    7.86      unmap_domain_mem(mpl2e);
    7.87  }
    7.88  
    7.89 @@ -702,9 +700,9 @@ static inline unsigned long gva_to_gpte(
    7.90  
    7.91      index = (gva >> L2_PAGETABLE_SHIFT);
    7.92  
    7.93 -    if (!l2_pgentry_val(ed->arch.guest_pl2e_cache[index])) {
    7.94 +    if (!l2_pgentry_val(ed->arch.hl2_vtable[index])) {
    7.95          pfn = phys_to_machine_mapping(gpde >> PAGE_SHIFT);
    7.96 -        ed->arch.guest_pl2e_cache[index] = 
    7.97 +        ed->arch.hl2_vtable[index] = 
    7.98              mk_l2_pgentry((pfn << PAGE_SHIFT) | __PAGE_HYPERVISOR);
    7.99      }
   7.100  
   7.101 @@ -746,6 +744,9 @@ static inline void __update_pagetables(s
   7.102      ed->arch.shadow_table = mk_pagetable(smfn<<PAGE_SHIFT);
   7.103  
   7.104      if ( !shadow_mode_external(ed->domain) )
   7.105 +        // mafetter: why do we need to keep overwriting
   7.106 +        // ed->arch.monitor_table?  Seems unnecessary...
   7.107 +        //
   7.108          ed->arch.monitor_table = ed->arch.shadow_table;
   7.109  }
   7.110  
   7.111 @@ -759,9 +760,15 @@ static inline void update_pagetables(str
   7.112       }
   7.113  #ifdef __x86_64__
   7.114       else if ( !(ed->arch.flags & TF_kernel_mode) )
   7.115 +         // mafetter: why do we need to keep overwriting
   7.116 +         // ed->arch.monitor_table?  Seems unnecessary...
   7.117 +         //
   7.118           ed->arch.monitor_table = ed->arch.guest_table_user;
   7.119  #endif
   7.120       else
   7.121 +         // mafetter: why do we need to keep overwriting
   7.122 +         // ed->arch.monitor_table?  Seems unnecessary...
   7.123 +         //
   7.124           ed->arch.monitor_table = ed->arch.guest_table;
   7.125  }
   7.126