From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDguW-0001Rk-Di for qemu-devel@nongnu.org; Tue, 11 Oct 2011 14:18:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDguV-0004h1-0E for qemu-devel@nongnu.org; Tue, 11 Oct 2011 14:18:40 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:43260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDguU-0004gf-KO for qemu-devel@nongnu.org; Tue, 11 Oct 2011 14:18:38 -0400 Message-ID: <4E948842.4030406@web.de> Date: Tue, 11 Oct 2011 20:17:38 +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> <4E928B54.1070707@cn.fujitsu.com> <4E92958E.9000509@web.de> <4E9476E2.1070804@cn.fujitsu.com> In-Reply-To: <4E9476E2.1070804@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig9C7E5ED8B8F8CABD9EEA4097" Sender: jan.kiszka@web.de Subject: Re: [Qemu-devel] [PATCH 2/2 V2] qemu-kvm: fix improper nmi emulation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lai Jiangshan Cc: Kenji Kaneshige , KAMEZAWA Hiroyuki , "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" , Avi Kivity This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig9C7E5ED8B8F8CABD9EEA4097 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2011-10-11 19:03, 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 > (laijs) changed from v1: > use KVM_CAP_LAPIC_NMI > adjust the pic_deliver_nmi() API >=20 > Signed-off-by: Kenji Kaneshige > Tested-by: Lai Jiangshan > --- > hw/apic.c | 26 ++++++++++++++++++++++++++ > hw/apic.h | 1 + > monitor.c | 6 +++++- > 3 files changed, 32 insertions(+), 1 deletions(-) >=20 > diff --git a/hw/apic.c b/hw/apic.c > index 69d6ac5..76e8208 100644 > --- a/hw/apic.c > +++ b/hw/apic.c > @@ -205,6 +205,32 @@ void apic_deliver_pic_intr(DeviceState *d, int lev= el) > } > } > =20 > +void apic_deliver_nmi(DeviceState *d) > +{ > + APICState *s =3D DO_UPCAST(APICState, busdev.qdev, d); > + > +#ifdef KVM_CAP_LAPIC_NMI Unneeded #ifdef, x86 has this defined unconditionally. > + static int kernel_lapic_nmi; Some enum with symbolic states would be more readable. > + > + if (kernel_lapic_nmi =3D=3D 0) { > + if (!kvm_enabled() || !kvm_irqchip_in_kernel() || > + !kvm_check_extension(kvm_state, KVM_CAP_LAPIC_NMI)) { This is wrong: If we run with in-kernel irqchip on an old kernel without KVM_CAP_LAPIC_NMI, we still must not call into the user space APIC model.= As explained in some other mail, we could then emulate the missing kernel feature by reading out the current in-kernel APIC state, testing if LINT1 is unmasked, and then delivering the NMI directly. Jan --------------enig9C7E5ED8B8F8CABD9EEA4097 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/ iEYEARECAAYFAk6UiEIACgkQitSsb3rl5xQSDQCfbbpTxuJjPlZjv4ZjjLaMKNwD /78AoIWEFHVSOHtWTxYXzQ0TQaMQJmfQ =0fJR -----END PGP SIGNATURE----- --------------enig9C7E5ED8B8F8CABD9EEA4097--