From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lai Jiangshan Subject: Re: [PATCH] qemu: Fix inject-nmi Date: Mon, 10 Oct 2011 14:06:01 +0800 Message-ID: <4E928B49.7090102@cn.fujitsu.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Jan Kiszka , Kenji Kaneshige , KAMEZAWA Hiroyuki , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" , seabios@seabios.org To: Avi Kivity Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:52140 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751838Ab1JJGEo (ORCPT ); Mon, 10 Oct 2011 02:04:44 -0400 In-Reply-To: <4E8035F9.9080908@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 09/26/2011 04:21 PM, Avi Kivity wrote: > On 09/25/2011 08:22 PM, Jan Kiszka wrote: >> On 2011-09-25 16:07, Avi Kivity wrote: >> > On 09/23/2011 12:31 PM, Lai Jiangshan wrote: >> >> > Moreover: wrong indention. >> >> > >> >> > You know that this won't work for qemu-kvm with in-kernel irqchip? You >> >> > may want to provide a patch for that tree, emulating the unavailable >> >> > LINT1 injection via testing the APIC configration and then raising an >> >> > NMI as before if it is accepted. >> >> > >> >> >> >> It works in my box but the NMI is not injected through the in-kernel >> >> irqchip, >> >> I will implement it as you suggested. >> > >> > Somewhat hacky; isn't it better to test LINT1 in the kernel (and >> > redefine the KVM_NMI ioctl as "toggle LINT1")? >> >> KVM_NMI is required for user space IRQ chip as well. > > We could define KVM_NMI as edging the core NMI input if !irqchip_in_kernel, and toggling LINT1 otherwise. Hardly nice though. > > The current KVM_NMI with irqchip_in_kernel is not meaningful, since it doesn't obey the rules of any NMI source. > >> Introducing some KVM_SET_LINT1 is an option though. But emulating it for >> the NMI button on older kernels sounds worthwhile nevertheless. >> > > Perhaps this is the best option to avoid confusion. > (add cc: seabios@seabios.org) Hi, All, When I was implementing KVM_SET_LINT1, I found many places of the qemu-kvm code need to be changed, and it became nasty. And as Avi said KVM_NMI with irqchip_in_kernel is not meaningful, so KVM_NMI is not used anymore when KVM_SET_LINT1 & irqchip_in_kernel, it is dead. Now, we redefine KVM_NMI with more proper meaning, when irqchip_in_kernel, it is kernel/kvm's responsibility to simulate the NMI-injection and set LINT1. When !irqchip_in_kernel, it is userspace's responsibility. It results more real simulation and results simpler code, and it don't need to add new ioctl interface, and it can make use of existing KVM_NMI. Thanks, Lai From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RD8yz-0003zt-D6 for qemu-devel@nongnu.org; Mon, 10 Oct 2011 02:05:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RD8yy-0007WY-0I for qemu-devel@nongnu.org; Mon, 10 Oct 2011 02:05:01 -0400 Received: from [222.73.24.84] (port=54036 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RD8yv-0007SE-GN for qemu-devel@nongnu.org; Mon, 10 Oct 2011 02:04:59 -0400 Message-ID: <4E928B49.7090102@cn.fujitsu.com> Date: Mon, 10 Oct 2011 14:06:01 +0800 From: Lai Jiangshan 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> In-Reply-To: <4E8035F9.9080908@redhat.com> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH] qemu: Fix inject-nmi List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: "kvm@vger.kernel.org" , seabios@seabios.org, "qemu-devel@nongnu.org" , Jan Kiszka , Kenji Kaneshige , KAMEZAWA Hiroyuki On 09/26/2011 04:21 PM, Avi Kivity wrote: > On 09/25/2011 08:22 PM, Jan Kiszka wrote: >> On 2011-09-25 16:07, Avi Kivity wrote: >> > On 09/23/2011 12:31 PM, Lai Jiangshan wrote: >> >> > Moreover: wrong indention. >> >> > >> >> > You know that this won't work for qemu-kvm with in-kernel irqchip? You >> >> > may want to provide a patch for that tree, emulating the unavailable >> >> > LINT1 injection via testing the APIC configration and then raising an >> >> > NMI as before if it is accepted. >> >> > >> >> >> >> It works in my box but the NMI is not injected through the in-kernel >> >> irqchip, >> >> I will implement it as you suggested. >> > >> > Somewhat hacky; isn't it better to test LINT1 in the kernel (and >> > redefine the KVM_NMI ioctl as "toggle LINT1")? >> >> KVM_NMI is required for user space IRQ chip as well. > > We could define KVM_NMI as edging the core NMI input if !irqchip_in_kernel, and toggling LINT1 otherwise. Hardly nice though. > > The current KVM_NMI with irqchip_in_kernel is not meaningful, since it doesn't obey the rules of any NMI source. > >> Introducing some KVM_SET_LINT1 is an option though. But emulating it for >> the NMI button on older kernels sounds worthwhile nevertheless. >> > > Perhaps this is the best option to avoid confusion. > (add cc: seabios@seabios.org) Hi, All, When I was implementing KVM_SET_LINT1, I found many places of the qemu-kvm code need to be changed, and it became nasty. And as Avi said KVM_NMI with irqchip_in_kernel is not meaningful, so KVM_NMI is not used anymore when KVM_SET_LINT1 & irqchip_in_kernel, it is dead. Now, we redefine KVM_NMI with more proper meaning, when irqchip_in_kernel, it is kernel/kvm's responsibility to simulate the NMI-injection and set LINT1. When !irqchip_in_kernel, it is userspace's responsibility. It results more real simulation and results simpler code, and it don't need to add new ioctl interface, and it can make use of existing KVM_NMI. Thanks, Lai