From nobody Sat Jul 12 15:17:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486013565871625.265312447564; Wed, 1 Feb 2017 21:32:45 -0800 (PST) Received: from localhost ([::1]:54291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZA0h-00077r-VH for importer@patchew.org; Thu, 02 Feb 2017 00:32:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9ji-0007Bq-40 for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZ9jf-0003Zh-KE for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:10 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:54809) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZ9jf-0003V4-2D; Thu, 02 Feb 2017 00:15:07 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vDSqN14bDz9s7c; Thu, 2 Feb 2017 16:14:55 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1486012496; bh=4VHy6PfgR2p1d9vjtcm2W/LcPoCejSuakTea4qTVGhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N8IoOEf+GHSKsmmeZ7msABiBtjrounWXUI0qhW3K0lQFtH+t09KtqkOkJfYNXhROP kQYcS4FW6rqprmh4GwgDyVr58mQOYIyI54l7uB+cHQw4HY/VFnWSZo7Cr2mLvqgnEs igTmwBer0/Eux+W5rd4wCyZTS7yJDli3X73MO8o4= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 2 Feb 2017 16:13:17 +1100 Message-Id: <20170202051445.5735-20-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170202051445.5735-1-david@gibson.dropbear.id.au> References: <20170202051445.5735-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 019/107] ppc/spapr: implement H_SIGNAL_SYS_RESET X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, Nicholas Piggin , agraf@suse.de, aik@ozlabs.ru, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin The H_SIGNAL_SYS_RESET hcall allows a guest CPU to raise a system reset exception on CPUs within the same guest -- all CPUs, all-but-self, or a specific CPU (including self). This has not made its way to a PAPR release yet, but we have an hcall number assigned. H_SIGNAL_SYS_RESET =3D 0x380 Syntax: hcall(uint64 H_SIGNAL_SYS_RESET, int64 target); Generate a system reset NMI on the threads indicated by target. Values for target: -1 =3D target all online threads including the caller -2 =3D target all online threads except for the caller All other negative values: reserved Positive values: The thread to be targeted, obtained from the value of the "ibm,ppc-interrupt-server#s" property of the CPU in the OF device tree. Semantics: - Invalid target: return H_Parameter. - Otherwise: Generate a system reset NMI on target thread(s), return H_Success. Signed-off-by: Nicholas Piggin Signed-off-by: David Gibson --- hw/ppc/spapr.c | 4 ++-- hw/ppc/spapr_hcall.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 5 ++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index cd95435..74419f8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2265,7 +2265,7 @@ static void spapr_machine_finalizefn(Object *obj) g_free(spapr->kvm_type); } =20 -static void ppc_cpu_do_nmi_on_cpu(CPUState *cs, run_on_cpu_data arg) +void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg) { cpu_synchronize_state(cs); ppc_cpu_do_system_reset(cs); @@ -2276,7 +2276,7 @@ static void spapr_nmi(NMIState *n, int cpu_index, Err= or **errp) CPUState *cs; =20 CPU_FOREACH(cs) { - async_run_on_cpu(cs, ppc_cpu_do_nmi_on_cpu, RUN_ON_CPU_NULL); + async_run_on_cpu(cs, spapr_do_system_reset_on_cpu, RUN_ON_CPU_NULL= ); } } =20 diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 4fbcb03..51681f3 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -881,6 +881,46 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPRM= achineState *spapr, return ret; } =20 +#define H_SIGNAL_SYS_RESET_ALL -1 +#define H_SIGNAL_SYS_RESET_ALLBUTSELF -2 + +static target_ulong h_signal_sys_reset(PowerPCCPU *cpu, + sPAPRMachineState *spapr, + target_ulong opcode, target_ulong *= args) +{ + target_long target =3D args[0]; + CPUState *cs; + + if (target < 0) { + /* Broadcast */ + if (target < H_SIGNAL_SYS_RESET_ALLBUTSELF) { + return H_PARAMETER; + } + + CPU_FOREACH(cs) { + PowerPCCPU *c =3D POWERPC_CPU(cs); + + if (target =3D=3D H_SIGNAL_SYS_RESET_ALLBUTSELF) { + if (c =3D=3D cpu) { + continue; + } + } + run_on_cpu(cs, spapr_do_system_reset_on_cpu, RUN_ON_CPU_NULL); + } + return H_SUCCESS; + + } else { + /* Unicast */ + CPU_FOREACH(cs) { + if (cpu->cpu_dt_id =3D=3D target) { + run_on_cpu(cs, spapr_do_system_reset_on_cpu, RUN_ON_CPU_NU= LL); + return H_SUCCESS; + } + } + return H_PARAMETER; + } +} + typedef struct { uint32_t compat_pvr; Error *err; @@ -1097,6 +1137,7 @@ static void hypercall_register_types(void) /* hcall-splpar */ spapr_register_hypercall(H_REGISTER_VPA, h_register_vpa); spapr_register_hypercall(H_CEDE, h_cede); + spapr_register_hypercall(H_SIGNAL_SYS_RESET, h_signal_sys_reset); =20 /* processor register resource access h-calls */ spapr_register_hypercall(H_SET_SPRG0, h_set_sprg0); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 04d2821..a2d8964 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -347,7 +347,8 @@ struct sPAPRMachineState { #define H_XIRR_X 0x2FC #define H_RANDOM 0x300 #define H_SET_MODE 0x31C -#define MAX_HCALL_OPCODE H_SET_MODE +#define H_SIGNAL_SYS_RESET 0x380 +#define MAX_HCALL_OPCODE H_SIGNAL_SYS_RESET =20 /* The hcalls above are standardized in PAPR and implemented by pHyp * as well. @@ -660,4 +661,6 @@ int spapr_rng_populate_dt(void *fdt); #define SPAPR_LMB_FLAGS_DRC_INVALID 0x00000020 #define SPAPR_LMB_FLAGS_RESERVED 0x00000080 =20 +void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg); + #endif /* HW_SPAPR_H */ --=20 2.9.3