Li, Jiongxi
2013-Jan-29 05:56 UTC
[PATCH v4 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 missed when
virtual interrupt delivery is enabled.
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..38ff216 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -1198,6 +1198,9 @@ 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;
+ if ( hvm_funcs.process_isr )
+ hvm_funcs.process_isr(vlapic_find_highest_isr(s), v);
+
vlapic_adjust_i8259_target(d);
lapic_rearm(s);
return 0;
diff --git a/xen/arch/x86/hvm/vmx/intr.c b/xen/arch/x86/hvm/vmx/intr.c
index c5c503e..8306237 100644
--- a/xen/arch/x86/hvm/vmx/intr.c
+++ b/xen/arch/x86/hvm/vmx/intr.c
@@ -290,8 +290,8 @@ void vmx_intr_assist(void)
vmx_set_eoi_exit_bitmap(v, pt_vector);
/* we need update the RVI field */
- status &= ~(unsigned long)0x0FF;
- status |= (unsigned long)0x0FF &
+ status &= ~(unsigned long)VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK;
+ status |= (unsigned long)VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK &
intack.vector;
__vmwrite(GUEST_INTR_STATUS, status);
if (v->arch.hvm_vmx.eoi_exitmap_changed) {
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 4d7c93f..43ed36c 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_process_isr(int isr, struct vcpu *v)
+{
+ unsigned long status;
+ u8 old;
+
+ if ( !cpu_has_vmx_virtual_intr_delivery )
+ return;
+
+ if (isr < 0)
+ isr = 0;
+
+ vmx_vmcs_enter(v);
+ status = __vmread(GUEST_INTR_STATUS);
+ old = status >> VMX_GUEST_INTR_STATUS_SVI_OFFSET;
+ if (isr != old) {
+ status &= VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK;
+ status |= isr << VMX_GUEST_INTR_STATUS_SVI_OFFSET;
+ __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,
+ .process_isr = vmx_process_isr,
.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..011a6a3 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 (*process_isr)(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/asm-x86/hvm/vmx/vmcs.h
b/xen/include/asm-x86/hvm/vmx/vmcs.h
index 51df81e..d4958c3 100644
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h
@@ -257,6 +257,10 @@ extern bool_t cpu_has_vmx_ins_outs_instr_info;
*/
#define VMX_BASIC_DEFAULT1_ZERO (1ULL << 55)
+/* Guest interrupt status */
+#define VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK 0x0FF
+#define VMX_GUEST_INTR_STATUS_SVI_OFFSET 8
+
/* VMCS field encodings. */
enum vmcs_field {
VIRTUAL_PROCESSOR_ID = 0x00000000,
--
1.7.1
Jan Beulich
2013-Jan-29 08:48 UTC
Re: [PATCH v4 1/2] Xen: Fix live migration while enabling APICV
>>> On 29.01.13 at 06:56, "Li, Jiongxi" <jiongxi.li@intel.com> wrote: > --- a/xen/arch/x86/hvm/vmx/intr.c > +++ b/xen/arch/x86/hvm/vmx/intr.c > @@ -290,8 +290,8 @@ void vmx_intr_assist(void) > vmx_set_eoi_exit_bitmap(v, pt_vector); > > /* we need update the RVI field */ > - status &= ~(unsigned long)0x0FF; > - status |= (unsigned long)0x0FF & > + status &= ~(unsigned long)VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK; > + status |= (unsigned long)VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK &Why are you keeping these completely bogus casts here?> +static void vmx_process_isr(int isr, struct vcpu *v) > +{ > + unsigned long status; > + u8 old; > + > + if ( !cpu_has_vmx_virtual_intr_delivery ) > + return; > + > + if (isr < 0)Missing blanks around expression.> + isr = 0; > + > + vmx_vmcs_enter(v); > + status = __vmread(GUEST_INTR_STATUS); > + old = status >> VMX_GUEST_INTR_STATUS_SVI_OFFSET; > + if (isr != old) {Here too. Plus the brace belongs on its own line. Jan
Reasonably Related Threads
- [ PATCH v3 2/3] xen: enable Virtual-interrupt delivery
- [PATCH v4 2/2] Xen: Fix VMCS setting for x2APIC mode guest while enabling APICV
- [PATCH v4 0/4] x86/HVM: miscellaneous improvements
- [PATCH] x86/HVM: move per-vendor function tables into .init.data
- [PATCH 0/4] Add posted interrupt supporting