From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v3 1/4] KVM: nVMX: Rework interception of IRQs and NMIs Date: Sun, 09 Mar 2014 09:01:59 +0100 Message-ID: <531C1FF7.5010408@web.de> References: <531A2270.6010406@redhat.com> <531AE108.8090008@web.de> <531C193B.3080805@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="6DOmkVOreauSJmJomvCKhhiR0P6ToNrxU" Cc: kvm To: Paolo Bonzini , Gleb Natapov , Marcelo Tosatti Return-path: Received: from mout.web.de ([212.227.17.12]:60770 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752328AbaCIIC0 (ORCPT ); Sun, 9 Mar 2014 04:02:26 -0400 In-Reply-To: <531C193B.3080805@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6DOmkVOreauSJmJomvCKhhiR0P6ToNrxU Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2014-03-09 08:33, Paolo Bonzini wrote: > Il 08/03/2014 10:21, Jan Kiszka ha scritto: >> On 2014-03-07 20:48, Paolo Bonzini wrote: >>> Il 07/03/2014 20:03, Jan Kiszka ha scritto: >>>> @@ -4631,22 +4631,8 @@ static void vmx_set_nmi_mask(struct kvm_vcpu >>>> *vcpu, bool masked) >>>> >>>> static int vmx_nmi_allowed(struct kvm_vcpu *vcpu) >>>> { >>>> - if (is_guest_mode(vcpu)) { >>>> - if (to_vmx(vcpu)->nested.nested_run_pending) >>>> - return 0; >>>> - if (nested_exit_on_nmi(vcpu)) { >>>> - nested_vmx_vmexit(vcpu, EXIT_REASON_EXCEPTION_NMI, >>>> - NMI_VECTOR | INTR_TYPE_NMI_INTR | >>>> - INTR_INFO_VALID_MASK, 0); >>>> - /* >>>> - * The NMI-triggered VM exit counts as injection: >>>> - * clear this one and block further NMIs. >>>> - */ >>>> - vcpu->arch.nmi_pending =3D 0; >>>> - vmx_set_nmi_mask(vcpu, true); >>>> - return 0; >>>> - } >>>> - } >>>> + if (to_vmx(vcpu)->nested.nested_run_pending) >>>> + return 0; >>>> >>>> if (!cpu_has_virtual_nmis() && to_vmx(vcpu)->soft_vnmi_blocked)= >>>> return 0; >>>> @@ -4658,19 +4644,8 @@ static int vmx_nmi_allowed(struct kvm_vcpu >>>> *vcpu) >>>> >>>> static int vmx_interrupt_allowed(struct kvm_vcpu *vcpu) >>>> { >>>> - if (is_guest_mode(vcpu)) { >>>> - if (to_vmx(vcpu)->nested.nested_run_pending) >>>> - return 0; >>>> - if (nested_exit_on_intr(vcpu)) { >>>> - nested_vmx_vmexit(vcpu, EXIT_REASON_EXTERNAL_INTERRUPT,= >>>> - 0, 0); >>>> - /* >>>> - * fall through to normal code, but now in L1, not L2 >>>> - */ >>>> - } >>>> - } >>>> - >>>> - return (vmcs_readl(GUEST_RFLAGS) & X86_EFLAGS_IF) && >>>> + return (!to_vmx(vcpu)->nested.nested_run_pending && >>>> + vmcs_readl(GUEST_RFLAGS) & X86_EFLAGS_IF) && >>>> !(vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & >>>> (GUEST_INTR_STATE_STI | GUEST_INTR_STATE_MOV_SS)); >>> >>> The checks on nested_run_pending are not needed anymore and can be >>> replaced with a WARN_ON. Otherwise, >> >> Nope, that won't be correct: If we have a pending interrupt that L1 do= es >> not intercept, we still trigger this condition legally. >=20 > Right, this is the case of !nested_exit_on_intr(vcpu) or > !nested_exit_on_nmi(vcpu). >=20 > Why don't we need to request an immediate exit in that case, in order t= o > inject the interrupt into L2? We enable the hardware interrupt/NMI window request for L2 instead. Jan --6DOmkVOreauSJmJomvCKhhiR0P6ToNrxU 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.19 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlMcH/oACgkQitSsb3rl5xRfrwCguQx2clz0xtdxhoj3yorr6fjc DvsAn2HEEMauhEcYDS/ve4Q+2WhQ3Nkh =WYME -----END PGP SIGNATURE----- --6DOmkVOreauSJmJomvCKhhiR0P6ToNrxU--