ia64/xen-unstable

changeset 3873:523423e2510b

bitkeeper revision 1.1205.1.11 (4217992bf9DJxC6jfUMIeJI7nFHXFA)

Get rid of vmx_update_shadow_state();
integrate into regular shadow code.
author maf46@burn.cl.cam.ac.uk
date Sat Feb 19 19:53:15 2005 +0000 (2005-02-19)
parents 5950d2ac5f17
children ad1d06d64313
files xen/arch/x86/domain.c xen/arch/x86/shadow.c xen/include/asm-x86/shadow.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Sat Feb 19 19:42:39 2005 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Sat Feb 19 19:53:15 2005 +0000
     1.3 @@ -248,6 +248,10 @@ void arch_do_createdomain(struct exec_do
     1.4          machine_to_phys_mapping[virt_to_phys(d->arch.mm_perdomain_pt) >> 
     1.5                                 PAGE_SHIFT] = INVALID_M2P_ENTRY;
     1.6          ed->arch.perdomain_ptes = d->arch.mm_perdomain_pt;
     1.7 +#if 0 /* don't need this yet, but maybe soon! */
     1.8 +        ed->arch.guest_vtable = linear_l2_table;
     1.9 +        ed->arch.shadow_vtable = shadow_linear_l2_table;
    1.10 +#endif
    1.11  
    1.12  #ifdef __x86_64__
    1.13          d->arch.mm_perdomain_l2 = (l2_pgentry_t *)alloc_xenheap_page();
    1.14 @@ -312,19 +316,19 @@ static void alloc_monitor_pagetable(stru
    1.15             &idle_pg_table[DOMAIN_ENTRIES_PER_L2_PAGETABLE],
    1.16             HYPERVISOR_ENTRIES_PER_L2_PAGETABLE * sizeof(l2_pgentry_t));
    1.17  
    1.18 -    ed->arch.monitor_table = mk_pagetable(mpfn << PAGE_SHIFT);
    1.19 -
    1.20      mpl2e[l2_table_offset(PERDOMAIN_VIRT_START)] =
    1.21          mk_l2_pgentry((__pa(d->arch.mm_perdomain_pt) & PAGE_MASK) 
    1.22                        | __PAGE_HYPERVISOR);
    1.23  
    1.24 +    ed->arch.monitor_table = mk_pagetable(mpfn << PAGE_SHIFT);
    1.25 +    ed->arch.monitor_vtable = mpl2e;
    1.26 +
    1.27      phys_table = (l2_pgentry_t *)
    1.28          map_domain_mem(pagetable_val(ed->arch.phys_table));
    1.29      memcpy(d->arch.mm_perdomain_pt, phys_table,
    1.30             L1_PAGETABLE_ENTRIES * sizeof(l1_pgentry_t));
    1.31  
    1.32      unmap_domain_mem(phys_table);
    1.33 -    unmap_domain_mem(mpl2e);
    1.34  }
    1.35  
    1.36  /*
    1.37 @@ -337,8 +341,8 @@ static void free_monitor_pagetable(struc
    1.38  
    1.39      ASSERT( pagetable_val(ed->arch.monitor_table) );
    1.40      
    1.41 -    mpl2e = (l2_pgentry_t *)
    1.42 -        map_domain_mem(pagetable_val(ed->arch.monitor_table));
    1.43 +    mpl2e = ed->arch.monitor_vtable;
    1.44 +
    1.45      /*
    1.46       * First get the pfn for hl2_table by looking at monitor_table
    1.47       */
    1.48 @@ -355,6 +359,7 @@ static void free_monitor_pagetable(struc
    1.49      free_domheap_page(&frame_table[mpfn]);
    1.50  
    1.51      ed->arch.monitor_table = mk_pagetable(0);
    1.52 +    ed->arch.monitor_vtable = 0;
    1.53  }
    1.54  
    1.55  static int vmx_final_setup_guest(struct exec_domain *ed,
     2.1 --- a/xen/arch/x86/shadow.c	Sat Feb 19 19:42:39 2005 +0000
     2.2 +++ b/xen/arch/x86/shadow.c	Sat Feb 19 19:53:15 2005 +0000
     2.3 @@ -489,15 +489,7 @@ unsigned long shadow_l2_table(
     2.4   
     2.5  #ifdef __i386__
     2.6      /* Install hypervisor and 2x linear p.t. mapings. */
     2.7 -    if ( shadow_mode_translate(d) )
     2.8 -    {
     2.9 -#ifdef CONFIG_VMX
    2.10 -        vmx_update_shadow_state(d->exec_domain[0], gmfn, spfn);
    2.11 -#else
    2.12 -        panic("Shadow Full 32 not yet implemented without VMX\n");
    2.13 -#endif
    2.14 -    }
    2.15 -    else
    2.16 +    if ( !shadow_mode_translate(d) )
    2.17      {
    2.18          l2_pgentry_t *spl2e;
    2.19          spl2e = (l2_pgentry_t *)map_domain_mem(spfn << PAGE_SHIFT);
     3.1 --- a/xen/include/asm-x86/shadow.h	Sat Feb 19 19:42:39 2005 +0000
     3.2 +++ b/xen/include/asm-x86/shadow.h	Sat Feb 19 19:53:15 2005 +0000
     3.3 @@ -656,39 +656,6 @@ static inline void set_shadow_status(
     3.4    
     3.5  #ifdef CONFIG_VMX
     3.6  
     3.7 -static inline void vmx_update_shadow_state(
     3.8 -    struct exec_domain *ed, unsigned long gmfn, unsigned long smfn)
     3.9 -{
    3.10 -
    3.11 -    l2_pgentry_t *mpl2e = 0;
    3.12 -    l2_pgentry_t *gpl2e, *spl2e;
    3.13 -
    3.14 -    /* unmap the old mappings */
    3.15 -    if ( ed->arch.shadow_vtable )
    3.16 -        unmap_domain_mem(ed->arch.shadow_vtable);
    3.17 -    if ( ed->arch.guest_vtable )
    3.18 -        unmap_domain_mem(ed->arch.guest_vtable);
    3.19 -
    3.20 -    /* new mapping */
    3.21 -    mpl2e = (l2_pgentry_t *)
    3.22 -        map_domain_mem(pagetable_val(ed->arch.monitor_table));
    3.23 -
    3.24 -    // mafetter: why do we need to keep setting up shadow_linear_pg_table for
    3.25 -    // this monitor page table?  Seems unnecessary...
    3.26 -    //
    3.27 -    mpl2e[l2_table_offset(SH_LINEAR_PT_VIRT_START)] =
    3.28 -        mk_l2_pgentry((smfn << PAGE_SHIFT) | __PAGE_HYPERVISOR);
    3.29 -    __flush_tlb_one(SH_LINEAR_PT_VIRT_START);
    3.30 -
    3.31 -    spl2e = (l2_pgentry_t *)map_domain_mem(smfn << PAGE_SHIFT);
    3.32 -    gpl2e = (l2_pgentry_t *)map_domain_mem(gmfn << PAGE_SHIFT);
    3.33 -    memset(spl2e, 0, L2_PAGETABLE_ENTRIES * sizeof(l2_pgentry_t));
    3.34 -
    3.35 -    ed->arch.shadow_vtable = spl2e;
    3.36 -    ed->arch.guest_vtable = gpl2e; /* expect the guest did clean this up */
    3.37 -    unmap_domain_mem(mpl2e);
    3.38 -}
    3.39 -
    3.40  static inline unsigned long gva_to_gpte(unsigned long gva)
    3.41  {
    3.42      unsigned long gpde, gpte, pfn, index;
    3.43 @@ -737,18 +704,44 @@ static inline void __update_pagetables(s
    3.44  
    3.45      if ( unlikely(smfn == 0) )
    3.46          smfn = shadow_l2_table(d, gmfn);
    3.47 -#ifdef CONFIG_VMX
    3.48 -    else if ( shadow_mode_translate(ed->domain) )
    3.49 -        vmx_update_shadow_state(ed, gmfn, smfn);
    3.50 -#endif
    3.51  
    3.52      ed->arch.shadow_table = mk_pagetable(smfn<<PAGE_SHIFT);
    3.53  
    3.54 -    if ( !shadow_mode_external(ed->domain) )
    3.55 -        // mafetter: why do we need to keep overwriting
    3.56 -        // ed->arch.monitor_table?  Seems unnecessary...
    3.57 -        //
    3.58 -        ed->arch.monitor_table = ed->arch.shadow_table;
    3.59 +    if  ( shadow_mode_translate(ed->domain) )
    3.60 +    {
    3.61 +        l2_pgentry_t *gpl2e, *spl2e;
    3.62 +
    3.63 +        if ( ed->arch.guest_vtable )
    3.64 +            unmap_domain_mem(ed->arch.guest_vtable);
    3.65 +        if ( ed->arch.shadow_vtable )
    3.66 +            unmap_domain_mem(ed->arch.shadow_vtable);
    3.67 +
    3.68 +        gpl2e = ed->arch.guest_vtable =
    3.69 +            map_domain_mem(pagetable_val(ed->arch.guest_table));
    3.70 +        spl2e = ed->arch.shadow_vtable =
    3.71 +            map_domain_mem(pagetable_val(ed->arch.shadow_table));
    3.72 +
    3.73 +        if ( shadow_mode_external(ed->domain ) )
    3.74 +        {
    3.75 +            l2_pgentry_t *mpl2e = ed->arch.monitor_vtable;
    3.76 +            unsigned long old_smfn;
    3.77 +            unsigned sh_l2offset = l2_table_offset(SH_LINEAR_PT_VIRT_START);
    3.78 +            
    3.79 +            old_smfn = l2_pgentry_val(mpl2e[sh_l2offset]) >> PAGE_SHIFT;
    3.80 +            if ( old_smfn != smfn )
    3.81 +            {
    3.82 +                mpl2e[sh_l2offset] =
    3.83 +                    mk_l2_pgentry((smfn << PAGE_SHIFT) | __PAGE_HYPERVISOR);
    3.84 +                local_flush_tlb();
    3.85 +            }
    3.86 +        }
    3.87 +
    3.88 +        if ( ed->arch.arch_vmx.flags )
    3.89 +        {
    3.90 +            // Why is VMX mode doing this?
    3.91 +            memset(spl2e, 0, L2_PAGETABLE_ENTRIES * sizeof(l2_pgentry_t));
    3.92 +        }
    3.93 +    }
    3.94  }
    3.95  
    3.96  static inline void update_pagetables(struct exec_domain *ed)
    3.97 @@ -759,18 +752,18 @@ static inline void update_pagetables(str
    3.98           __update_pagetables(ed);
    3.99           shadow_unlock(ed->domain);
   3.100       }
   3.101 +     if ( !shadow_mode_external(ed->domain) )
   3.102 +     {
   3.103  #ifdef __x86_64__
   3.104 -     else if ( !(ed->arch.flags & TF_kernel_mode) )
   3.105 -         // mafetter: why do we need to keep overwriting
   3.106 -         // ed->arch.monitor_table?  Seems unnecessary...
   3.107 -         //
   3.108 -         ed->arch.monitor_table = ed->arch.guest_table_user;
   3.109 +         if ( !(ed->arch.flags & TF_kernel_mode) )
   3.110 +             ed->arch.monitor_table = ed->arch.guest_table_user;
   3.111 +         else
   3.112  #endif
   3.113 -     else
   3.114 -         // mafetter: why do we need to keep overwriting
   3.115 -         // ed->arch.monitor_table?  Seems unnecessary...
   3.116 -         //
   3.117 -         ed->arch.monitor_table = ed->arch.guest_table;
   3.118 +         if ( shadow_mode_enabled(ed->domain) )
   3.119 +             ed->arch.monitor_table = ed->arch.shadow_table;
   3.120 +         else
   3.121 +             ed->arch.monitor_table = ed->arch.guest_table;
   3.122 +     }
   3.123  }
   3.124  
   3.125  #if SHADOW_DEBUG