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 2/4] target-s390x: Migrate to new nmi_monitor_handler() CPU callback
Date: Tue, 10 Jun 2014 16:18:01 +1000 [thread overview]
Message-ID: <1402381083-17241-3-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 s390 CPU class.
This removes #ifdef s390 branch in qmp_inject_nmi so new s390's
nmi_monitor_handler() callback is going to be used for NMI.
Since nmi_monitor_handler()-calling code is platform independent,
CPUState::cpu_index is used instead of S390CPU::env.cpu_num.
There should not be any change in behaviour as both @cpu_index and
@cpu_num are global CPU numbers.
Also, s390_cpu_restart() takes care of preforming operations in
the specific CPU thread so no extra measure is required here either.
Since the only error s390_cpu_restart() can return is ENOSYS, convert
it to QERR_UNSUPPORTED.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v5:
* added ENOSYS -> QERR_UNSUPPORTED, qapi/qmp/qerror.h was added for this
v4:
* s/\<nmi\>/nmi_monitor_handler/
v3:
* now contains both old code removal and new code insertion, easier to
track changes
---
Is there any good reason to have @cpu_num in addition to @cpu_index?
Just asking :)
---
cpus.c | 14 --------------
target-s390x/cpu.c | 9 +++++++++
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/cpus.c b/cpus.c
index b9d6602..87188ce 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1480,20 +1480,6 @@ void qmp_inject_nmi(Error **errp)
apic_deliver_nmi(cpu->apic_state);
}
}
-#elif defined(TARGET_S390X)
- CPUState *cs;
- S390CPU *cpu;
-
- CPU_FOREACH(cs) {
- cpu = S390_CPU(cs);
- if (cpu->env.cpu_num == monitor_get_cpu_index()) {
- if (s390_cpu_restart(S390_CPU(cs)) == -1) {
- error_set(errp, QERR_UNSUPPORTED);
- return;
- }
- break;
- }
- }
#else
CPUState *cs = qemu_get_cpu(monitor_get_cpu_index());
CPUClass *cc = CPU_GET_CLASS(cs);
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index c3082b7..8f40bcc 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -27,6 +27,7 @@
#include "qemu-common.h"
#include "qemu/timer.h"
#include "hw/hw.h"
+#include "qapi/qmp/qerror.h"
#ifndef CONFIG_USER_ONLY
#include "sysemu/arch_init.h"
#endif
@@ -160,6 +161,13 @@ static void s390_cpu_full_reset(CPUState *s)
tlb_flush(s, 1);
}
+static void s390_cpu_nmi_monitor_handler(CPUState *cs, Error **errp)
+{
+ if (s390_cpu_restart(S390_CPU(cs))) {
+ error_set(errp, QERR_UNSUPPORTED);
+ }
+}
+
#if !defined(CONFIG_USER_ONLY)
static void s390_cpu_machine_reset_cb(void *opaque)
{
@@ -245,6 +253,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
scc->cpu_reset = s390_cpu_reset;
scc->initial_cpu_reset = s390_cpu_initial_reset;
cc->reset = s390_cpu_full_reset;
+ cc->nmi_monitor_handler = s390_cpu_nmi_monitor_handler;
cc->has_work = s390_cpu_has_work;
cc->do_interrupt = s390_cpu_do_interrupt;
cc->dump_state = s390_cpu_dump_state;
--
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 ` Alexey Kardashevskiy [this message]
2014-06-10 11:48 ` [Qemu-devel] [PATCH v5 2/4] target-s390x: Migrate to new nmi_monitor_handler() CPU callback Cornelia Huck
2014-06-10 6:18 ` [Qemu-devel] [PATCH v5 3/4] target-i386: " Alexey Kardashevskiy
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-3-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).