Index: xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c =================================================================== --- xen-3.3.1-testing.orig/xen/arch/x86/hvm/hvm.c 2009-02-12 09:23:34.000000000 -0700 +++ xen-3.3.1-testing/xen/arch/x86/hvm/hvm.c 2009-02-12 09:29:19.000000000 -0700 @@ -544,7 +544,25 @@ if ( hvm_funcs.load_cpu_ctxt(v, &ctxt) < 0 ) 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 seg.limit = ctxt.idtr_limit; + seg.base = ctxt.idtr_base; hvm_set_segment_register(v, x86_seg_idtr, &seg);