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

[Xen-changelog] [xen-unstable] Support for save and restore of compatibility guests



# HG changeset patch
# User Emmanuel Ackaouy <ack@xxxxxxxxxxxxx>
# Date 1168018483 0
# Node ID 973e4d23346142ecb525ecc6eb6c587ef3df4bee
# Parent  96dacd72fdbefc2595e54f4ea1d4f1de1261cad0
Support for save and restore of compatibility guests

Signed-off-by: Emmanuel Ackaouy <ack@xxxxxxxxxxxxx>
---
 tools/libxc/xc_linux_save.c       |   27 ++++++++++++++++++++-------
 tools/libxc/xg_save_restore.h     |    9 +++++++++
 xen/arch/x86/domctl.c             |    5 ++++-
 xen/include/asm-x86/x86_64/page.h |    2 +-
 4 files changed, 34 insertions(+), 9 deletions(-)

diff -r 96dacd72fdbe -r 973e4d233461 tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c       Fri Jan 05 17:34:41 2007 +0000
+++ b/tools/libxc/xc_linux_save.c       Fri Jan 05 17:34:43 2007 +0000
@@ -44,6 +44,7 @@ static xen_pfn_t *live_p2m = NULL;
 
 /* Live mapping of system MFN to PFN table. */
 static xen_pfn_t *live_m2p = NULL;
+static unsigned long m2p_mfn0;
 
 /* grep fodder: machine_to_phys */
 
@@ -440,13 +441,23 @@ static int canonicalize_pagetable(unsign
     ** that this check will fail for other L2s.
     */
     if (pt_levels == 3 && type == XEN_DOMCTL_PFINFO_L2TAB) {
-
-/* XXX index of the L2 entry in PAE mode which holds the guest LPT */
-#define PAE_GLPT_L2ENTRY (495)
-        pte = ((const uint64_t*)spage)[PAE_GLPT_L2ENTRY];
-
-        if(((pte >> PAGE_SHIFT) & 0x0fffffff) == live_p2m[pfn])
-            xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
+        int hstart;
+        unsigned long he;
+
+        hstart = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
+        he = ((const uint64_t *) spage)[hstart];
+
+        if ( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 ) {
+            /* hvirt starts with xen stuff... */
+            xen_start = hstart;
+        } else if ( hvirt_start != 0xf5800000 ) {
+            /* old L2s from before hole was shrunk... */
+            hstart = (0xf5800000 >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
+            he = ((const uint64_t *) spage)[hstart];
+
+            if( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 )
+                xen_start = hstart;
+        }
     }
 
     if (pt_levels == 4 && type == XEN_DOMCTL_PFINFO_L4TAB) {
@@ -549,6 +560,8 @@ static xen_pfn_t *xc_map_m2p(int xc_hand
         ERROR("xc_mmap_foreign_ranges failed (rc = %d)", rc);
         return NULL;
     }
+
+    m2p_mfn0 = entries[0].mfn;
 
     free(extent_start);
     free(entries);
diff -r 96dacd72fdbe -r 973e4d233461 tools/libxc/xg_save_restore.h
--- a/tools/libxc/xg_save_restore.h     Fri Jan 05 17:34:41 2007 +0000
+++ b/tools/libxc/xg_save_restore.h     Fri Jan 05 17:34:43 2007 +0000
@@ -53,8 +53,17 @@ static int get_platform_info(int xc_hand
 
     *hvirt_start = xen_params.virt_start;
 
+    /*
+     * XXX For now, 32bit dom0's can only save/restore 32bit domUs
+     * on 64bit hypervisors, so no need to check which type of domain
+     * we're dealing with.
+     */
     if (strstr(xen_caps, "xen-3.0-x86_64"))
+#if defined(__i386__)
+        *pt_levels = 3;
+#else
         *pt_levels = 4;
+#endif
     else if (strstr(xen_caps, "xen-3.0-x86_32p"))
         *pt_levels = 3;
     else if (strstr(xen_caps, "xen-3.0-x86_32"))
diff -r 96dacd72fdbe -r 973e4d233461 xen/arch/x86/domctl.c
--- a/xen/arch/x86/domctl.c     Fri Jan 05 17:34:41 2007 +0000
+++ b/xen/arch/x86/domctl.c     Fri Jan 05 17:34:43 2007 +0000
@@ -356,7 +356,10 @@ void arch_get_info_guest(struct vcpu *v,
         c.nat->ctrlreg[3] = 
xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table));
 #ifdef CONFIG_COMPAT
     else
-        c.cmp->ctrlreg[3] = 
compat_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table));
+    {
+        l4_pgentry_t *l4e = __va(pagetable_get_paddr(v->arch.guest_table));
+        c.cmp->ctrlreg[3] = compat_pfn_to_cr3(l4e_get_pfn(*l4e));
+    }
 #endif
 
     c(vm_assist = v->domain->vm_assist);
diff -r 96dacd72fdbe -r 973e4d233461 xen/include/asm-x86/x86_64/page.h
--- a/xen/include/asm-x86/x86_64/page.h Fri Jan 05 17:34:41 2007 +0000
+++ b/xen/include/asm-x86/x86_64/page.h Fri Jan 05 17:34:43 2007 +0000
@@ -96,7 +96,7 @@ typedef l4_pgentry_t root_pgentry_t;
 #define L3_DISALLOW_MASK (BASE_DISALLOW_MASK | 0x180U /* must-be-zero */)
 #define L4_DISALLOW_MASK (BASE_DISALLOW_MASK | 0x180U /* must-be-zero */)
 
-#define COMPAT_L3_DISALLOW_MASK 0xFFFFF1E6U /* must-be-zero */
+#define COMPAT_L3_DISALLOW_MASK L3_DISALLOW_MASK
 
 #define PAGE_HYPERVISOR         (__PAGE_HYPERVISOR         | _PAGE_GLOBAL)
 #define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | _PAGE_GLOBAL)

_______________________________________________
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®.