From patchwork Mon Jan 16 15:55:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 136287 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 8B410B6EEB for ; Tue, 17 Jan 2012 02:56:48 +1100 (EST) Received: from localhost ([::1]:45863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmovJ-0001BQ-6B for incoming@patchwork.ozlabs.org; Mon, 16 Jan 2012 10:56:41 -0500 Received: from eggs.gnu.org ([140.186.70.92]:54680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rmous-0000Qa-Ey for qemu-devel@nongnu.org; Mon, 16 Jan 2012 10:56:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rmouk-0002o1-VW for qemu-devel@nongnu.org; Mon, 16 Jan 2012 10:56:14 -0500 Received: from goliath.siemens.de ([192.35.17.28]:24758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rmouk-0002nd-Ab for qemu-devel@nongnu.org; Mon, 16 Jan 2012 10:56:06 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id q0GFtssJ029696; Mon, 16 Jan 2012 16:55:55 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q0GFtqku023489; Mon, 16 Jan 2012 16:55:54 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Mon, 16 Jan 2012 16:55:38 +0100 Message-Id: <4ea6e24ac157f4a4bcc599746cbbfc1039373fb9.1326729350.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.28 Cc: Anthony Liguori , Lai Jiangshan , kvm@vger.kernel.org, "Michael S. Tsirkin" , qemu-devel , Blue Swirl Subject: [Qemu-devel] [PATCH v7 04/18] apic: Inject external NMI events via LINT1 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 real hardware, NMI button events are injected via the LINT1 line of the APICs. E.g. kdump expect this wiring and gets upset if the per-APIC LINT1 mask is not respected, i.e. if NMIs are injected to VCPUs that should not receive them. Change the APIC emulation code to reflect this. Based on qemu-kvm patch by Lai Jiangshan. CC: Lai Jiangshan Reported-by: Kenji Kaneshige Signed-off-by: Jan Kiszka --- cpus.c | 6 +++++- hw/apic.c | 7 +++++++ hw/apic.h | 1 + 3 files changed, 13 insertions(+), 1 deletions(-) diff --git a/cpus.c b/cpus.c index b421a71..857f96f 100644 --- a/cpus.c +++ b/cpus.c @@ -1225,7 +1225,11 @@ void qmp_inject_nmi(Error **errp) 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); + } } #else error_set(errp, QERR_UNSUPPORTED); diff --git a/hw/apic.c b/hw/apic.c index 4b97b17..b9d733c 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);