From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDljb-0003zX-AO for qemu-devel@nongnu.org; Mon, 05 Dec 2016 00:22:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDljZ-0000Lz-Vq for qemu-devel@nongnu.org; Mon, 05 Dec 2016 00:22:39 -0500 Date: Mon, 5 Dec 2016 16:12:41 +1100 From: David Gibson Message-ID: <20161205051241.GG32366@umbus.fritz.box> References: <20161205035647.17406-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="L1c6L/cjZjI9d0Eq" Content-Disposition: inline In-Reply-To: <20161205035647.17406-1-npiggin@gmail.com> Subject: Re: [Qemu-devel] [PATCH] 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 --L1c6L/cjZjI9d0Eq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 05, 2016 at 02:56:47PM +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 This is much too late for qemu-2.8, so can you please rebase this onto my ppc-for-2.9 branch - it doesn't apply clean there. > --- > Hi, >=20 > I have taken into account feedback since last posting, the comments > were appreciated. >=20 > http://lists.nongnu.org/archive/html/qemu-devel/2016-10/msg04881.html >=20 > - Improved changelog description. > - Shared code with QEMU NMI injection. > - Move hcall-specific parameter definitions out of header. > - Added an "unofficial" PAPR specification to changelog. >=20 > There is interest to improve the community process with PAPR > development, but I can't say if/when/how, so this is the best I can do. >=20 > * Some additional background information follows * >=20 > The Linux powerpc branch has a corresponding change to add this hcall > definition: >=20 > https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/commit/?= h=3Dnext&id=3D53ce299615e587e900548eb6b384c3081b71bbfa >=20 > The motivation is to allow a crash or debug event to pull stuck > (interrupts disabled) CPUs into the crash/debug handlers. This is in > response to a problem encountered in the wild on a customer machine. > Linux guest patches to that end were posted for review: >=20 > https://lists.ozlabs.org/pipermail/linuxppc-dev/2016-November/150684.ht= ml >=20 > Additionally, there is ongoing firmware effort to provide a similar > service for non-virtualized environments: >=20 > https://lists.ozlabs.org/pipermail/skiboot/2016-November/005481.html >=20 > Thanks, > Nick >=20 > 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 208ef7b..5d2adf8 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -2252,7 +2252,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); > @@ -2263,7 +2263,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 9a9bedf..b61ac9d 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 cpu_version; > Error *err; > @@ -1101,6 +1141,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 bd5bcf7..443c425 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. > @@ -662,4 +663,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 --L1c6L/cjZjI9d0Eq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYRPdHAAoJEGw4ysog2bOSEK0P/21sHwwGPtZgYlc5ACAxBaq6 78ujqlP/c/dtZwveQnvElE+W5D61StAoZKUwMps2LIfxKKdG1rTGEpr8Xy34mH7+ 024FWpfNAIUvIgJBYQGj+1kb4ThQA7ZHhuMAr8NJKNFN3ffZrLhPQlSMem7wGN5L aJNzHNsTnRKL1tSlfy7nusDdbeB4+j55lbDLbvBgnwDavOXG5d3O8SLJ92We70dF FADsMAdwdJ9PyN1Cvaqyk9ecS5i6nno86bH+2coa4f5fCE7rMupNI5PaVvXei60X xP0kObR55/FqsWPF8qCG1yrw+ObeFPjbnYEz5zc7TihOfbsOvyrazkPLjSteYv+W dwb+Mkw5sS3Qu1OHSGVcTiI8GhUzl2TU3wzDia1WnNpokOferEOicNs9MeEQI4JV 7Ea6sfEW8R1co8MExhdpDNUq2UYk0jZmXkBivZCfPB/Ts4CCduIKlIal3KApPuPj 3XYg/p1mhMN2MmxEJ6p4Ax9uuzXgDb86BJqDJ6Ve0qlhGccFJMOpJJxUhk5XdZw8 f1GA0AiLe2ln5Azmk7cT0mpM4iKGH7o1e9SwH5psk1vRm7F6dwwnWpsSRLLTdfUB Io+jG42v8y56ahaxQ6ptY5yP1UV1ukzM2kI/9IRKxwp5iRzRzgRclvi3NYQDXXPL qQqvPCNjVlcMyu8V1333 =2w2w -----END PGP SIGNATURE----- --L1c6L/cjZjI9d0Eq--