--- xen-3.1.1-ovs/xen/include/public/foreign/structs.py.orig 2007-10-11 15:29:50.000000000 -0700 +++ xen-3.1.1-ovs/xen/include/public/foreign/structs.py 2007-10-11 15:28:29.000000000 -0700 @@ -49,6 +49,7 @@ defines = [ "__i386__", # all archs "xen_pfn_to_cr3", + "xen_cr3_to_pfn", "MAX_VIRT_CPUS", "MAX_GUEST_CMDLINE" ]; --- xen-3.1.1-ovs/tools/libxc/xc_domain_save.c.orig 2007-10-11 15:34:07.000000000 -0700 +++ xen-3.1.1-ovs/tools/libxc/xc_domain_save.c 2007-10-11 15:35:29.000000000 -0700 @@ -1604,32 +1604,50 @@ int xc_domain_save(int xc_handle, int io SET_FIELD(&ctxt, gdt_frames[j], mfn_to_pfn(mfn)); } - /* Canonicalise the page table base pointer. */ - if ( !MFN_IS_IN_PSEUDOPHYS_MAP(xen_cr3_to_pfn( - GET_FIELD(&ctxt, ctrlreg[3]))) ) - { - ERROR("PT base is not in range of pseudophys map"); - goto out; - } - SET_FIELD(&ctxt, ctrlreg[3], - xen_pfn_to_cr3( - mfn_to_pfn( - xen_cr3_to_pfn( - GET_FIELD(&ctxt, ctrlreg[3]))))); + if (guest_width == 8) + { + /* Canonicalise the page table base pointer. */ + if ( !MFN_IS_IN_PSEUDOPHYS_MAP(xen_cr3_to_pfn_x86_64( + GET_FIELD(&ctxt, ctrlreg[3]))) ) + { + ERROR("cr3 PT base is not in range of pseudophys map"); + goto out; + } + SET_FIELD(&ctxt, ctrlreg[3], + xen_pfn_to_cr3_x86_64( + mfn_to_pfn( + xen_cr3_to_pfn_x86_64( + GET_FIELD(&ctxt, ctrlreg[3]))))); + } + else + { + /* Canonicalise the page table base pointer. */ + if ( !MFN_IS_IN_PSEUDOPHYS_MAP(xen_cr3_to_pfn_x86_32( + GET_FIELD(&ctxt, ctrlreg[3]))) ) + { + ERROR("cr3 PT base is not in range of pseudophys map"); + goto out; + } + SET_FIELD(&ctxt, ctrlreg[3], + xen_pfn_to_cr3_x86_32( + mfn_to_pfn( + xen_cr3_to_pfn_x86_32( + GET_FIELD(&ctxt, ctrlreg[3]))))); + } /* Guest pagetable (x86/64) stored in otherwise-unused CR1. */ if ( (pt_levels == 4) && ctxt.x64.ctrlreg[1] ) { if ( !MFN_IS_IN_PSEUDOPHYS_MAP( - xen_cr3_to_pfn(ctxt.x64.ctrlreg[1])) ) + xen_cr3_to_pfn_x86_64(ctxt.x64.ctrlreg[1])) ) { - ERROR("PT base is not in range of pseudophys map"); + ERROR("cr1 PT base is not in range of pseudophys map"); goto out; } /* Least-significant bit means 'valid PFN'. */ ctxt.x64.ctrlreg[1] = 1 | - xen_pfn_to_cr3( - mfn_to_pfn(xen_cr3_to_pfn(ctxt.x64.ctrlreg[1]))); + xen_pfn_to_cr3_x86_64( + mfn_to_pfn(xen_cr3_to_pfn_x86_64(ctxt.x64.ctrlreg[1]))); } if ( !write_exact(io_fd, &ctxt, ((guest_width==8) --- xen-3.1.1-ovs/tools/libxc/xc_domain_restore.c.orig 2007-10-11 16:06:05.000000000 -0700 +++ xen-3.1.1-ovs/tools/libxc/xc_domain_restore.c 2007-10-11 16:06:09.000000000 -0700 @@ -32,6 +32,16 @@ #include #include +#define xen_cr3_to_pfn_either(cr3) \ + (guest_width==8 ? \ + xen_cr3_to_pfn_x86_64(cr3) : \ + xen_cr3_to_pfn_x86_32(cr3)) + +#define xen_pfn_to_cr3_either(pfn) \ + (guest_width==8 ? \ + xen_pfn_to_cr3_x86_64(pfn) : \ + xen_pfn_to_cr3_x86_32(pfn)) + /* max mfn of the current host machine */ static unsigned long max_mfn; @@ -1050,7 +1060,7 @@ int xc_domain_restore(int xc_handle, int SET_FIELD(&ctxt, gdt_frames[j], p2m[pfn]); } /* Uncanonicalise the page table base pointer. */ - pfn = xen_cr3_to_pfn(GET_FIELD(&ctxt, ctrlreg[3])); + pfn = xen_cr3_to_pfn_either(GET_FIELD(&ctxt, ctrlreg[3])); if ( pfn >= p2m_size ) { @@ -1067,12 +1077,12 @@ int xc_domain_restore(int xc_handle, int (unsigned long)pt_levels<= p2m_size ) { ERROR("User PT base is bad: pfn=%lu p2m_size=%lu", @@ -1087,7 +1097,7 @@ int xc_domain_restore(int xc_handle, int (unsigned long)pt_levels<