From: "Jan Beulich" Subject: [PATCH v2 1/5] VMX: fix interaction of APIC-V and Viridian emulation Date: Mon, 24 Jun 2013 08:03:50 +0100 Message-ID: <51C80B7602000078000DFDAE@nat28.tlf.novell.com> References: <51C8092A02000078000DFDA0@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part5767CC46.3__=" Return-path: In-Reply-To: <51C8092A02000078000DFDA0@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser , George Dunlap , Eddie Dong , paul.durrant@citrix.com, Jun Nakajima , Yang Z Zhang List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part5767CC46.3__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Viridian using a synthetic MSR for issuing EOI notifications bypasses the normal in-processor handling, which would clear GUEST_INTR_STATUS.SVI. Hence we need to do this in software in order for future interrupts to get delivered. Based on analysis by Yang Z Zhang . Signed-off-by: Jan Beulich --- v2: Split off cleanup parts to new patch 3. --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -386,6 +386,9 @@ void vlapic_EOI_set(struct vlapic *vlapi =20 vlapic_clear_vector(vector, &vlapic->regs->data[APIC_ISR]); =20 + if ( hvm_funcs.handle_eoi ) + hvm_funcs.handle_eoi(vector); + if ( vlapic_test_and_clear_vector(vector, &vlapic->regs->data[APIC_TMR= ]) ) vioapic_update_EOI(vlapic_domain(vlapic), vector); =20 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1502,6 +1502,15 @@ static void vmx_sync_pir_to_irr(struct v vlapic_set_vector(i, &vlapic->regs->data[APIC_IRR]); } =20 +static void vmx_handle_eoi(u8 vector) +{ + unsigned long status =3D __vmread(GUEST_INTR_STATUS); + + /* We need to clear the SVI field. */ + status &=3D VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK; + __vmwrite(GUEST_INTR_STATUS, status); +} + static struct hvm_function_table __initdata vmx_function_table =3D { .name =3D "VMX", .cpu_up_prepare =3D vmx_cpu_up_prepare, @@ -1554,6 +1563,7 @@ static struct hvm_function_table __initd .process_isr =3D vmx_process_isr, .deliver_posted_intr =3D vmx_deliver_posted_intr, .sync_pir_to_irr =3D vmx_sync_pir_to_irr, + .handle_eoi =3D vmx_handle_eoi, .nhvm_hap_walk_L1_p2m =3D nvmx_hap_walk_L1_p2m, }; =20 @@ -1580,7 +1590,10 @@ const struct hvm_function_table * __init =20 setup_ept_dump(); } -=20 + + if ( !cpu_has_vmx_virtual_intr_delivery ) + vmx_function_table.handle_eoi =3D NULL; + if ( cpu_has_vmx_posted_intr_processing ) alloc_direct_apic_vector(&posted_intr_vector, event_check_interrup= t); else --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -186,6 +186,7 @@ struct hvm_function_table { void (*process_isr)(int isr, struct vcpu *v); void (*deliver_posted_intr)(struct vcpu *v, u8 vector); void (*sync_pir_to_irr)(struct vcpu *v); + void (*handle_eoi)(u8 vector); =20 /*Walk nested p2m */ int (*nhvm_hap_walk_L1_p2m)(struct vcpu *v, paddr_t L2_gpa, --=__Part5767CC46.3__= Content-Type: text/plain; name="x86-VMX-Viridian-vINTR.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-VMX-Viridian-vINTR.patch" VMX: fix interaction of APIC-V and Viridian emulation=0A=0AViridian using = a synthetic MSR for issuing EOI notifications bypasses=0Athe normal = in-processor handling, which would clear=0AGUEST_INTR_STATUS.SVI. Hence we = need to do this in software in order=0Afor future interrupts to get = delivered.=0A=0ABased on analysis by Yang Z Zhang .= =0A=0ASigned-off-by: Jan Beulich =0A---=0Av2: Split off = cleanup parts to new patch 3.=0A=0A--- a/xen/arch/x86/hvm/vlapic.c=0A+++ = b/xen/arch/x86/hvm/vlapic.c=0A@@ -386,6 +386,9 @@ void vlapic_EOI_set(struc= t vlapic *vlapi=0A =0A vlapic_clear_vector(vector, &vlapic->regs->data[= APIC_ISR]);=0A =0A+ if ( hvm_funcs.handle_eoi )=0A+ hvm_funcs.han= dle_eoi(vector);=0A+=0A if ( vlapic_test_and_clear_vector(vector, = &vlapic->regs->data[APIC_TMR]) )=0A vioapic_update_EOI(vlapic_domai= n(vlapic), vector);=0A =0A--- a/xen/arch/x86/hvm/vmx/vmx.c=0A+++ b/xen/arch= /x86/hvm/vmx/vmx.c=0A@@ -1502,6 +1502,15 @@ static void vmx_sync_pir_to_irr= (struct v=0A vlapic_set_vector(i, &vlapic->regs->data[APIC_IRR]);= =0A }=0A =0A+static void vmx_handle_eoi(u8 vector)=0A+{=0A+ unsigned = long status =3D __vmread(GUEST_INTR_STATUS);=0A+=0A+ /* We need to = clear the SVI field. */=0A+ status &=3D VMX_GUEST_INTR_STATUS_SUBFIELD_B= ITMASK;=0A+ __vmwrite(GUEST_INTR_STATUS, status);=0A+}=0A+=0A static = struct hvm_function_table __initdata vmx_function_table =3D {=0A .name = =3D "VMX",=0A .cpu_up_prepare =3D vmx_cpu_up_prep= are,=0A@@ -1554,6 +1563,7 @@ static struct hvm_function_table __initd=0A = .process_isr =3D vmx_process_isr,=0A .deliver_posted_intr = =3D vmx_deliver_posted_intr,=0A .sync_pir_to_irr =3D vmx_sync_pir_= to_irr,=0A+ .handle_eoi =3D vmx_handle_eoi,=0A .nhvm_hap_w= alk_L1_p2m =3D nvmx_hap_walk_L1_p2m,=0A };=0A =0A@@ -1580,7 +1590,10 @@ = const struct hvm_function_table * __init=0A =0A setup_ept_dump();= =0A }=0A- =0A+=0A+ if ( !cpu_has_vmx_virtual_intr_delivery )=0A+ = vmx_function_table.handle_eoi =3D NULL;=0A+=0A if ( cpu_has_vmx_pos= ted_intr_processing )=0A alloc_direct_apic_vector(&posted_intr_vect= or, event_check_interrupt);=0A else=0A--- a/xen/include/asm-x86/hvm/hvm= .h=0A+++ b/xen/include/asm-x86/hvm/hvm.h=0A@@ -186,6 +186,7 @@ struct = hvm_function_table {=0A void (*process_isr)(int isr, struct vcpu = *v);=0A void (*deliver_posted_intr)(struct vcpu *v, u8 vector);=0A = void (*sync_pir_to_irr)(struct vcpu *v);=0A+ void (*handle_eoi)(u8 = vector);=0A =0A /*Walk nested p2m */=0A int (*nhvm_hap_walk_L1_p2m= )(struct vcpu *v, paddr_t L2_gpa,=0A --=__Part5767CC46.3__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part5767CC46.3__=--