Received: from eggs.gnu.org ([2001:4830:134:3::10]:49411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuFOB-0002G6-4u for qemu-devel@nongnu.org; Tue, 10 Jun 2014 02:18:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuFNv-0003HZ-GK for qemu-devel@nongnu.org; Tue, 10 Jun 2014 02:18:31 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:38037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuFNu-0003Gq-Q2 for qemu-devel@nongnu.org; Tue, 10 Jun 2014 02:18:15 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Jun 2014 16:18:12 +1000 From: Alexey Kardashevskiy Date: Tue, 10 Jun 2014 16:18:03 +1000 Message-Id: <1402381083-17241-5-git-send-email-aik@ozlabs.ru> In-Reply-To: <1402381083-17241-1-git-send-email-aik@ozlabs.ru> References: <1402381083-17241-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH v5 4/4] target-ppc: Add support for new nmi_monitor_handler() CPU callback List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexey Kardashevskiy , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini This defines a nmi_monitor_handler() callback for POWERPC CPU class so the "nmi" HMP/QMP command gets supported for POWERPC machines. This calls POWERPC_EXCP_RESET (vector 0x100) in the guest to deliver NMI. The expected result is XMON (in-kernel debugger) invocation. Signed-off-by: Alexey Kardashevskiy --- Changes: 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() --- target-ppc/cpu-qom.h | 1 + target-ppc/excp_helper.c | 8 ++++++++ target-ppc/translate_init.c | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) 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) diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 4d94015..ee28c27 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -8510,6 +8510,21 @@ static void ppc_cpu_initfn(Object *obj) } } +#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 ppc_cpu_nmi_monitor_handler(CPUState *cs, Error **errp) +{ + async_run_on_cpu(cs, ppc_cpu_do_nmi_on_cpu, cs); +} +#endif + static void ppc_cpu_class_init(ObjectClass *oc, void *data) { PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); @@ -8536,6 +8551,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = ppc_cpu_handle_mmu_fault; #else + cc->nmi_monitor_handler = ppc_cpu_nmi_monitor_handler; cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu; #if defined(TARGET_PPC64) -- 2.0.0