From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] qemu-kvm: fix improper nmi emulation Date: Mon, 10 Oct 2011 08:49:50 +0200 Message-ID: <4E92958E.9000509@web.de> 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> <4E928B54.1070707@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigFE23E27A4735D623C5590201" Cc: Avi Kivity , Kenji Kaneshige , KAMEZAWA Hiroyuki , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" , seabios@seabios.org To: Lai Jiangshan Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:50969 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750980Ab1JJGtw (ORCPT ); Mon, 10 Oct 2011 02:49:52 -0400 In-Reply-To: <4E928B54.1070707@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigFE23E27A4735D623C5590201 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, inject-nmi request is handled as follows. >=20 > - When in-kernel irqchip is disabled, inject LINT1 instead of NMI > interrupt. > - When in-kernel irqchip is enabled, send nmi event to kernel as the > current code does. LINT1 should be emulated in kernel. >=20 > Signed-off-by: Kenji Kaneshige > Tested-by: Lai Jiangshan This is targeting uq/master? Please make sure your patch passes checkpatch.pl > --- > hw/apic.c | 16 ++++++++++++++++ > hw/apic.h | 1 + > monitor.c | 5 ++--- > 3 files changed, 19 insertions(+), 3 deletions(-) >=20 > Index: qemu-kvm/hw/apic.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 > --- qemu-kvm.orig/hw/apic.c > +++ qemu-kvm/hw/apic.c > @@ -205,6 +205,22 @@ void apic_deliver_pic_intr(DeviceState * > } > } > =20 > +void apic_deliver_nmi(CPUState *env) > +{ > + APICState *apic; > + > + if (kvm_enabled() && kvm_irqchip_in_kernel()) { > + cpu_interrupt(env, CPU_INTERRUPT_NMI); > + return; > + } > + > + apic =3D DO_UPCAST(APICState, busdev.qdev, env->apic_state); > + if (!apic) > + cpu_interrupt(env, CPU_INTERRUPT_NMI); Testing for !apic and handling the non-APIC case here looks a bit strange. Let's move the !env->apic_state test to the caller to make it consistent with other APIC services. The KVM case should be a separate qemu-kvm patch on top for now. (We may implement calls into APIC models differently when pushing in-kernel irqchip support upstream.) Jan --------------enigFE23E27A4735D623C5590201 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/ iEYEARECAAYFAk6SlY4ACgkQitSsb3rl5xTWvQCgwPVIC/PbLzg6bpsvDvB92hKV ocgAn1dIFXVXDVTKTFEGgCja6IY5IMJR =GRIJ -----END PGP SIGNATURE----- --------------enigFE23E27A4735D623C5590201--