ia64/xen-unstable

changeset 13312:973e4d233461

Support for save and restore of compatibility guests

Signed-off-by: Emmanuel Ackaouy <ack@xensource.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Fri Jan 05 17:34:43 2007 +0000 (2007-01-05)
parents 96dacd72fdbe
children 1b7ebd25fa40
files tools/libxc/xc_linux_save.c tools/libxc/xg_save_restore.h xen/arch/x86/domctl.c xen/include/asm-x86/x86_64/page.h
line diff
     1.1 --- a/tools/libxc/xc_linux_save.c	Fri Jan 05 17:34:41 2007 +0000
     1.2 +++ b/tools/libxc/xc_linux_save.c	Fri Jan 05 17:34:43 2007 +0000
     1.3 @@ -44,6 +44,7 @@ static xen_pfn_t *live_p2m = NULL;
     1.4  
     1.5  /* Live mapping of system MFN to PFN table. */
     1.6  static xen_pfn_t *live_m2p = NULL;
     1.7 +static unsigned long m2p_mfn0;
     1.8  
     1.9  /* grep fodder: machine_to_phys */
    1.10  
    1.11 @@ -440,13 +441,23 @@ static int canonicalize_pagetable(unsign
    1.12      ** that this check will fail for other L2s.
    1.13      */
    1.14      if (pt_levels == 3 && type == XEN_DOMCTL_PFINFO_L2TAB) {
    1.15 +        int hstart;
    1.16 +        unsigned long he;
    1.17  
    1.18 -/* XXX index of the L2 entry in PAE mode which holds the guest LPT */
    1.19 -#define PAE_GLPT_L2ENTRY (495)
    1.20 -        pte = ((const uint64_t*)spage)[PAE_GLPT_L2ENTRY];
    1.21 +        hstart = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
    1.22 +        he = ((const uint64_t *) spage)[hstart];
    1.23  
    1.24 -        if(((pte >> PAGE_SHIFT) & 0x0fffffff) == live_p2m[pfn])
    1.25 -            xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
    1.26 +        if ( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 ) {
    1.27 +            /* hvirt starts with xen stuff... */
    1.28 +            xen_start = hstart;
    1.29 +        } else if ( hvirt_start != 0xf5800000 ) {
    1.30 +            /* old L2s from before hole was shrunk... */
    1.31 +            hstart = (0xf5800000 >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
    1.32 +            he = ((const uint64_t *) spage)[hstart];
    1.33 +
    1.34 +            if( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 )
    1.35 +                xen_start = hstart;
    1.36 +        }
    1.37      }
    1.38  
    1.39      if (pt_levels == 4 && type == XEN_DOMCTL_PFINFO_L4TAB) {
    1.40 @@ -550,6 +561,8 @@ static xen_pfn_t *xc_map_m2p(int xc_hand
    1.41          return NULL;
    1.42      }
    1.43  
    1.44 +    m2p_mfn0 = entries[0].mfn;
    1.45 +
    1.46      free(extent_start);
    1.47      free(entries);
    1.48  
     2.1 --- a/tools/libxc/xg_save_restore.h	Fri Jan 05 17:34:41 2007 +0000
     2.2 +++ b/tools/libxc/xg_save_restore.h	Fri Jan 05 17:34:43 2007 +0000
     2.3 @@ -53,8 +53,17 @@ static int get_platform_info(int xc_hand
     2.4  
     2.5      *hvirt_start = xen_params.virt_start;
     2.6  
     2.7 +    /*
     2.8 +     * XXX For now, 32bit dom0's can only save/restore 32bit domUs
     2.9 +     * on 64bit hypervisors, so no need to check which type of domain
    2.10 +     * we're dealing with.
    2.11 +     */
    2.12      if (strstr(xen_caps, "xen-3.0-x86_64"))
    2.13 +#if defined(__i386__)
    2.14 +        *pt_levels = 3;
    2.15 +#else
    2.16          *pt_levels = 4;
    2.17 +#endif
    2.18      else if (strstr(xen_caps, "xen-3.0-x86_32p"))
    2.19          *pt_levels = 3;
    2.20      else if (strstr(xen_caps, "xen-3.0-x86_32"))
     3.1 --- a/xen/arch/x86/domctl.c	Fri Jan 05 17:34:41 2007 +0000
     3.2 +++ b/xen/arch/x86/domctl.c	Fri Jan 05 17:34:43 2007 +0000
     3.3 @@ -356,7 +356,10 @@ void arch_get_info_guest(struct vcpu *v,
     3.4          c.nat->ctrlreg[3] = xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table));
     3.5  #ifdef CONFIG_COMPAT
     3.6      else
     3.7 -        c.cmp->ctrlreg[3] = compat_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table));
     3.8 +    {
     3.9 +        l4_pgentry_t *l4e = __va(pagetable_get_paddr(v->arch.guest_table));
    3.10 +        c.cmp->ctrlreg[3] = compat_pfn_to_cr3(l4e_get_pfn(*l4e));
    3.11 +    }
    3.12  #endif
    3.13  
    3.14      c(vm_assist = v->domain->vm_assist);
     4.1 --- a/xen/include/asm-x86/x86_64/page.h	Fri Jan 05 17:34:41 2007 +0000
     4.2 +++ b/xen/include/asm-x86/x86_64/page.h	Fri Jan 05 17:34:43 2007 +0000
     4.3 @@ -96,7 +96,7 @@ typedef l4_pgentry_t root_pgentry_t;
     4.4  #define L3_DISALLOW_MASK (BASE_DISALLOW_MASK | 0x180U /* must-be-zero */)
     4.5  #define L4_DISALLOW_MASK (BASE_DISALLOW_MASK | 0x180U /* must-be-zero */)
     4.6  
     4.7 -#define COMPAT_L3_DISALLOW_MASK 0xFFFFF1E6U /* must-be-zero */
     4.8 +#define COMPAT_L3_DISALLOW_MASK L3_DISALLOW_MASK
     4.9  
    4.10  #define PAGE_HYPERVISOR         (__PAGE_HYPERVISOR         | _PAGE_GLOBAL)
    4.11  #define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | _PAGE_GLOBAL)