From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 05/15] Coalesce userspace/kernel irqchip interrupt injection logic. Date: Sat, 18 Apr 2009 11:05:10 +0200 Message-ID: <49E997C6.4090503@web.de> References: <1239616545-25199-1-git-send-email-gleb@redhat.com> <1239616545-25199-6-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig9353832EC1E857F6043E6C83" Cc: avi@redhat.com, kvm@vger.kernel.org, joerg.roedel@amd.com, sheng@linux.intel.com, Dmitry Baryshkov To: Gleb Natapov Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:36804 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752826AbZDRJFX (ORCPT ); Sat, 18 Apr 2009 05:05:23 -0400 In-Reply-To: <1239616545-25199-6-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig9353832EC1E857F6043E6C83 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Gleb Natapov wrote: > Start to use interrupt/exception queues like VMX does. > This also fix the bug that if exit was caused by a guest > internal exception access to IDT the exception was not > reinjected. >=20 > Signed-off-by: Gleb Natapov > --- > arch/x86/kvm/svm.c | 176 ++++++++++++++++++++++----------------------= -------- > 1 files changed, 75 insertions(+), 101 deletions(-) >=20 > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 52c41aa..053370d 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -70,7 +70,6 @@ module_param(npt, int, S_IRUGO); > static int nested =3D 0; > module_param(nested, int, S_IRUGO); > =20 > -static void kvm_reput_irq(struct vcpu_svm *svm); > static void svm_flush_tlb(struct kvm_vcpu *vcpu); > =20 > static int nested_svm_exit_handled(struct vcpu_svm *svm, bool kvm_over= ride); > @@ -199,9 +198,7 @@ static void svm_queue_exception(struct kvm_vcpu *vc= pu, unsigned nr, > =20 > static bool svm_exception_injected(struct kvm_vcpu *vcpu) > { > - struct vcpu_svm *svm =3D to_svm(vcpu); > - > - return !(svm->vmcb->control.exit_int_info & SVM_EXITINTINFO_VALID); > + return false; > } > =20 > static int is_external_interrupt(u32 info) > @@ -976,12 +973,9 @@ static int svm_guest_debug(struct kvm_vcpu *vcpu, = struct kvm_guest_debug *dbg) > =20 > static int svm_get_irq(struct kvm_vcpu *vcpu) > { > - struct vcpu_svm *svm =3D to_svm(vcpu); > - u32 exit_int_info =3D svm->vmcb->control.exit_int_info; > - > - if (is_external_interrupt(exit_int_info)) > - return exit_int_info & SVM_EVTINJ_VEC_MASK; > - return -1; > + if (!vcpu->arch.interrupt.pending) > + return -1; > + return vcpu->arch.interrupt.nr; > } > =20 > static void load_host_msrs(struct kvm_vcpu *vcpu) > @@ -1088,17 +1082,8 @@ static void svm_set_dr(struct kvm_vcpu *vcpu, in= t dr, unsigned long value, > =20 > static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_r= un) > { > - u32 exit_int_info =3D svm->vmcb->control.exit_int_info; > - struct kvm *kvm =3D svm->vcpu.kvm; > u64 fault_address; > u32 error_code; > - bool event_injection =3D false; > - > - if (!irqchip_in_kernel(kvm) && > - is_external_interrupt(exit_int_info)) { > - event_injection =3D true; > - kvm_push_irq(&svm->vcpu, exit_int_info & SVM_EVTINJ_VEC_MASK); > - } > =20 > fault_address =3D svm->vmcb->control.exit_info_2; > error_code =3D svm->vmcb->control.exit_info_1; > @@ -1118,9 +1103,11 @@ static int pf_interception(struct vcpu_svm *svm,= struct kvm_run *kvm_run) > */ > if (npt_enabled) > svm_flush_tlb(&svm->vcpu); > - > - if (!npt_enabled && event_injection) > - kvm_mmu_unprotect_page_virt(&svm->vcpu, fault_address); > + else { > + if (svm->vcpu.arch.interrupt.pending || > + svm->vcpu.arch.exception.pending) > + kvm_mmu_unprotect_page_virt(&svm->vcpu, fault_address); > + } Without understanding yet why kvm_mmu_unprotect_page_virt is required here, this looks like it is lacking '|| svm->vcpu.arch.nmi_injected'. Interrupts and exceptions are re-queued on fault-during-injection, therefore they are now pending again, right? Jan --------------enig9353832EC1E857F6043E6C83 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAknpl9AACgkQniDOoMHTA+kJVwCeOaBYHZszVrMV7u4BZxIGqAxq jmoAnRR3H6QcK2sKdd9EtHMHzUCcgQpZ =AM2h -----END PGP SIGNATURE----- --------------enig9353832EC1E857F6043E6C83--