From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws6G6-0006o1-6U for qemu-devel@nongnu.org; Wed, 04 Jun 2014 04:09:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ws6Fv-0005qY-27 for qemu-devel@nongnu.org; Wed, 04 Jun 2014 04:09:18 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:55011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws6Fu-0005pD-8N for qemu-devel@nongnu.org; Wed, 04 Jun 2014 04:09:06 -0400 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Jun 2014 18:08:59 +1000 From: Alexey Kardashevskiy Date: Wed, 4 Jun 2014 18:08:49 +1000 Message-Id: <1401869330-32449-4-git-send-email-aik@ozlabs.ru> In-Reply-To: <1401869330-32449-1-git-send-email-aik@ozlabs.ru> References: <1401869330-32449-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH v3 3/4] target-i386: Migrate to new nmi() CPU callback List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alex Bligh , Alexey Kardashevskiy , Markus Armbruster , Alexander Graf , Luiz Capitulino , qemu-ppc@nongnu.org, Stefan Hajnoczi , Cornelia Huck , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson This defines a nmi() callback for i386 CPU class. This removes #ifdef I386 branch in qmp_inject_nmi so new i386's nmi() callback is going to be used for NMI. This changes code to inject NMI on the current CPU instead of injecting it on every CPU. However that does not seem to be an issue. Since kvm_apic_external_nmi() takes care of preforming operations in the specific CPU thread so no extra measure is required here. Signed-off-by: Alexey Kardashevskiy --- Changes: v3: * now contains both old code removal and new code insertion, easier to track changes * fixed compile for linux-user --- cpus.c | 14 -------------- target-i386/cpu.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cpus.c b/cpus.c index 83223d3..c0c8ac9 100644 --- a/cpus.c +++ b/cpus.c @@ -1468,19 +1468,6 @@ exit: void qmp_inject_nmi(Error **errp) { -#if defined(TARGET_I386) - CPUState *cs; - - CPU_FOREACH(cs) { - X86CPU *cpu = X86_CPU(cs); - - if (!cpu->apic_state) { - cpu_interrupt(cs, CPU_INTERRUPT_NMI); - } else { - apic_deliver_nmi(cpu->apic_state); - } - } -#else CPUState *cs = qemu_get_cpu(monitor_get_cpu_index()); CPUClass *cc = CPU_GET_CLASS(cs); int ret = -1; @@ -1491,5 +1478,4 @@ void qmp_inject_nmi(Error **errp) if (ret) { error_set(errp, QERR_UNSUPPORTED); } -#endif } diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 042a48d..af250a4 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2500,6 +2500,21 @@ static void x86_cpu_reset(CPUState *s) #endif } +static int x86_cpu_nmi(CPUState *cs) +{ + X86CPU *cpu = X86_CPU(cs); + + if (!cpu->apic_state) { + cpu_interrupt(cs, CPU_INTERRUPT_NMI); +#ifndef CONFIG_USER_ONLY + } else { + apic_deliver_nmi(cpu->apic_state); +#endif + } + + return 0; +} + #ifndef CONFIG_USER_ONLY bool cpu_is_bsp(X86CPU *cpu) { @@ -2808,6 +2823,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) xcc->parent_reset = cc->reset; cc->reset = x86_cpu_reset; + cc->nmi = x86_cpu_nmi; cc->reset_dump_flags = CPU_DUMP_FPU | CPU_DUMP_CCOP; cc->class_by_name = x86_cpu_class_by_name; -- 2.0.0