All of lore.kernel.org
 help / color / mirror / Atom feed
* save/restore compatibility broken
@ 2009-02-12 13:39 Zhai, Edwin
  2009-02-12 13:45 ` [PATCH] Handle older Xen save files where arbytes are in the wrong format Tim Deegan
  0 siblings, 1 reply; 7+ messages in thread
From: Zhai, Edwin @ 2009-02-12 13:39 UTC (permalink / raw)
  To: Keir.Fraser; +Cc: xen-devel, Zhai, Edwin

Keir,
 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?

Thanks,
edwin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Handle older Xen save files where arbytes are in the wrong format.
  2009-02-12 13:39 save/restore compatibility broken Zhai, Edwin
@ 2009-02-12 13:45 ` Tim Deegan
  2009-02-12 18:04   ` John Levon
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Deegan @ 2009-02-12 13:45 UTC (permalink / raw)
  To: Zhai, Edwin; +Cc: Keir.Fraser@cl.cam.ac.uk, xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

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 <Tim.Deegan@citrix.com>


[-- Attachment #2: old-arbytes --]
[-- Type: text/plain, Size: 1034 bytes --]

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 )

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
  2009-02-12 13:45 ` [PATCH] Handle older Xen save files where arbytes are in the wrong format Tim Deegan
@ 2009-02-12 18:04   ` John Levon
  2009-02-12 18:17     ` Keir Fraser
  0 siblings, 1 reply; 7+ messages in thread
From: John Levon @ 2009-02-12 18:04 UTC (permalink / raw)
  To: Tim Deegan
  Cc: Keir.Fraser@cl.cam.ac.uk, xen-devel@lists.xensource.com,
	Zhai, Edwin

On Thu, Feb 12, 2009 at 01:45:50PM +0000, Tim Deegan wrote:

> Yes -- sorry, I thought I'd already sent this patch. 

What happens with a new-format image on an old Xen?

regards
john

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
  2009-02-12 18:04   ` John Levon
@ 2009-02-12 18:17     ` Keir Fraser
  2009-02-12 18:20       ` John Levon
  0 siblings, 1 reply; 7+ messages in thread
From: Keir Fraser @ 2009-02-12 18:17 UTC (permalink / raw)
  To: John Levon, Tim Deegan
  Cc: Keir.Fraser@cl.cam.ac.uk, xen-devel@lists.xensource.com,
	Zhai, Edwin

On 12/02/2009 18:04, "John Levon" <levon@movementarian.org> wrote:

> On Thu, Feb 12, 2009 at 01:45:50PM +0000, Tim Deegan wrote:
> 
>> Yes -- sorry, I thought I'd already sent this patch.
> 
> What happens with a new-format image on an old Xen?

Doesn't work, but we don't support that anyway. You'd be scuppered by
various other save-format upgrades quite apart from this unintentional one.

 -- Keir

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
  2009-02-12 18:17     ` Keir Fraser
@ 2009-02-12 18:20       ` John Levon
  2009-02-12 18:41         ` Keir Fraser
  0 siblings, 1 reply; 7+ messages in thread
From: John Levon @ 2009-02-12 18:20 UTC (permalink / raw)
  To: Keir Fraser
  Cc: Tim Deegan, Keir.Fraser@cl.cam.ac.uk,
	xen-devel@lists.xensource.com, Zhai, Edwin

On Thu, Feb 12, 2009 at 06:17:04PM +0000, Keir Fraser wrote:

> > On Thu, Feb 12, 2009 at 01:45:50PM +0000, Tim Deegan wrote:
> > 
> >> Yes -- sorry, I thought I'd already sent this patch.
> > 
> > What happens with a new-format image on an old Xen?
> 
> Doesn't work

Sure, but doesn't work how? There's a world of difference between
"crashes mysteriously" and "useful error message".

regards,
john

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
  2009-02-12 18:20       ` John Levon
@ 2009-02-12 18:41         ` Keir Fraser
  2009-02-13  9:18           ` Tim Deegan
  0 siblings, 1 reply; 7+ messages in thread
From: Keir Fraser @ 2009-02-12 18:41 UTC (permalink / raw)
  To: John Levon
  Cc: Tim Deegan, Keir.Fraser@cl.cam.ac.uk,
	xen-devel@lists.xensource.com, Zhai, Edwin

On 12/02/2009 18:20, "John Levon" <levon@movementarian.org> wrote:

>>> What happens with a new-format image on an old Xen?
>> 
>> Doesn't work
> 
> Sure, but doesn't work how? There's a world of difference between
> "crashes mysteriously" and "useful error message".

Mmm.. Most of the changes will cause restore failure rather than apparently
successful restore but you end up with a broken guest. I suppose this
segmentation change may act like the latter. I don't think there's been much
conscious effort to make new-on-old fail cleanly though.

 -- Keir

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
  2009-02-12 18:41         ` Keir Fraser
@ 2009-02-13  9:18           ` Tim Deegan
  0 siblings, 0 replies; 7+ messages in thread
From: Tim Deegan @ 2009-02-13  9:18 UTC (permalink / raw)
  To: Keir Fraser
  Cc: Keir.Fraser@cl.cam.ac.uk, xen-devel@lists.xensource.com,
	Zhai, Edwin, John Levon

At 13:41 -0500 on 12 Feb (1234446081), Keir Fraser wrote:
> On 12/02/2009 18:20, "John Levon" <levon@movementarian.org> wrote:
> 
> >>> What happens with a new-format image on an old Xen?
> >> 
> >> Doesn't work
> > 
> > Sure, but doesn't work how? There's a world of difference between
> > "crashes mysteriously" and "useful error message".
> 
> Mmm.. Most of the changes will cause restore failure rather than apparently
> successful restore but you end up with a broken guest. I suppose this
> segmentation change may act like the latter. I don't think there's been much
> conscious effort to make new-on-old fail cleanly though.

There is some code in there that checks that the changeset of Xen is the
same as the one the image was saved on -- it only works if hg was
available when Xen was built, and is certainly too strict.  It could be
replaced with something more useful like the Xen version number. 

Tim.

-- 
Tim Deegan <Tim.Deegan@citrix.com>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-13  9:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-12 13:39 save/restore compatibility broken Zhai, Edwin
2009-02-12 13:45 ` [PATCH] Handle older Xen save files where arbytes are in the wrong format Tim Deegan
2009-02-12 18:04   ` John Levon
2009-02-12 18:17     ` Keir Fraser
2009-02-12 18:20       ` John Levon
2009-02-12 18:41         ` Keir Fraser
2009-02-13  9:18           ` Tim Deegan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.