[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Patch to run a domU in shadow test mode.



ChangeSet 1.1272.1.1, 2005/04/12 10:32:24+01:00, mafetter@xxxxxxxxxxxxxxxx

        Patch to run a domU in shadow test mode.



 linux-2.6.11-xen-sparse/arch/xen/Kconfig                          |    7 ++
 linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32    |    1 
 linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32    |    4 +
 linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c             |    4 +
 linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c                |    2 
 linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h |    5 ++
 linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h        |    9 +++
 linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h              |   15 +++++-
 tools/libxc/xc_linux_build.c                                      |   15 ++++++
 xen/arch/x86/domain.c                                             |   14 ++++-
 xen/arch/x86/mm.c                                                 |   11 ++--
 xen/arch/x86/shadow.c                                             |   17 
++-----
 xen/common/dom_mem_ops.c                                          |    9 ---
 xen/include/asm-x86/shadow.h                                      |   24 
+++++-----
 xen/include/xen/perfc_defn.h                                      |    1 
 15 files changed, 97 insertions(+), 41 deletions(-)


diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/Kconfig 
b/linux-2.6.11-xen-sparse/arch/xen/Kconfig
--- a/linux-2.6.11-xen-sparse/arch/xen/Kconfig  2005-04-13 19:03:07 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/Kconfig  2005-04-13 19:03:07 -04:00
@@ -123,6 +123,13 @@
          to a character device, allowing device prototyping in application
          space.  Odds are that you want to say N here.
 
+config XEN_SHADOW_MODE
+       bool "Fake shadow mode"
+       default n
+    help
+      fakes out a shadow mode kernel
+
+
 config XEN_SCRUB_PAGES
        bool "Scrub memory before freeing it to Xen"
        default y
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 
b/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32
--- a/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32    
2005-04-13 19:03:08 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32    
2005-04-13 19:03:08 -04:00
@@ -14,6 +14,7 @@
 CONFIG_XEN_PHYSDEV_ACCESS=y
 CONFIG_XEN_BLKDEV_BACKEND=y
 # CONFIG_XEN_BLKDEV_TAP_BE is not set
+# CONFIG_XEN_BLKDEV_GRANT is not set
 CONFIG_XEN_NETDEV_BACKEND=y
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32 
b/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32
--- a/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32    
2005-04-13 19:03:08 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32    
2005-04-13 19:03:08 -04:00
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.11-xenU
-# Fri Mar 11 01:20:28 2005
+# Tue Apr  5 16:44:33 2005
 #
 CONFIG_XEN=y
 CONFIG_ARCH_XEN=y
@@ -12,10 +12,12 @@
 #
 # CONFIG_XEN_PRIVILEGED_GUEST is not set
 # CONFIG_XEN_PHYSDEV_ACCESS is not set
+# CONFIG_XEN_BLKDEV_GRANT is not set
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
 # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
 # CONFIG_XEN_BLKDEV_TAP is not set
+CONFIG_XEN_SHADOW_MODE=y
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_X86=y
 # CONFIG_X86_64 is not set
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c 
b/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- a/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c     2005-04-13 
19:03:08 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c     2005-04-13 
19:03:08 -04:00
@@ -48,6 +48,7 @@
 #define pmd_val_ma(v) (v).pud.pgd.pgd;
 #endif
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 void xen_l1_entry_update(pte_t *ptr, unsigned long val)
 {
     mmu_update_t u;
@@ -63,6 +64,7 @@
     u.val = pmd_val_ma(val);
     BUG_ON(HYPERVISOR_mmu_update(&u, 1, NULL, DOMID_SELF) < 0);
 }
+#endif
 
 void xen_machphys_update(unsigned long mfn, unsigned long pfn)
 {
@@ -131,6 +133,7 @@
 
 #endif /* CONFIG_SMP */
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 void xen_pgd_pin(unsigned long ptr)
 {
     struct mmuext_op op;
@@ -162,6 +165,7 @@
     op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
     BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
+#endif
 
 void xen_set_ldt(unsigned long ptr, unsigned long len)
 {
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c 
b/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c
--- a/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c        2005-04-13 
19:03:08 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c        2005-04-13 
19:03:08 -04:00
@@ -366,6 +366,7 @@
        kmem_cache_free(pgd_cache, pgd);
 }
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 void make_lowmem_page_readonly(void *va)
 {
        pgd_t *pgd = pgd_offset_k((unsigned long)va);
@@ -437,3 +438,4 @@
                va = (void *)((unsigned long)va + PAGE_SIZE);
        }
 }
+#endif /* CONFIG_XEN_SHADOW_MODE */
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h 
2005-04-13 19:03:08 -04:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h 
2005-04-13 19:03:08 -04:00
@@ -15,7 +15,12 @@
  */
 #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
 #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
+
+#ifndef CONFIG_XEN_SHADOW_MODE
 #define set_pmd(pmdptr, pmdval) xen_l2_entry_update((pmdptr), (pmdval))
+#else
+#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
+#endif
 
 #define ptep_get_and_clear(xp) __pte_ma(xchg(&(xp)->pte_low, 0))
 #define pte_same(a, b)         ((a).pte_low == (b).pte_low)
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h        
2005-04-13 19:03:08 -04:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h        
2005-04-13 19:03:08 -04:00
@@ -432,12 +432,21 @@
        }                                                               \
 } while (0)
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 void make_lowmem_page_readonly(void *va);
 void make_lowmem_page_writable(void *va);
 void make_page_readonly(void *va);
 void make_page_writable(void *va);
 void make_pages_readonly(void *va, unsigned int nr);
 void make_pages_writable(void *va, unsigned int nr);
