From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
Alexander Graf <agraf@suse.de>,
qemu-ppc@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH v5 3/4] target-i386: Migrate to new nmi_monitor_handler() CPU callback
Date: Tue, 10 Jun 2014 16:18:02 +1000 [thread overview]
Message-ID: <1402381083-17241-4-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1402381083-17241-1-git-send-email-aik@ozlabs.ru>
This defines a nmi_monitor_handler() 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 <aik@ozlabs.ru>
---
Changes:
v4:
* s/\<nmi\>/nmi_monitor_handler/
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 | 14 ++++++++++++++
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/cpus.c b/cpus.c
index 87188ce..463f8d0 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);
@@ -1489,5 +1476,4 @@ void qmp_inject_nmi(Error **errp)
} else {
error_set(errp, QERR_UNSUPPORTED);
}
-#endif
}
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index dde052c..96e268e 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2497,6 +2497,19 @@ static void x86_cpu_reset(CPUState *s)
#endif
}
+static void x86_cpu_nmi_monitor_handler(CPUState *cs, Error **errp)
+{
+ 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
+ }
+}
+
#ifndef CONFIG_USER_ONLY
bool cpu_is_bsp(X86CPU *cpu)
{
@@ -2806,6 +2819,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
xcc->parent_reset = cc->reset;
cc->reset = x86_cpu_reset;
+ cc->nmi_monitor_handler = x86_cpu_nmi_monitor_handler;
cc->reset_dump_flags = CPU_DUMP_FPU | CPU_DUMP_CCOP;
cc->class_by_name = x86_cpu_class_by_name;
--
2.0.0
next prev parent reply other threads:[~2014-06-10 6:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-10 6:17 [Qemu-devel] [PATCH v5 0/4] cpus: Add generic "nmi" monitor command support Alexey Kardashevskiy
2014-06-10 6:18 ` [Qemu-devel] [PATCH v5 1/4] cpus: Define callback for QEMU "nmi" command Alexey Kardashevskiy
2014-06-10 11:43 ` Cornelia Huck
2014-06-10 11:45 ` Paolo Bonzini
2014-06-10 15:39 ` Alexey Kardashevskiy
2014-06-10 6:18 ` [Qemu-devel] [PATCH v5 2/4] target-s390x: Migrate to new nmi_monitor_handler() CPU callback Alexey Kardashevskiy
2014-06-10 11:48 ` Cornelia Huck
2014-06-10 6:18 ` Alexey Kardashevskiy [this message]
2014-06-10 6:18 ` [Qemu-devel] [PATCH v5 4/4] target-ppc: Add support for " Alexey Kardashevskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1402381083-17241-4-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).