From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wulvr-0005uC-Ow for qemu-devel@nongnu.org; Wed, 11 Jun 2014 13:03:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wulvg-0001r5-MJ for qemu-devel@nongnu.org; Wed, 11 Jun 2014 13:03:27 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:45527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wulvf-0001q8-UY for qemu-devel@nongnu.org; Wed, 11 Jun 2014 13:03:16 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Jun 2014 03:03:12 +1000 From: Alexey Kardashevskiy Date: Thu, 12 Jun 2014 03:03:03 +1000 Message-Id: <1402506183-29736-5-git-send-email-aik@ozlabs.ru> In-Reply-To: <1402506183-29736-1-git-send-email-aik@ozlabs.ru> References: <1402506183-29736-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH v6 4/4] target-ppc: Add support for new NMI interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Alexey Kardashevskiy , Markus Armbruster , Alexander Graf , Luiz Capitulino , qemu-ppc@nongnu.org, Alex Bligh , Cornelia Huck , Paolo Bonzini , Richard Henderson This implements an NMI interface POWERPC SPAPR machine. This enables an "nmi" HMP/QMP command supported on SPAPR. This calls POWERPC_EXCP_RESET (vector 0x100) in the guest to deliver NMI to every CPU. The expected result is XMON (in-kernel debugger) invocation. Signed-off-by: Alexey Kardashevskiy --- Changes: v6: * support NMI interface v4: * s/\/nmi_monitor_handler/ * added note about XMON into commit log v3: * ppc_cpu_do_nmi() is exported from excp_helper.c instead of powerpc_excp() --- hw/ppc/spapr.c | 27 +++++++++++++++++++++++++++ target-ppc/cpu-qom.h | 1 + target-ppc/excp_helper.c | 8 ++++++++ 3 files changed, 36 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 57e9578..006c37f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -53,6 +53,7 @@ #include "hw/usb.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "hw/nmi.h" #include @@ -1476,10 +1477,34 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus, return NULL; } +#ifndef CONFIG_USER_ONLY +static void ppc_cpu_do_nmi_on_cpu(void *arg) +{ + CPUState *cs = arg; + + cpu_synchronize_state(cs); + ppc_cpu_do_nmi(cs); +} + +static void spapr_nmi(NMI *n, int cpu_index, Error **errp) +{ + CPUState *cs; + + CPU_FOREACH(cs) { + async_run_on_cpu(cs, ppc_cpu_do_nmi_on_cpu, cs); + } +} +#else +static void spapr_nmi(NMI *n, int cpu_index, Error **errp) +{ +} +#endif + static void spapr_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc); + NMIClass *nc = NMI_CLASS(oc); mc->name = "pseries"; mc->desc = "pSeries Logical Partition (PAPR compliant)"; @@ -1493,6 +1518,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->kvm_type = spapr_kvm_type; fwc->get_dev_path = spapr_get_fw_dev_path; + nc->nmi_monitor_handler = spapr_nmi; } static const TypeInfo spapr_machine_info = { @@ -1501,6 +1527,7 @@ static const TypeInfo spapr_machine_info = { .class_init = spapr_machine_class_init, .interfaces = (InterfaceInfo[]) { { TYPE_FW_PATH_PROVIDER }, + { TYPE_NMI }, { } }, }; diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h index 47dc8e6..fe7d602 100644 --- a/target-ppc/cpu-qom.h +++ b/target-ppc/cpu-qom.h @@ -119,6 +119,7 @@ int ppc64_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, void *opaque); #ifndef CONFIG_USER_ONLY +void ppc_cpu_do_nmi(CPUState *cs); extern const struct VMStateDescription vmstate_ppc_cpu; #endif diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c index 7dfc52d..a574ba3 100644 --- a/target-ppc/excp_helper.c +++ b/target-ppc/excp_helper.c @@ -802,6 +802,14 @@ void ppc_hw_interrupt(CPUPPCState *env) } } } + +void ppc_cpu_do_nmi(CPUState *cs) +{ + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + + powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_RESET); +} #endif /* !CONFIG_USER_ONLY */ #if defined(DEBUG_OP) -- 2.0.0