File 19204-allow-old-images-restore.patch of Package xen
# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1235129639 0
# Node ID 7c52b7c980686ebc6e4263d0e19751fcbcaffe2b
# Parent 6f7000810e594e14735197036ce3a1bdd381a018
x86 hvm: Allow restore of old images with different segment attribute format.
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
xen-unstable changeset: 19204:e6f1c66874d55fcf76ebdd4130ba55a3c8952b55
xen-unstable date: Fri Feb 13 09:29:52 2009 +0000
Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c
===================================================================
--- xen-3.3.1-testing.orig/xen/arch/x86/hvm/hvm.c
+++ xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c
@@ -538,6 +538,22 @@ static int hvm_load_cpu_ctxt(struct doma
return -EINVAL;
}
+ /* Older Xen versions used to save the segment arbytes directly
+ * from the VMCS on Intel hosts. Detect this and rearrange them
+ * into the struct segment_register format. */
+#define UNFOLD_ARBYTES(_r) \
+ if ( (_r & 0xf000) && !(_r & 0x0f00) ) \
+ _r = ((_r & 0xff) | ((_r >> 4) & 0xf00))
+ UNFOLD_ARBYTES(ctxt.cs_arbytes);
+ UNFOLD_ARBYTES(ctxt.ds_arbytes);
+ UNFOLD_ARBYTES(ctxt.es_arbytes);
+ UNFOLD_ARBYTES(ctxt.fs_arbytes);
+ UNFOLD_ARBYTES(ctxt.gs_arbytes);
+ UNFOLD_ARBYTES(ctxt.ss_arbytes);
+ UNFOLD_ARBYTES(ctxt.tr_arbytes);
+ UNFOLD_ARBYTES(ctxt.ldtr_arbytes);
+#undef UNFOLD_ARBYTES
+
/* Architecture-specific vmcs/vmcb bits */
if ( hvm_funcs.load_cpu_ctxt(v, &ctxt) < 0 )
return -EINVAL;