Received: from eggs.gnu.org ([2001:4830:134:3::10]:35445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDo1r-0000C9-7S for qemu-devel@nongnu.org; Mon, 05 Dec 2016 02:49:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDo1p-0001ca-Tq for qemu-devel@nongnu.org; Mon, 05 Dec 2016 02:49:39 -0500 Date: Mon, 5 Dec 2016 17:07:00 +1100 From: David Gibson Message-ID: <20161205060700.GI32366@umbus.fritz.box> References: <20161205055021.4985-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4LwthZj+AV2mq5CX" Content-Disposition: inline In-Reply-To: <20161205055021.4985-1-npiggin@gmail.com> Subject: Re: [Qemu-devel] [PATCH ppc-for-2.9] ppc/spapr: implement H_SIGNAL_SYS_RESET List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nicholas Piggin Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Thomas Huth , Greg Kurz --4LwthZj+AV2mq5CX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 05, 2016 at 04:50:21PM +1100, Nicholas Piggin wrote: > 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). >=20 > This has not made its way to a PAPR release yet, but we have an hcall > number assigned. >=20 > H_SIGNAL_SYS_RESET =3D 0x380 >=20 > Syntax: > hcall(uint64 H_SIGNAL_SYS_RESET, int64 target); >=20 > Generate a system reset NMI on the threads indicated by target. >=20 > 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. >=20 > Semantics: > - Invalid target: return H_Parameter. > - Otherwise: Generate a system reset NMI on target thread(s), > return H_Success. >=20 > Signed-off-by: Nicholas Piggin Applied to ppc-for-2.9, thanks. > --- > hw/ppc/spapr.c | 4 ++-- > hw/ppc/spapr_hcall.c | 41 +++++++++++++++++++++++++++++++++++++++++ > include/hw/ppc/spapr.h | 5 ++++- > 3 files changed, 47 insertions(+), 3 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 684d1d4..b693ab5 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, E= rror **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_NU= LL); > } > } > =20 > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > index 35499ae..fd9f1d4 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, sPAP= RMachineState *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_= NULL); > + 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 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --4LwthZj+AV2mq5CX Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYRQQCAAoJEGw4ysog2bOS8tcQAKDTsuzpCYDMa6rmUy3EBZnv b4aoDNuPoZVCan+J4DzAeSDmOzA5u8WT9sNAH4Hyxk94tiC7gRGIfg28Ej7W5zi4 AZDh1Fs4NcJdzR1NdNqmkXP0gsYLu7Gl/pZ3yx8d5XnE23/Oy9UidIfbTqzvkuaY OnucSOSML13FIQqq/9V3OLo+htKzNCq4UdPaLtmR+SBGyB1nODvm4YMT82zBAvgJ Asx7eKdsK+UsxApgXps8LDP9F9P3xqeDgeWN6n/SUKrUD37Uw6QWyVYcLuNyE6d2 qdiCC7SqLfnGM+I/LFMuyXaqxMtoedAZ165Iz8vHSgURVV+5dMQ0kd0wgWEvfQJF VAjblmNGFxtxxSZCKXKzEGfX84oQ8m2Ucq4qiqDbjI5hXLDH66hGE8bSUIm3c4aN DuBLxD8nqkT9btTasI20DGAsUhviR7SRx+VJT/M6YgXfzB2tTMTiJrbBX0QlDghO n9Zd2CYm2DEuI26O6u9JqtD5RHZNI+r+bQxkrPEyLnfxw7zphBk7an7zt8qDtdf5 a4DEVFeRA7WvzbUHwWP5TmDoW/mGB1Mbfwv6tSv6F4l6NPDTG0w/qlA5YWqE6in9 sy5Y9lQoSM0zMXJXAJyxbxXFfV9A+BtKRSIXIoE1QJix0RHEDf6qniAvwApaeLJz IN3xeWHBLrCwaZFVieCq =XRFY -----END PGP SIGNATURE----- --4LwthZj+AV2mq5CX--