save/restore compatibility broken
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
PATCH 1/1 Handle older Xen save files where arbytes are in the wrong format.
Quoted 10 lines · Edwin
From r17037, hvm_{get|set}_segment_register are used to save/restore
the VMCS segment register. But they introduce new compat image format forxx_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_arbytesis not zero, and then translate it?
Yes -- sorry, I thought I'd already sent this patch.
xen/arch/x86/hvm/hvm.c +16 -0
@@ -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 )
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
Quoted 1 line · Tim Deegan
Yes -- sorry, I thought I'd already sent this patch.
What happens with a new-format image on an old Xen?
regards
john
Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
Quoted 5 lines · John Levon
Quoted 1 line · Tim Deegan
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
Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
Quoted 7 lines · Keir Fraser
Quoted 5 lines · Tim Deegan
Quoted 2 lines
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
Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
Quoted 6 lines · John Levon
Quoted 3 lines
Quoted 1 line
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
Re: [PATCH] Handle older Xen save files where arbytes are in the wrong format.
Quoted 6 lines · Keir Fraser
Quoted 4 lines · John Levon
Quoted 3 lines
Quoted 1 line
What happens with a new-format image on an old Xen?
Doesn't work
Quoted 7 lines
Quoted 2 lines
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.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]