All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Alexey Kardashevskiy <aik@ozlabs.ru>,
	Markus Armbruster <armbru@redhat.com>,
	Alexander Graf <agraf@suse.de>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	qemu-ppc@nongnu.org, Alex Bligh <alex@alex.org.uk>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH v6 2/4] target-s390x: Migrate to new NMI interface
Date: Thu, 12 Jun 2014 03:03:01 +1000	[thread overview]
Message-ID: <1402506183-29736-3-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1402506183-29736-1-git-send-email-aik@ozlabs.ru>

This implements an NMI interface for s390 machine.

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:
v6:
* supported NMI interface

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 --------------
 hw/s390x/s390-virtio.c | 31 +++++++++++++++++++++++++++++++
 target-s390x/cpu.c     |  1 +
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/cpus.c b/cpus.c
index da1f6a9..f3756b4 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1481,20 +1481,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
     nmi(monitor_get_cpu_index(), errp);
 #endif
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 93c7ace..9c5b7b2 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -38,6 +38,7 @@
 #include "hw/s390x/sclp.h"
 #include "hw/s390x/s390_flic.h"
 #include "hw/s390x/s390-virtio.h"
+#include "hw/nmi.h"
 
 //#define DEBUG_S390
 
@@ -51,6 +52,7 @@
 
 #define MAX_BLK_DEVS                    10
 #define ZIPL_FILENAME                   "s390-zipl.rom"
+#define TYPE_NMI_S390                   "s390_nmi"
 
 static VirtIOS390Bus *s390_bus;
 static S390CPU **ipi_states;
@@ -277,6 +279,9 @@ static void s390_init(MachineState *machine)
 
     /* Create VirtIO network adapters */
     s390_create_virtio_net((BusState *)s390_bus, "virtio-net-s390");
+
+    object_property_add_child(OBJECT(machine), "nmi",
+                              object_new(TYPE_NMI_S390), NULL);
 }
 
 static QEMUMachine s390_machine = {
@@ -295,8 +300,34 @@ static QEMUMachine s390_machine = {
     .is_default = 1,
 };
 
+static void s390_nmi(NMI *n, int cpu_index, Error **errp)
+{
+    CPUState *cs = qemu_get_cpu(cpu_index);
+
+    if (s390_cpu_restart(S390_CPU(cs))) {
+        error_set(errp, QERR_UNSUPPORTED);
+    }
+}
+
+static void s390_nmi_class_init(ObjectClass *oc, void *data)
+{
+    NMIClass *nc = NMI_CLASS(oc);
+    nc->nmi_monitor_handler = s390_nmi;
+}
+
+static const TypeInfo s390_nmi_info = {
+    .name          = TYPE_NMI_S390,
+    .parent        = TYPE_OBJECT,
+    .class_init    = s390_nmi_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_NMI },
+        { }
+    },
+};
+
 static void s390_machine_init(void)
 {
+    type_register_static(&s390_nmi_info);
     qemu_register_machine(&s390_machine);
 }
 
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index c3082b7..15142ff 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
-- 
2.0.0

  parent reply	other threads:[~2014-06-11 17:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 17:02 [Qemu-devel] [PATCH v6 0/4] cpus: Add generic "nmi" monitor command support Alexey Kardashevskiy
2014-06-11 17:03 ` [Qemu-devel] [PATCH v6 1/4] cpus: Define callback for QEMU "nmi" command Alexey Kardashevskiy
2014-06-11 17:21   ` Eric Blake
2014-06-12  0:10     ` Alexey Kardashevskiy
2014-06-12  1:46       ` Eric Blake
2014-06-12  3:29         ` Alexey Kardashevskiy
2014-06-12 13:42           ` Eric Blake
2014-06-11 17:03 ` Alexey Kardashevskiy [this message]
2014-06-11 17:29   ` [Qemu-devel] [PATCH v6 2/4] target-s390x: Migrate to new NMI interface Paolo Bonzini
2014-06-12  0:08     ` Alexey Kardashevskiy
2014-06-12  7:42       ` Paolo Bonzini
2014-06-12  8:35         ` Alexey Kardashevskiy
2014-06-12  8:41           ` Paolo Bonzini
2014-06-12  6:31   ` Cornelia Huck
2014-06-12  9:38     ` Alexey Kardashevskiy
2014-06-12  9:39       ` Alexander Graf
2014-06-12  9:55         ` Alexey Kardashevskiy
2014-06-12 11:02       ` Cornelia Huck
2014-06-12 12:33         ` Alexey Kardashevskiy
2014-06-11 17:03 ` [Qemu-devel] [PATCH v6 3/4] target-i386: " Alexey Kardashevskiy
2014-06-11 17:03 ` [Qemu-devel] [PATCH v6 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=1402506183-29736-3-git-send-email-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=agraf@suse.de \
    --cc=alex@alex.org.uk \
    --cc=armbru@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=lcapitulino@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.