From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] kernel/kvm: fix improper nmi emulation Date: Mon, 10 Oct 2011 12:26:53 +0200 Message-ID: <4E92C86D.9000701@redhat.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> <4E928B4E.2080207@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: "kvm@vger.kernel.org" , seabios@seabios.org, "qemu-devel@nongnu.org" , Jan Kiszka , Kenji Kaneshige , KAMEZAWA Hiroyuki To: Lai Jiangshan Return-path: In-Reply-To: <4E928B4E.2080207@cn.fujitsu.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org On 10/10/2011 08:06 AM, Lai Jiangshan wrote: > From: Kenji Kaneshige > > 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. > > With this patch, KVM_NMI ioctl is handled as follows. > > - 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. > > - 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. Please add a KVM_NMI section to Documentation/virtual/kvm/api.txt. > > -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 = 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 = 0; > break; > } Why did you drop kvm_vcpu_ioctl_nmi()? Please add (and document) a KVM_CAP flag that lets userspace know the new behaviour is supported. -- error compiling committee.c: too many arguments to function