From: Tim Deegan Subject: [PATCH] Handle older Xen save files where arbytes are in the wrong format. Date: Thu, 12 Feb 2009 13:45:50 +0000 Message-ID: <20090212134550.GA17060@york.uk.xensource.com> References: <4994267D.5020903@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0OAP2g/MAC+5xKAE" Return-path: Content-Disposition: inline In-Reply-To: <4994267D.5020903@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "Zhai, Edwin" Cc: "Keir.Fraser@cl.cam.ac.uk" , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --0OAP2g/MAC+5xKAE Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline At 08:39 -0500 on 12 Feb (1234427949), Zhai, Edwin wrote: > From r17037, hvm_{get|set}_segment_register are used to save/restore > the VMCS segment register. But they introduce new compat image format > for xx_arbytes, i.e. > reg->attr.bytes = (attr & 0xff) | ((attr >> 4) & 0xf00); > > This caused wrong VMCS setting for arbytes when restore old image on > new changeset. > > How to fix it? Can we determine it's old format if bit 12~15 of > cs_arbytes is not zero, and then translate it? Yes -- sorry, I thought I'd already sent this patch. Signed-off-by: Tim Deegan --0OAP2g/MAC+5xKAE Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: attachment; filename=old-arbytes diff -r ba2dc1c221fe xen/arch/x86/hvm/hvm.c --- a/xen/arch/x86/hvm/hvm.c Wed Feb 04 16:37:30 2009 +0000 +++ b/xen/arch/x86/hvm/hvm.c Thu Feb 12 13:43:33 2009 +0000 @@ -541,6 +541,22 @@ ctxt.msr_efer); 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 ) --0OAP2g/MAC+5xKAE Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --0OAP2g/MAC+5xKAE--