From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XK4p6-0007ze-2t for qemu-devel@nongnu.org; Wed, 20 Aug 2014 08:17:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XK4ov-0004aI-Ep for qemu-devel@nongnu.org; Wed, 20 Aug 2014 08:17:04 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:47601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XK4ou-0004ZX-Qt for qemu-devel@nongnu.org; Wed, 20 Aug 2014 08:16:53 -0400 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Aug 2014 22:16:47 +1000 From: Alexey Kardashevskiy Date: Wed, 20 Aug 2014 22:16:35 +1000 Message-Id: <1408536997-2075-4-git-send-email-aik@ozlabs.ru> In-Reply-To: <1408536997-2075-1-git-send-email-aik@ozlabs.ru> References: <1408536997-2075-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH v8 3/5] s390x: Migrate to new NMI interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , Cornelia Huck , qemu-ppc@nongnu.org, Alexander Graf , Paolo Bonzini This implements an NMI interface for s390 and s390-ccw machines. 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. Note that s390_cpu_restart() already takes care of the specified cpu, so we don't need to schedule via async_run_on_cpu(). Since the only error s390_cpu_restart() can return is ENOSYS, convert it to QERR_UNSUPPORTED. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Alexander Graf Reviewed-by: Cornelia Huck --- Changes: v8: * adjusted commit log v7: * since now s390' are QOM'ed, add interface to them and do not create new object v6: * supported NMI interface v5: * added ENOSYS -> QERR_UNSUPPORTED, qapi/qmp/qerror.h was added for this v4: * s/\/nmi_monitor_handler/ v3: * now contains both old code removal and new code insertion, easier to track changes --- cpus.c | 14 -------------- hw/s390x/s390-virtio-ccw.c | 6 ++++++ hw/s390x/s390-virtio.c | 15 +++++++++++++++ hw/s390x/s390-virtio.h | 3 +++ 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/cpus.c b/cpus.c index 37d90f4..eb1ac85 100644 --- a/cpus.c +++ b/cpus.c @@ -1537,20 +1537,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_handle(monitor_get_cpu_index(), errp); #endif diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 05311b8..004b2c2 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -139,6 +139,7 @@ static void ccw_init(MachineState *machine) static void ccw_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); + NMIClass *nc = NMI_CLASS(oc); mc->name = "s390-ccw-virtio"; mc->alias = "s390-ccw"; @@ -152,12 +153,17 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) mc->no_sdcard = 1; mc->use_sclp = 1, mc->max_cpus = 255; + nc->nmi_monitor_handler = s390_nmi; } static const TypeInfo ccw_machine_info = { .name = TYPE_S390_CCW_MACHINE, .parent = TYPE_MACHINE, .class_init = ccw_machine_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_NMI }, + { } + }, }; static void ccw_machine_register_types(void) diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index f1e0dbc..1a75a1c 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -280,9 +280,19 @@ static void s390_init(MachineState *machine) s390_create_virtio_net((BusState *)s390_bus, "virtio-net-s390"); } +void s390_nmi(NMIState *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_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); + NMIClass *nc = NMI_CLASS(oc); mc->name = "s390-virtio"; mc->alias = "s390"; @@ -297,12 +307,17 @@ static void s390_machine_class_init(ObjectClass *oc, void *data) mc->no_cdrom = 1; mc->no_sdcard = 1; mc->is_default = 1; + nc->nmi_monitor_handler = s390_nmi; } static const TypeInfo s390_machine_info = { .name = TYPE_S390_MACHINE, .parent = TYPE_MACHINE, .class_init = s390_machine_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_NMI }, + { } + }, }; static void s390_machine_register_types(void) diff --git a/hw/s390x/s390-virtio.h b/hw/s390x/s390-virtio.h index 5c405e7..33847ae 100644 --- a/hw/s390x/s390-virtio.h +++ b/hw/s390x/s390-virtio.h @@ -12,6 +12,8 @@ #ifndef HW_S390_VIRTIO_H #define HW_S390_VIRTIO_H 1 +#include "hw/nmi.h" + #define KVM_S390_VIRTIO_NOTIFY 0 #define KVM_S390_VIRTIO_RESET 1 #define KVM_S390_VIRTIO_SET_STATUS 2 @@ -26,4 +28,5 @@ void s390_init_ipl_dev(const char *kernel_filename, const char *initrd_filename, const char *firmware); void s390_create_virtio_net(BusState *bus, const char *name); +void s390_nmi(NMIState *n, int cpu_index, Error **errp); #endif -- 2.0.0