From patchwork Wed Oct 19 15:21:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 120654 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9A836B71C7 for ; Thu, 20 Oct 2011 02:21:07 +1100 (EST) Received: from localhost ([::1]:39709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGXx0-0005DN-Ob for incoming@patchwork.ozlabs.org; Wed, 19 Oct 2011 11:21:02 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGXwm-0005Bu-Lq for qemu-devel@nongnu.org; Wed, 19 Oct 2011 11:20:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGXwi-0002wT-2Y for qemu-devel@nongnu.org; Wed, 19 Oct 2011 11:20:48 -0400 Received: from [222.73.24.84] (port=52422 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGXwg-0002vn-NI for qemu-devel@nongnu.org; Wed, 19 Oct 2011 11:20:43 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id EF8D717012E; Wed, 19 Oct 2011 23:20:11 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p9JFKAQZ029894; Wed, 19 Oct 2011 23:20:11 +0800 Received: from lai.fc14.fnst ([10.167.225.146]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011101923182328-492572 ; Wed, 19 Oct 2011 23:18:23 +0800 Message-ID: <4E9EEB08.30504@cn.fujitsu.com> Date: Wed, 19 Oct 2011 23:21:44 +0800 From: Lai Jiangshan User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc14 Thunderbird/3.1.4 MIME-Version: 1.0 To: Jan Kiszka References: <20110913093835.GB4265@localhost.localdomain> <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> <4E948842.4030406@web.de> <4E978827.6070008@cn.fujitsu.com> <4E97CE42.9020102@web.de> <4E97D85C.7070107@cn.fujitsu.com> <4E97DB62.9020605@web.de> <4E97FAC7.6080007@cn.fujitsu.com> <4E9AA657.1050503@redhat.com> <4E9BF821.2070805@cn.fujitsu.com> <4E9BFA40.5070806@redhat.com> <4E9C5106.5070506@cn.fujitsu.com> <4E9DD659.1050005@web.de> <4E9E6F3D.1060802@cn.fujitsu.com> <4E9EAD01.50605@siemens.com> In-Reply-To: <4E9EAD01.50605@siemens.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-10-19 23:18:23, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-10-19 23:18:23, Serialize complete at 2011-10-19 23:18:23 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) X-Received-From: 222.73.24.84 Cc: "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" , Avi Kivity , KAMEZAWA Hiroyuki , Kenji Kaneshige Subject: [Qemu-devel] [PATCH 1/1 V6] qemu: fix improper nmi emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 10/19/2011 06:57 PM, Jan Kiszka wrote: >>> >>> Looks OK to me. >>> >>> Please don't forget to bake a qemu-only patch for those bits that apply >>> to upstream as well (ie. the user space APIC path). >>> >>> Jan >>> >> >> I did forget it. >> Did you mean we need to add "#ifdef KVM_CAP_IRQCHIP" back? > > No. I meant basically your patch minus the kvm_in_kernel_irqchip code > paths, applicable against current qemu.git. Those paths will be re-added > (slightly differently) when upstream gains that support. I'm working on > a basic version an will incorporate the logic if your qemu patch is > already available. > > Jan > Patch for qemu.git From: Lai Jiangshan 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 masked 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, inject-nmi request is handled as delivering LINT1. Signed-off-by: Lai Jiangshan Reported-by: Kenji Kaneshige --- hw/apic.c | 7 +++++++ hw/apic.h | 1 + monitor.c | 6 +++++- 3 files changed, 13 insertions(+), 1 deletions(-) diff --git a/hw/apic.c b/hw/apic.c index 8289eef..c8dc997 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -205,6 +205,13 @@ void apic_deliver_pic_intr(DeviceState *d, int level) } } +void apic_deliver_nmi(DeviceState *d) +{ + APICState *s = DO_UPCAST(APICState, busdev.qdev, d); + + apic_local_deliver(s, APIC_LVT_LINT1); +} + #define foreach_apic(apic, deliver_bitmask, code) \ {\ int __i, __j, __mask;\ diff --git a/hw/apic.h b/hw/apic.h index a5c910f..a62d83b 100644 --- a/hw/apic.h +++ b/hw/apic.h @@ -8,6 +8,7 @@ void apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode, uint8_t vector_num, uint8_t trigger_mode); int apic_accept_pic_intr(DeviceState *s); void apic_deliver_pic_intr(DeviceState *s, int level); +void apic_deliver_nmi(DeviceState *d); int apic_get_interrupt(DeviceState *s); void apic_reset_irq_delivered(void); int apic_get_irq_delivered(void); diff --git a/monitor.c b/monitor.c index ffda0fe..144099a 100644 --- a/monitor.c +++ b/monitor.c @@ -2501,7 +2501,11 @@ static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data) CPUState *env; for (env = first_cpu; env != NULL; env = env->next_cpu) { - cpu_interrupt(env, CPU_INTERRUPT_NMI); + if (!env->apic_state) { + cpu_interrupt(env, CPU_INTERRUPT_NMI); + } else { + apic_deliver_nmi(env->apic_state); + } } return 0;