All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hvm: live migration between intel and amd
@ 2008-06-13 15:46 Jean Guyader
  2008-06-13 16:08 ` Keir Fraser
  0 siblings, 1 reply; 3+ messages in thread
From: Jean Guyader @ 2008-06-13 15:46 UTC (permalink / raw)
  To: xen-devel

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

Hi,


This patch is to enable live migration (save/restore) between intel and 
amd processor. We need to downgrade the cpuid to make it look like a P3.

The downgrading don't induce any huge performance impacts (enclosed 
graphs of ddk build on windows 2k3, build -c -ZPM 3).

Please try it by yourself to give me some feedback.

Regards,

-- 
Jean Guyader

[-- Attachment #2: live_migration_amd_intel.png --]
[-- Type: image/png, Size: 12011 bytes --]

[-- Attachment #3: live_migration_amd_intel.patch --]
[-- Type: text/plain, Size: 758 bytes --]

diff -r ec56331c056a xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c	Thu Jun 12 16:34:25 2008 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Jun 13 16:40:30 2008 +0100
@@ -614,6 +614,23 @@ static void vmx_load_cpu_state(struct vc
 {
 #ifdef __x86_64__
     struct vmx_msr_state *guest_state = &v->arch.hvm_vmx.msr_state;
+
+    /* Do we come from AMD processor ? */
+    if ( data->msr_flags == -1ULL )
+    {
+        data->msr_flags = 0x7ULL;
+
+        data->ldtr_limit = 0xffffffff;
+        data->ldtr_arbytes = 0xc00;
+
+        data->cs_arbytes = 0xc9b;
+
+        data->gs_limit = 0xffffffff;
+        data->gs_arbytes = 0xc00;
+
+        data->tr_arbytes = 0x8b;
+    }
+
 
     /* restore msrs */
     guest_state->flags = data->msr_flags;

[-- Attachment #4: 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] 3+ messages in thread

* Re: [PATCH] hvm: live migration between intel and amd
  2008-06-13 15:46 [PATCH] hvm: live migration between intel and amd Jean Guyader
@ 2008-06-13 16:08 ` Keir Fraser
  2008-06-16 13:32   ` Jean Guyader
  0 siblings, 1 reply; 3+ messages in thread
From: Keir Fraser @ 2008-06-13 16:08 UTC (permalink / raw)
  To: Jean Guyader, xen-devel

On 13/6/08 16:46, "Jean Guyader" <jean.guyader@eu.citrix.com> wrote:

> +    /* Do we come from AMD processor ? */
> +    if ( data->msr_flags == -1ULL )
> +    {
> +        data->msr_flags = 0x7ULL;
> +
> +        data->ldtr_limit = 0xffffffff;
> +        data->ldtr_arbytes = 0xc00;
> +
> +        data->cs_arbytes = 0xc9b;
> +
> +        data->gs_limit = 0xffffffff;
> +        data->gs_arbytes = 0xc00;
> +
> +        data->tr_arbytes = 0x8b;
> +    }
> +

It's a bit rude to trample register state like this. Why do limits need to
be forced? The Intel manuals do not specify that any vm-entry checks are
applied to segment limits outside of vm86 mode.

 -- Keir

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

* Re: [PATCH] hvm: live migration between intel and amd
  2008-06-13 16:08 ` Keir Fraser
@ 2008-06-16 13:32   ` Jean Guyader
  0 siblings, 0 replies; 3+ messages in thread
From: Jean Guyader @ 2008-06-16 13:32 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel

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

Keir Fraser wrote:
> On 13/6/08 16:46, "Jean Guyader" <jean.guyader@eu.citrix.com> wrote:
> 
>> +    /* Do we come from AMD processor ? */
>> +    if ( data->msr_flags == -1ULL )
>> +    {
>> +        data->msr_flags = 0x7ULL;
>> +
>> +        data->ldtr_limit = 0xffffffff;
>> +        data->ldtr_arbytes = 0xc00;
>> +
>> +        data->cs_arbytes = 0xc9b;
>> +
>> +        data->gs_limit = 0xffffffff;
>> +        data->gs_arbytes = 0xc00;
>> +
>> +        data->tr_arbytes = 0x8b;
>> +    }
>> +
> 
> It's a bit rude to trample register state like this. Why do limits need to
> be forced? The Intel manuals do not specify that any vm-entry checks are
> applied to segment limits outside of vm86 mode.
> 

Agreed. The vm-entry check was failing on this one (Intel 3b, 22-11):

  - Bit 15 (G). The following checks apply if the register is CS or if 
the register is usable:
    - If any bit in the limit field in the range 11:0 is 0, G must be 0. 

    - If any bit in the limit field in the range 31:20 is 1, G must be 1.

-- 
Jean Guyader

[-- Attachment #2: live_migration_amd_intel_2.patch --]
[-- Type: text/plain, Size: 1046 bytes --]

diff -r ec56331c056a xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c	Thu Jun 12 16:34:25 2008 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c	Mon Jun 16 14:25:33 2008 +0100
@@ -615,6 +615,10 @@ static void vmx_load_cpu_state(struct vc
 #ifdef __x86_64__
     struct vmx_msr_state *guest_state = &v->arch.hvm_vmx.msr_state;
 
+    /* Set the msr_flags */
+    if ( data->msr_flags & 0x7ULL )
+        data->msr_flags &= 0x7ULL;
+
     /* restore msrs */
     guest_state->flags = data->msr_flags;
     guest_state->msrs[VMX_INDEX_MSR_LSTAR]        = data->msr_lstar;
@@ -624,6 +628,15 @@ static void vmx_load_cpu_state(struct vc
     v->arch.hvm_vmx.cstar     = data->msr_cstar;
     v->arch.hvm_vmx.shadow_gs = data->shadow_gs;
 #endif
+    
+    /*
+    ** If any bit in the limit field in the range 31:20 is 1,
+    ** G must be set to 1 (Intel 3b, 22-11)
+    **/
+    if ( data->cs_limit & 0xfff0000 )
+        set_bit(11, &data->cs_arbytes);
+    else
+        clear_bit(11, &data->cs_arbytes);
 
     hvm_set_guest_tsc(v, data->tsc);
 }

[-- 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] 3+ messages in thread

end of thread, other threads:[~2008-06-16 13:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-13 15:46 [PATCH] hvm: live migration between intel and amd Jean Guyader
2008-06-13 16:08 ` Keir Fraser
2008-06-16 13:32   ` Jean Guyader

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.