From patchwork Thu Dec 15 12:33:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 131598 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 256591007D4 for ; Fri, 16 Dec 2011 00:06:47 +1100 (EST) Received: from localhost ([::1]:39004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbAWK-0003jp-W2 for incoming@patchwork.ozlabs.org; Thu, 15 Dec 2011 07:34:44 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbAVT-0002NG-1E for qemu-devel@nongnu.org; Thu, 15 Dec 2011 07:33:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbAVL-0000bL-Ir for qemu-devel@nongnu.org; Thu, 15 Dec 2011 07:33:50 -0500 Received: from david.siemens.de ([192.35.17.14]:20737) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbAVL-0000b0-5Z for qemu-devel@nongnu.org; Thu, 15 Dec 2011 07:33:43 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id pBFCXYPp014976; Thu, 15 Dec 2011 13:33:34 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id pBFCXW5G003584; Thu, 15 Dec 2011 13:33:34 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Thu, 15 Dec 2011 13:33:19 +0100 Message-Id: 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.14 Cc: Anthony Liguori , Lai Jiangshan , kvm@vger.kernel.org, "Michael S. Tsirkin" , qemu-devel , Blue Swirl Subject: [Qemu-devel] [PATCH v5 04/16] 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 --- 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 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); diff --git a/monitor.c b/monitor.c index 1be222e..6bd0fb1 100644 --- a/monitor.c +++ b/monitor.c @@ -2354,7 +2354,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;