ia64/xen-unstable

changeset 4510:f6326ed2e7fe

bitkeeper revision 1.1288 (425b9987hyix49ReaseCwzMc1AFxcQ)

Hand merged
author mafetter@fleming.research
date Tue Apr 12 09:48:55 2005 +0000 (2005-04-12)
parents 3c81571fdbfb 23185fc6ba7b
children 94452568bf73
files linux-2.6.11-xen-sparse/arch/xen/Kconfig linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32 linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h tools/libxc/xc_linux_build.c xen/arch/x86/domain.c xen/arch/x86/mm.c xen/arch/x86/shadow.c xen/common/dom_mem_ops.c xen/include/asm-x86/shadow.h xen/include/xen/perfc_defn.h
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/arch/xen/Kconfig	Mon Apr 11 17:56:17 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/Kconfig	Tue Apr 12 09:48:55 2005 +0000
     1.3 @@ -123,6 +123,13 @@ config XEN_BLKDEV_TAP
     1.4  	  to a character device, allowing device prototyping in application
     1.5  	  space.  Odds are that you want to say N here.
     1.6  
     1.7 +config XEN_SHADOW_MODE
     1.8 +	bool "Fake shadow mode"
     1.9 +	default n
    1.10 +    help
    1.11 +      fakes out a shadow mode kernel
    1.12 +
    1.13 +
    1.14  config XEN_SCRUB_PAGES
    1.15  	bool "Scrub memory before freeing it to Xen"
    1.16  	default y
     3.1 --- a/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32	Mon Apr 11 17:56:17 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32	Tue Apr 12 09:48:55 2005 +0000
     3.3 @@ -17,6 +17,7 @@ CONFIG_XEN_BLKDEV_FRONTEND=y
     3.4  CONFIG_XEN_NETDEV_FRONTEND=y
     3.5  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
     3.6  # CONFIG_XEN_BLKDEV_TAP is not set
     3.7 +CONFIG_XEN_SHADOW_MODE=y
     3.8  CONFIG_XEN_SCRUB_PAGES=y
     3.9  CONFIG_XEN_X86=y
    3.10  # CONFIG_XEN_X86_64 is not set
     4.1 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c	Mon Apr 11 17:56:17 2005 +0000
     4.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c	Tue Apr 12 09:48:55 2005 +0000
     4.3 @@ -48,6 +48,7 @@
     4.4  #define pmd_val_ma(v) (v).pud.pgd.pgd;
     4.5  #endif
     4.6  
     4.7 +#ifndef CONFIG_XEN_SHADOW_MODE
     4.8  void xen_l1_entry_update(pte_t *ptr, unsigned long val)
     4.9  {
    4.10      mmu_update_t u;
    4.11 @@ -63,6 +64,7 @@ void xen_l2_entry_update(pmd_t *ptr, pmd
    4.12      u.val = pmd_val_ma(val);
    4.13      BUG_ON(HYPERVISOR_mmu_update(&u, 1, NULL, DOMID_SELF) < 0);
    4.14  }
    4.15 +#endif
    4.16  
    4.17  void xen_machphys_update(unsigned long mfn, unsigned long pfn)
    4.18  {
    4.19 @@ -131,6 +133,7 @@ void xen_invlpg_mask(cpumask_t mask, uns
    4.20  
    4.21  #endif /* CONFIG_SMP */
    4.22  
    4.23 +#ifndef CONFIG_XEN_SHADOW_MODE
    4.24  void xen_pgd_pin(unsigned long ptr)
    4.25  {
    4.26      struct mmuext_op op;
    4.27 @@ -162,6 +165,7 @@ void xen_pte_unpin(unsigned long ptr)
    4.28      op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
    4.29      BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
    4.30  }
    4.31 +#endif
    4.32  
    4.33  void xen_set_ldt(unsigned long ptr, unsigned long len)
    4.34  {
     5.1 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	Mon Apr 11 17:56:17 2005 +0000
     5.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	Tue Apr 12 09:48:55 2005 +0000
     5.3 @@ -366,6 +366,7 @@ void pgd_free(pgd_t *pgd)
     5.4  	kmem_cache_free(pgd_cache, pgd);
     5.5  }
     5.6  
     5.7 +#ifndef CONFIG_XEN_SHADOW_MODE
     5.8  void make_lowmem_page_readonly(void *va)
     5.9  {
    5.10  	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    5.11 @@ -437,3 +438,4 @@ void make_pages_writable(void *va, unsig
    5.12  		va = (void *)((unsigned long)va + PAGE_SIZE);
    5.13  	}
    5.14  }
    5.15 +#endif /* CONFIG_XEN_SHADOW_MODE */
     6.1 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Mon Apr 11 17:56:17 2005 +0000
     6.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Tue Apr 12 09:48:55 2005 +0000
     6.3 @@ -15,7 +15,12 @@
     6.4   */
     6.5  #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
     6.6  #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
     6.7 +
     6.8 +#ifndef CONFIG_XEN_SHADOW_MODE
     6.9  #define set_pmd(pmdptr, pmdval) xen_l2_entry_update((pmdptr), (pmdval))
    6.10 +#else
    6.11 +#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
    6.12 +#endif
    6.13  
    6.14  #define ptep_get_and_clear(xp)	__pte_ma(xchg(&(xp)->pte_low, 0))
    6.15  #define pte_same(a, b)		((a).pte_low == (b).pte_low)
     7.1 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Mon Apr 11 17:56:17 2005 +0000
     7.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Tue Apr 12 09:48:55 2005 +0000
     7.3 @@ -432,12 +432,21 @@ do {				  					\
     7.4  	}								\
     7.5  } while (0)
     7.6  
     7.7 +#ifndef CONFIG_XEN_SHADOW_MODE
     7.8  void make_lowmem_page_readonly(void *va);
     7.9  void make_lowmem_page_writable(void *va);
    7.10  void make_page_readonly(void *va);
    7.11  void make_page_writable(void *va);
    7.12  void make_pages_readonly(void *va, unsigned int nr);
    7.13  void make_pages_writable(void *va, unsigned int nr);
    7.14 +#else
    7.15 +#define make_lowmem_page_readonly(_va) ((void)0)
    7.16 +#define make_lowmem_page_writable(_va) ((void)0)
    7.17 +#define make_page_readonly(_va)        ((void)0)
    7.18 +#define make_page_writable(_va)        ((void)0)
    7.19 +#define make_pages_readonly(_va, _nr)  ((void)0)
    7.20 +#define make_pages_writable(_va, _nr)  ((void)0)
    7.21 +#endif
    7.22  
    7.23  #define arbitrary_virt_to_machine(__va)					\
    7.24  ({									\
     8.1 --- a/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h	Mon Apr 11 17:56:17 2005 +0000
     8.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h	Tue Apr 12 09:48:55 2005 +0000
     8.3 @@ -73,15 +73,17 @@ void lgdt_finish(void);
     8.4   * be MACHINE addresses.
     8.5   */
     8.6  
     8.7 -void xen_l1_entry_update(pte_t *ptr, unsigned long val);
     8.8 -void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
     8.9 -void xen_l3_entry_update(pud_t *ptr, pud_t val); /* x86_64 only */
    8.10 -void xen_l4_entry_update(pgd_t *ptr, pgd_t val); /* x86_64 only */
    8.11  void xen_pt_switch(unsigned long ptr);
    8.12  void xen_new_user_pt(unsigned long ptr); /* x86_64 only */
    8.13  void xen_load_gs(unsigned int selector); /* x86_64 only */
    8.14  void xen_tlb_flush(void);
    8.15  void xen_invlpg(unsigned long ptr);
    8.16 +
    8.17 +#ifndef CONFIG_XEN_SHADOW_MODE
    8.18 +void xen_l1_entry_update(pte_t *ptr, unsigned long val);
    8.19 +void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
    8.20 +void xen_l3_entry_update(pud_t *ptr, pud_t val); /* x86_64 only */
    8.21 +void xen_l4_entry_update(pgd_t *ptr, pgd_t val); /* x86_64 only */
    8.22  void xen_pgd_pin(unsigned long ptr);
    8.23  void xen_pgd_unpin(unsigned long ptr);
    8.24  void xen_pud_pin(unsigned long ptr); /* x86_64 only */
    8.25 @@ -90,6 +92,15 @@ void xen_pmd_pin(unsigned long ptr); /* 
    8.26  void xen_pmd_unpin(unsigned long ptr); /* x86_64 only */
    8.27  void xen_pte_pin(unsigned long ptr);
    8.28  void xen_pte_unpin(unsigned long ptr);
    8.29 +#else
    8.30 +#define xen_l1_entry_update(_p, _v) set_pte((_p), (pte_t){(_v)})
    8.31 +#define xen_l2_entry_update(_p, _v) set_pgd((_p), (pgd_t){(_v)})
    8.32 +#define xen_pgd_pin(_p)   ((void)0)
    8.33 +#define xen_pgd_unpin(_p) ((void)0)
    8.34 +#define xen_pte_pin(_p)   ((void)0)
    8.35 +#define xen_pte_unpin(_p) ((void)0)
    8.36 +#endif
    8.37 +
    8.38  void xen_set_ldt(unsigned long ptr, unsigned long bytes);
    8.39  void xen_machphys_update(unsigned long mfn, unsigned long pfn);
    8.40  
     9.1 --- a/tools/libxc/xc_linux_build.c	Mon Apr 11 17:56:17 2005 +0000
     9.2 +++ b/tools/libxc/xc_linux_build.c	Tue Apr 12 09:48:55 2005 +0000
     9.3 @@ -210,9 +210,11 @@ static int setup_guest(int xc_handle,
     9.4          }
     9.5  
     9.6          *vl1e = (page_array[count] << PAGE_SHIFT) | L1_PROT;
     9.7 +#if !(1 || defined(GROSS_HACK_TO_TEST_SHADOW_MODE_CLIENTS))
     9.8          if ( (count >= ((vpt_start-dsi.v_start)>>PAGE_SHIFT)) && 
     9.9               (count <  ((vpt_end  -dsi.v_start)>>PAGE_SHIFT)) )
    9.10              *vl1e &= ~_PAGE_RW;
    9.11 +#endif
    9.12          vl1e++;
    9.13      }
    9.14      munmap(vl1tab, PAGE_SIZE);
    9.15 @@ -243,12 +245,25 @@ static int setup_guest(int xc_handle,
    9.16      }
    9.17      munmap(physmap, PAGE_SIZE);
    9.18      
    9.19 +#if 1 || defined(GROSS_HACK_TO_TEST_SHADOW_MODE_CLIENTS)
    9.20 +    {
    9.21 +        int ret;
    9.22 +        ret = xc_shadow_control(xc_handle, dom,
    9.23 +                                DOM0_SHADOW_CONTROL_OP_ENABLE_TEST,
    9.24 +                                NULL, 0, NULL);
    9.25 +        if ( !ret )
    9.26 +            ERROR("enabling shadow test mode failed\n");
    9.27 +    }
    9.28 +#endif
    9.29 +
    9.30      /*
    9.31       * Pin down l2tab addr as page dir page - causes hypervisor to provide
    9.32       * correct protection for the page
    9.33       */ 
    9.34 +#if !(1 || defined(GROSS_HACK_TO_TEST_SHADOW_MODE_CLIENTS))
    9.35      if ( pin_table(xc_handle, MMUEXT_PIN_L2_TABLE, l2tab>>PAGE_SHIFT, dom) )
    9.36          goto error_out;
    9.37 +#endif
    9.38  
    9.39      start_info = xc_map_foreign_range(
    9.40          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
    10.1 --- a/xen/arch/x86/domain.c	Mon Apr 11 17:56:17 2005 +0000
    10.2 +++ b/xen/arch/x86/domain.c	Tue Apr 12 09:48:55 2005 +0000
    10.3 @@ -440,9 +440,17 @@ int arch_set_info_guest(
    10.4      phys_basetab = c->pt_base;
    10.5      ed->arch.guest_table = mk_pagetable(phys_basetab);
    10.6  
    10.7 -    if ( !get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], d, 
    10.8 -                            PGT_base_page_table) )
    10.9 -        return -EINVAL;
   10.10 +    if ( shadow_mode_enabled(d) )
   10.11 +    {
   10.12 +        if ( !get_page(&frame_table[phys_basetab>>PAGE_SHIFT], d) )
   10.13 +            return -EINVAL;
   10.14 +    }
   10.15 +    else
   10.16 +    {
   10.17 +        if ( !get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], d, 
   10.18 +                                PGT_base_page_table) )
   10.19 +            return -EINVAL;
   10.20 +    }
   10.21  
   10.22      /* Failure to set GDT is harmless. */
   10.23      SET_GDT_ENTRIES(ed, DEFAULT_GDT_ENTRIES);
    11.1 --- a/xen/arch/x86/mm.c	Mon Apr 11 17:56:17 2005 +0000
    11.2 +++ b/xen/arch/x86/mm.c	Tue Apr 12 09:48:55 2005 +0000
    11.3 @@ -1897,8 +1897,11 @@ int do_mmu_update(
    11.4                          gpfn = __mfn_to_gpfn(d, mfn);
    11.5                          ASSERT(VALID_M2P(gpfn));
    11.6  
    11.7 -                        if ( page_is_page_table(page) )
    11.8 +                        if ( page_is_page_table(page) &&
    11.9 +                             !page_out_of_sync(page) )
   11.10 +                        {
   11.11                              shadow_mark_mfn_out_of_sync(ed, gpfn, mfn);
   11.12 +                        }
   11.13                      }
   11.14  
   11.15                      *(unsigned long *)va = req.val;
   11.16 @@ -2152,7 +2155,7 @@ int do_update_va_mapping(unsigned long v
   11.17              local_flush_tlb();
   11.18              break;
   11.19          case UVMF_ALL:
   11.20 -            BUG_ON(shadow_mode_enabled(d));
   11.21 +            BUG_ON(shadow_mode_enabled(d) && (d->cpuset != (1<<cpu)));
   11.22              flush_tlb_mask(d->cpuset);
   11.23              break;
   11.24          default:
   11.25 @@ -2173,7 +2176,7 @@ int do_update_va_mapping(unsigned long v
   11.26              local_flush_tlb_one(va);
   11.27              break;
   11.28          case UVMF_ALL:
   11.29 -            BUG_ON(shadow_mode_enabled(d));
   11.30 +            BUG_ON(shadow_mode_enabled(d) && (d->cpuset != (1<<cpu)));
   11.31              flush_tlb_one_mask(d->cpuset, va);
   11.32              break;
   11.33          default:
   11.34 @@ -2391,7 +2394,7 @@ long do_update_descriptor(unsigned long 
   11.35          if ( shadow_mode_log_dirty(dom) )
   11.36              __mark_dirty(dom, mfn);
   11.37  
   11.38 -        if ( page_is_page_table(page) )
   11.39 +        if ( page_is_page_table(page) && !page_out_of_sync(page) )
   11.40              shadow_mark_mfn_out_of_sync(current, gpfn, mfn);
   11.41      }
   11.42  
    12.1 --- a/xen/arch/x86/shadow.c	Mon Apr 11 17:56:17 2005 +0000
    12.2 +++ b/xen/arch/x86/shadow.c	Tue Apr 12 09:48:55 2005 +0000
    12.3 @@ -519,10 +519,10 @@ static void free_shadow_pages(struct dom
    12.4       * e.g., You are expected to have paused the domain and synchronized CR3.
    12.5       */
    12.6  
    12.7 +    if( !d->arch.shadow_ht ) return;
    12.8 +
    12.9      shadow_audit(d, 1);
   12.10  
   12.11 -    if( !d->arch.shadow_ht ) return;
   12.12 -
   12.13      // first, remove any outstanding refs from out_of_sync entries...
   12.14      //
   12.15      free_out_of_sync_state(d);
   12.16 @@ -1673,7 +1673,7 @@ shadow_mark_mfn_out_of_sync(struct exec_
   12.17      ASSERT(pfn_is_ram(mfn));
   12.18      ASSERT((page->u.inuse.type_info & PGT_type_mask) == PGT_writable_page);
   12.19  
   12.20 -    FSH_LOG("mark_mfn_out_of_sync(gpfn=%p, mfn=%p) c=%p t=%p",
   12.21 +    FSH_LOG("%s(gpfn=%p, mfn=%p) c=%p t=%p", __func__,
   12.22              gpfn, mfn, page->count_info, page->u.inuse.type_info);
   12.23  
   12.24      // XXX this will require some more thought...  Cross-domain sharing and
   12.25 @@ -2041,6 +2041,7 @@ u32 shadow_remove_all_access(struct doma
   12.26      u32 count = 0;
   12.27  
   12.28      ASSERT(spin_is_locked(&d->arch.shadow_lock));
   12.29 +    perfc_incrc(remove_all_access);
   12.30  
   12.31      for (i = 0; i < shadow_ht_buckets; i++)
   12.32      {
   12.33 @@ -2632,14 +2633,6 @@ static int check_l1_table(
   12.34      unsigned long *gpl1e, *spl1e;
   12.35      int errors = 0, oos_ptes = 0;
   12.36  
   12.37 -    // First check to see if this guest page is currently the active
   12.38 -    // PTWR page.  If so, then we compare the (old) cached copy of the
   12.39 -    // guest page to the shadow, and not the currently writable (and
   12.40 -    // thus potentially out-of-sync) guest page.
   12.41 -    //
   12.42 -    if ( VM_ASSIST(d, VMASST_TYPE_writable_pagetables) )
   12.43 -        BUG();
   12.44 -
   12.45      if ( page_out_of_sync(pfn_to_page(gmfn)) )
   12.46      {
   12.47          gmfn = __shadow_status(d, gpfn, PGT_snapshot);
   12.48 @@ -2757,7 +2750,7 @@ int _check_pagetable(struct exec_domain 
   12.49      unsigned long ptbase_mfn = 0;
   12.50      int errors = 0, limit, oos_pdes = 0;
   12.51  
   12.52 -    _audit_domain(d, AUDIT_QUIET);
   12.53 +    //_audit_domain(d, AUDIT_QUIET);
   12.54      shadow_lock(d);
   12.55  
   12.56      sh_check_name = s;
    14.1 --- a/xen/include/asm-x86/shadow.h	Mon Apr 11 17:56:17 2005 +0000
    14.2 +++ b/xen/include/asm-x86/shadow.h	Tue Apr 12 09:48:55 2005 +0000
    14.3 @@ -222,11 +222,11 @@ struct out_of_sync_entry {
    14.4  #define SHADOW_SNAPSHOT_ELSEWHERE (-1L)
    14.5  
    14.6  /************************************************************************/
    14.7 -#define SHADOW_DEBUG 1
    14.8 -#define SHADOW_VERBOSE_DEBUG 1
    14.9 -#define SHADOW_VVERBOSE_DEBUG 1
   14.10 -#define SHADOW_HASH_DEBUG 1
   14.11 -#define FULLSHADOW_DEBUG 1
   14.12 +#define SHADOW_DEBUG 0
   14.13 +#define SHADOW_VERBOSE_DEBUG 0
   14.14 +#define SHADOW_VVERBOSE_DEBUG 0
   14.15 +#define SHADOW_HASH_DEBUG 0
   14.16 +#define FULLSHADOW_DEBUG 0
   14.17  
   14.18  #if SHADOW_DEBUG
   14.19  extern int shadow_status_noswap;
   14.20 @@ -1490,14 +1490,18 @@ extern void __update_pagetables(struct e
   14.21  static inline void update_pagetables(struct exec_domain *ed)
   14.22  {
   14.23      struct domain *d = ed->domain;
   14.24 +    int paging_enabled;
   14.25  
   14.26  #ifdef CONFIG_VMX
   14.27 -    int paging_enabled =
   14.28 -        !VMX_DOMAIN(ed) ||
   14.29 -        test_bit(VMX_CPU_STATE_PG_ENABLED, &ed->arch.arch_vmx.cpu_state);
   14.30 -#else
   14.31 -    const int paging_enabled = 1;
   14.32 +    if ( VMX_DOMAIN(ed) )
   14.33 +        paging_enabled =
   14.34 +            test_bit(VMX_CPU_STATE_PG_ENABLED, &ed->arch.arch_vmx.cpu_state);
   14.35 +    else
   14.36  #endif
   14.37 +        // HACK ALERT: there's currently no easy way to figure out if a domU
   14.38 +        // has set its arch.guest_table to zero, vs not yet initialized it.
   14.39 +        //
   14.40 +        paging_enabled = !!pagetable_val(ed->arch.guest_table);
   14.41  
   14.42      /*
   14.43       * We don't call __update_pagetables() when vmx guest paging is
    15.1 --- a/xen/include/xen/perfc_defn.h	Mon Apr 11 17:56:17 2005 +0000
    15.2 +++ b/xen/include/xen/perfc_defn.h	Tue Apr 12 09:48:55 2005 +0000
    15.3 @@ -99,6 +99,7 @@ PERFCOUNTER_CPU(validate_hl2e_calls,    
    15.4  PERFCOUNTER_CPU(validate_hl2e_changes,             "validate_hl2e makes changes")
    15.5  PERFCOUNTER_CPU(exception_fixed,                   "pre-exception fixed")
    15.6  PERFCOUNTER_CPU(gpfn_to_mfn_foreign,               "calls to gpfn_to_mfn_foreign")
    15.7 +PERFCOUNTER_CPU(remove_all_access,                 "calls to remove_all_access")
    15.8  PERFCOUNTER_CPU(remove_write_access,               "calls to remove_write_access")
    15.9  PERFCOUNTER_CPU(remove_write_access_easy,          "easy outs of remove_write_access")
   15.10  PERFCOUNTER_CPU(remove_write_no_work,              "no work in remove_write_access")