Li, Jiongxi
2013-Jan-26 06:11 UTC
[PATCH 1/2] Xen: Fix live migration while enabling APICV
SVI should be restored in case guest is processing virtual interrupt while saveing a domain state. Otherwise SVI would be missied when virtual interrupt delivery is enabled. Also adjust code sequence of lapic load code to make the function name reflect what it does more accurately. Signed-off-by: Jiongxi Li <jiongxi.li@intel.com> diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index ee2294c..9a9c7d1 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -1176,6 +1176,12 @@ static int lapic_load_hidden(struct domain *d, hvm_domain_context_t *h) vmx_vlapic_msr_changed(v); + if ( hvm_funcs.set_svi ) + hvm_funcs.set_svi(vlapic_find_highest_isr(s), v); + + vlapic_adjust_i8259_target(d); + lapic_rearm(s); + return 0; } @@ -1198,8 +1204,6 @@ static int lapic_load_regs(struct domain *d, hvm_domain_context_t *h) if ( hvm_load_entry(LAPIC_REGS, h, s->regs) != 0 ) return -EINVAL; - vlapic_adjust_i8259_target(d); - lapic_rearm(s); return 0; } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 4d7c93f..2949782 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1419,6 +1419,28 @@ static int vmx_virtual_intr_delivery_enabled(void) return cpu_has_vmx_virtual_intr_delivery; } +static void vmx_set_svi(int isr, struct vcpu *v) +{ + unsigned long status; + u8 old; + + if ( !cpu_has_vmx_virtual_intr_delivery ) + return; + + if (isr == -1) + isr = 0; + + vmx_vmcs_enter(v); + status = __vmread(GUEST_INTR_STATUS); + old = status >> 8; + if (isr != old) { + status &= 0x0FF; + status |= isr << 8; + __vmwrite(GUEST_INTR_STATUS, status); + } + vmx_vmcs_exit(v); +} + static struct hvm_function_table __read_mostly vmx_function_table = { .name = "VMX", .cpu_up_prepare = vmx_cpu_up_prepare, @@ -1468,6 +1490,7 @@ static struct hvm_function_table __read_mostly vmx_function_table = { .nhvm_domain_relinquish_resources = nvmx_domain_relinquish_resources, .update_eoi_exit_bitmap = vmx_update_eoi_exit_bitmap, .virtual_intr_delivery_enabled = vmx_virtual_intr_delivery_enabled, + .set_svi = vmx_set_svi, .nhvm_hap_walk_L1_p2m = nvmx_hap_walk_L1_p2m, }; diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 76e9cc8..a0375a7 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -183,6 +183,7 @@ struct hvm_function_table { /* Virtual interrupt delivery */ void (*update_eoi_exit_bitmap)(struct vcpu *v, u8 vector, u8 trig); int (*virtual_intr_delivery_enabled)(void); + void (*set_svi)(int isr, struct vcpu *v); /*Walk nested p2m */ int (*nhvm_hap_walk_L1_p2m)(struct vcpu *v, paddr_t L2_gpa, diff --git a/xen/include/public/arch-x86/hvm/save.h b/xen/include/public/arch-x86/hvm/save.h index a82a5ee..d2a9cf3 100644 --- a/xen/include/public/arch-x86/hvm/save.h +++ b/xen/include/public/arch-x86/hvm/save.h @@ -376,6 +376,12 @@ DECLARE_HVM_SAVE_TYPE(IOAPIC, 4, struct hvm_hw_vioapic); * LAPIC */ +struct hvm_hw_lapic_regs { + uint8_t data[1024]; +}; + +DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 5, struct hvm_hw_lapic_regs); + struct hvm_hw_lapic { uint64_t apic_base_msr; uint32_t disabled; /* VLAPIC_xx_DISABLED */ @@ -383,13 +389,7 @@ struct hvm_hw_lapic { uint64_t tdt_msr; }; -DECLARE_HVM_SAVE_TYPE(LAPIC, 5, struct hvm_hw_lapic); - -struct hvm_hw_lapic_regs { - uint8_t data[1024]; -}; - -DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 6, struct hvm_hw_lapic_regs); +DECLARE_HVM_SAVE_TYPE(LAPIC, 6, struct hvm_hw_lapic); /* -- 1.7.12.1
Keir Fraser
2013-Jan-26 07:22 UTC
Re: [PATCH 1/2] Xen: Fix live migration while enabling APICV
On 26/01/2013 06:11, "Li, Jiongxi" <jiongxi.li@intel.com> wrote:> diff --git a/xen/include/public/arch-x86/hvm/save.h > b/xen/include/public/arch-x86/hvm/save.h > index a82a5ee..d2a9cf3 100644 > --- a/xen/include/public/arch-x86/hvm/save.h > +++ b/xen/include/public/arch-x86/hvm/save.h > @@ -376,6 +376,12 @@ DECLARE_HVM_SAVE_TYPE(IOAPIC, 4, struct hvm_hw_vioapic); > * LAPIC > */ > > +struct hvm_hw_lapic_regs { > + uint8_t data[1024]; > +}; > + > +DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 5, struct hvm_hw_lapic_regs); > + > struct hvm_hw_lapic { > uint64_t apic_base_msr; > uint32_t disabled; /* VLAPIC_xx_DISABLED */ > @@ -383,13 +389,7 @@ struct hvm_hw_lapic { > uint64_t tdt_msr; > }; > > -DECLARE_HVM_SAVE_TYPE(LAPIC, 5, struct hvm_hw_lapic); > - > -struct hvm_hw_lapic_regs { > - uint8_t data[1024]; > -}; > - > -DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 6, struct hvm_hw_lapic_regs); > +DECLARE_HVM_SAVE_TYPE(LAPIC, 6, struct hvm_hw_lapic); > > > /*Why mess with the ordering here? And changing the type numbering is not allowed, as that''s part of the public interface and makes backward compatibility with older save images harder. -- Keir
Li, Jiongxi
2013-Jan-27 11:04 UTC
Re: [PATCH 1/2] Xen: Fix live migration while enabling APICV
> -----Original Message----- > From: xen-devel-bounces@lists.xen.org > [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of Keir Fraser > Sent: Saturday, January 26, 2013 3:23 PM > To: Li, Jiongxi; ''xen-devel@lists.xen.org'' > Subject: Re: [Xen-devel] [PATCH 1/2] Xen: Fix live migration while enabling > APICV > > On 26/01/2013 06:11, "Li, Jiongxi" <jiongxi.li@intel.com> wrote: > > > diff --git a/xen/include/public/arch-x86/hvm/save.h > > b/xen/include/public/arch-x86/hvm/save.h > > index a82a5ee..d2a9cf3 100644 > > --- a/xen/include/public/arch-x86/hvm/save.h > > +++ b/xen/include/public/arch-x86/hvm/save.h > > @@ -376,6 +376,12 @@ DECLARE_HVM_SAVE_TYPE(IOAPIC, 4, struct > hvm_hw_vioapic); > > * LAPIC > > */ > > > > +struct hvm_hw_lapic_regs { > > + uint8_t data[1024]; > > +}; > > + > > +DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 5, struct hvm_hw_lapic_regs); > > + > > struct hvm_hw_lapic { > > uint64_t apic_base_msr; > > uint32_t disabled; /* VLAPIC_xx_DISABLED */ > > @@ -383,13 +389,7 @@ struct hvm_hw_lapic { > > uint64_t tdt_msr; > > }; > > > > -DECLARE_HVM_SAVE_TYPE(LAPIC, 5, struct hvm_hw_lapic); > > - > > -struct hvm_hw_lapic_regs { > > - uint8_t data[1024]; > > -}; > > - > > -DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 6, struct hvm_hw_lapic_regs); > > +DECLARE_HVM_SAVE_TYPE(LAPIC, 6, struct hvm_hw_lapic); > > > > > > /* > > Why mess with the ordering here? And changing the type numbering is not > allowed, as that''s part of the public interface and makes backward > compatibility with older save images harder.Because loading SVI depends on hw_lapic_regs loading and SVI seems to belong to the ''hidden'' stuff, I changed the order. But you are right with the compatibility things. I will revise the patch to minimize the change. Thanks> > -- Keir > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel