From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RD9X9-0001PL-LW for qemu-devel@nongnu.org; Mon, 10 Oct 2011 02:40:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RD9X8-0006Jk-7i for qemu-devel@nongnu.org; Mon, 10 Oct 2011 02:40:19 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:57186) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RD9X7-0006Jg-RO for qemu-devel@nongnu.org; Mon, 10 Oct 2011 02:40:18 -0400 Message-ID: <4E92934C.2080605@web.de> Date: Mon, 10 Oct 2011 08:40:12 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <20110913093835.GB4265@localhost.localdomain> <20110914093441.e2bb305c.kamezawa.hiroyu@jp.fujitsu.com> <4E705BC3.5000508@cn.fujitsu.com> <20110915164704.9cacd407.kamezawa.hiroyu@jp.fujitsu.com> <4E71B28F.7030201@cn.fujitsu.com> <4E72F3BA.2000603@jp.fujitsu.com> <4E73200A.7040908@jp.fujitsu.com> <4E76C6AA.9080403@cn.fujitsu.com> <4E7B04DC.1030407@cn.fujitsu.com> <4E7B4B8F.507@siemens.com> <4E7C51E4.2000503@cn.fujitsu.com> <4E7F3585.40108@redhat.com> <4E7F635E.6080009@web.de> <4E8035F9.9080908@redhat.com> <4E928B4E.2080207@cn.fujitsu.com> In-Reply-To: <4E928B4E.2080207@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB5AC63EAEDCA438AE3D01969" Sender: jan.kiszka@web.de Subject: Re: [Qemu-devel] [PATCH] kernel/kvm: fix improper nmi emulation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lai Jiangshan Cc: "kvm@vger.kernel.org" , seabios@seabios.org, "qemu-devel@nongnu.org" , Avi Kivity , Kenji Kaneshige , KAMEZAWA Hiroyuki This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB5AC63EAEDCA438AE3D01969 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2011-10-10 08:06, Lai Jiangshan wrote: > From: Kenji Kaneshige >=20 > Currently, NMI interrupt is blindly sent to all the vCPUs when NMI > button event happens. This doesn't properly emulate real hardware on > which NMI button event triggers LINT1. Because of this, NMI is sent to > the processor even when LINT1 is maskied in LVT. For example, this > causes the problem that kdump initiated by NMI sometimes doesn't work > on KVM, because kdump assumes NMI is masked on CPUs other than CPU0. >=20 > With this patch, KVM_NMI ioctl is handled as follows. >=20 > - When in-kernel irqchip is enabled, KVM_NMI ioctl is handled as a > request of triggering LINT1 on the processor. LINT1 is emulated in > in-kernel irqchip. >=20 > - When in-kernel irqchip is disabled, KVM_NMI ioctl is handled as a > request of injecting NMI to the processor. This assumes LINT1 is > already emulated in userland. >=20 > Signed-off-by: Kenji Kaneshige > Tested-by: Lai Jiangshan > --- > arch/x86/kvm/irq.h | 1 + > arch/x86/kvm/lapic.c | 8 ++++++++ > arch/x86/kvm/x86.c | 14 ++++---------- > 3 files changed, 13 insertions(+), 10 deletions(-) >=20 > Index: linux/arch/x86/kvm/irq.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- linux.orig/arch/x86/kvm/irq.h > +++ linux/arch/x86/kvm/irq.h > @@ -95,6 +95,7 @@ void kvm_pic_reset(struct kvm_kpic_state > void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); > void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); > void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu); > +void kvm_apic_lint1_deliver(struct kvm_vcpu *vcpu); > void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu); > void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu); > void __kvm_migrate_timers(struct kvm_vcpu *vcpu); > Index: linux/arch/x86/kvm/lapic.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- linux.orig/arch/x86/kvm/lapic.c > +++ linux/arch/x86/kvm/lapic.c > @@ -1039,6 +1039,14 @@ void kvm_apic_nmi_wd_deliver(struct kvm_ > kvm_apic_local_deliver(apic, APIC_LVT0); > } > =20 > +void kvm_apic_lint1_deliver(struct kvm_vcpu *vcpu) > +{ > + struct kvm_lapic *apic =3D vcpu->arch.apic; > + > + if (apic) WARN_ON(!apic)? Looks like that case would be a kernel bug. > + kvm_apic_local_deliver(apic, APIC_LVT1); > +} > + > static struct kvm_timer_ops lapic_timer_ops =3D { > .is_periodic =3D lapic_is_periodic, > }; > Index: linux/arch/x86/kvm/x86.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- linux.orig/arch/x86/kvm/x86.c > +++ linux/arch/x86/kvm/x86.c > @@ -2729,13 +2729,6 @@ static int kvm_vcpu_ioctl_interrupt(stru > return 0; > } > =20 > -static int kvm_vcpu_ioctl_nmi(struct kvm_vcpu *vcpu) > -{ > - kvm_inject_nmi(vcpu); > - > - return 0; > -} > - > static int vcpu_ioctl_tpr_access_reporting(struct kvm_vcpu *vcpu, > struct kvm_tpr_access_ctl *tac) > { > @@ -3038,9 +3031,10 @@ long kvm_arch_vcpu_ioctl(struct file *fi > break; > } > case KVM_NMI: { > - r =3D kvm_vcpu_ioctl_nmi(vcpu); > - if (r) > - goto out; > + if (irqchip_in_kernel(vcpu->kvm)) > + kvm_apic_lint1_deliver(vcpu); > + else > + kvm_inject_nmi(vcpu); > r =3D 0; > break; > } Looks OK otherwise. Jan --------------enigB5AC63EAEDCA438AE3D01969 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.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6Sk08ACgkQitSsb3rl5xSt2QCeIggT4te5dbci4VP63ceR2eK2 XGQAnA+ExSOGjKKizrbZlwEZbLJo/Uce =USys -----END PGP SIGNATURE----- --------------enigB5AC63EAEDCA438AE3D01969--