+#else
+#define make_lowmem_page_readonly(_va) ((void)0)
+#define make_lowmem_page_writable(_va) ((void)0)
+#define make_page_readonly(_va)        ((void)0)
+#define make_page_writable(_va)        ((void)0)
+#define make_pages_readonly(_va, _nr)  ((void)0)
+#define make_pages_writable(_va, _nr)  ((void)0)
+#endif
 
 #define arbitrary_virt_to_machine(__va)                                        
\
 ({                                                                     \
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h 
b/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h      2005-04-13 
19:03:07 -04:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h      2005-04-13 
19:03:07 -04:00
@@ -71,15 +71,26 @@
  * be MACHINE addresses.
  */
 
-void xen_l1_entry_update(pte_t *ptr, unsigned long val);
-void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
 void xen_pt_switch(unsigned long ptr);
 void xen_tlb_flush(void);
 void xen_invlpg(unsigned long ptr);
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+void xen_l1_entry_update(pte_t *ptr, unsigned long val);
+void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
 void xen_pgd_pin(unsigned long ptr);
 void xen_pgd_unpin(unsigned long ptr);
 void xen_pte_pin(unsigned long ptr);
 void xen_pte_unpin(unsigned long ptr);
+#else
+#define xen_l1_entry_update(_p, _v) set_pte((_p), (pte_t){(_v)})
+#define xen_l2_entry_update(_p, _v) set_pgd((_p), (pgd_t){(_v)})
+#define xen_pgd_pin(_p)   ((void)0)
+#define xen_pgd_unpin(_p) ((void)0)
+#define xen_pte_pin(_p)   ((void)0)
+#define xen_pte_unpin(_p) ((void)0)
+#endif
+
 void xen_set_ldt(unsigned long ptr, unsigned long bytes);
 void xen_machphys_update(unsigned long mfn, unsigned long pfn);
 
diff -Nru a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      2005-04-13 19:03:08 -04:00
+++ b/tools/libxc/xc_linux_build.c      2005-04-13 19:03:08 -04:00
@@ -210,9 +210,11 @@
         }
 
         *vl1e = (page_array[count] << PAGE_SHIFT) | L1_PROT;
+#if !(1 || defined(GROSS_HACK_TO_TEST_SHADOW_MODE_CLIENTS))
         if ( (count >= ((vpt_start-dsi.v_start)>>PAGE_SHIFT)) && 
              (count <  ((vpt_end  -dsi.v_start)>>PAGE_SHIFT)) )
             *vl1e &= ~_PAGE_RW;
+#endif
         vl1e++;
     }
     munmap(vl1tab, PAGE_SIZE);
@@ -243,12 +245,25 @@
     }
     munmap(physmap, PAGE_SIZE);
     
+#if 1 || defined(GROSS_HACK_TO_TEST_SHADOW_MODE_CLIENTS)
+    {
+        int ret;
+        ret = xc_shadow_control(xc_handle, dom,
+                                DOM0_SHADOW_CONTROL_OP_ENABLE_TEST,
+                                NULL, 0, NULL);
+        if ( !ret )
+            ERROR("enabling shadow test mode failed\n");
+    }
+#endif
+
     /*
      * Pin down l2tab addr as page dir page - causes hypervisor to provide
      * correct protection for the page
      */ 
+#if !(1 || defined(GROSS_HACK_TO_TEST_SHADOW_MODE_CLIENTS))
     if ( pin_table(xc_handle, MMUEXT_PIN_L2_TABLE, l2tab>>PAGE_SHIFT, dom) )
         goto error_out;
+#endif
 
     start_info = xc_map_foreign_range(
         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
diff -Nru a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     2005-04-13 19:03:07 -04:00
+++ b/xen/arch/x86/domain.c     2005-04-13 19:03:08 -04:00
@@ -440,9 +440,17 @@
     phys_basetab = c->pt_base;
     ed->arch.guest_table = mk_pagetable(phys_basetab);
 
-    if ( !get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], d, 
-                            PGT_base_page_table) )
-        return -EINVAL;
+    if ( shadow_mode_enabled(d) )
+    {
+        if ( !get_page(&frame_table[phys_basetab>>PAGE_SHIFT], d) )
+            return -EINVAL;
+    }
+    else
+    {
+        if ( !get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], d, 
+                                PGT_base_page_table) )
+            return -EINVAL;
+    }
 
     /* Failure to set GDT is harmless. */
     SET_GDT_ENTRIES(ed, DEFAULT_GDT_ENTRIES);
diff -Nru a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c 2005-04-13 19:03:08 -04:00
+++ b/xen/arch/x86/mm.c 2005-04-13 19:03:08 -04:00
@@ -1897,8 +1897,11 @@
                         gpfn = __mfn_to_gpfn(d, mfn);
                         ASSERT(VALID_M2P(gpfn));
 
-                        if ( page_is_page_table(page) )

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.