From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWaEJ-0006pk-JO for qemu-devel@nongnu.org; Mon, 31 Aug 2015 21:19:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWaEI-0004Bp-6f for qemu-devel@nongnu.org; Mon, 31 Aug 2015 21:19:19 -0400 Date: Tue, 1 Sep 2015 11:06:56 +1000 From: David Gibson Message-ID: <20150901010656.GP11475@voom.redhat.com> References: <1440746120-21577-1-git-send-email-gwshan@linux.vnet.ibm.com> <1440746120-21577-8-git-send-email-gwshan@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="OmL7C/BU0IhhC9Of" Content-Disposition: inline In-Reply-To: <1440746120-21577-8-git-send-email-gwshan@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v7 7/8] sPAPR: Support RTAS call ibm, {open, close}-errinjct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gavin Shan Cc: aik@ozlabs.ru, peter.maydell@linaro.org, thuth@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org --OmL7C/BU0IhhC9Of Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 28, 2015 at 05:15:19PM +1000, Gavin Shan wrote: > This supports RTAS calls "ibm,{open,close}-errinjct" to manupliate > the token, which is passed to RTAS call "ibm,errinjct" to indicate > the valid context for error injection. Each VM is permitted to have > only one token at once and we simply have sequential number for that. > The token is resetted in ppc_spapr_reset() when rebooting guest. It's > notable that the least bit of the token is reserved to indicate if the > token has been opened, meaning the valid token should be always odd. >=20 > Signed-off-by: Gavin Shan Reviewed-by: David Gibson > --- > hw/ppc/spapr.c | 9 +++++++- > hw/ppc/spapr_rtas.c | 60 ++++++++++++++++++++++++++++++++++++++++++++= ++++++ > include/hw/ppc/spapr.h | 9 +++++++- > 3 files changed, 76 insertions(+), 2 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 06d000d..6ac0012 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -1064,6 +1064,9 @@ static void ppc_spapr_reset(void) > =20 > qemu_devices_reset(); > =20 > + /* Reset error injection token */ > + spapr->errinjct_token =3D 0; > + > /* > * We place the device tree and RTAS just below either the top of th= e RMA, > * or just below 2GB, whichever is lowere, so that it can be > @@ -1191,7 +1194,7 @@ static bool version_before_3(void *opaque, int vers= ion_id) > =20 > static const VMStateDescription vmstate_spapr =3D { > .name =3D "spapr", > - .version_id =3D 3, > + .version_id =3D 4, > .minimum_version_id =3D 1, > .post_load =3D spapr_post_load, > .fields =3D (VMStateField[]) { > @@ -1202,6 +1205,10 @@ static const VMStateDescription vmstate_spapr =3D { > VMSTATE_UINT64_TEST(rtc_offset, sPAPRMachineState, version_befor= e_3), > =20 > VMSTATE_PPC_TIMEBASE_V(tb, sPAPRMachineState, 2), > + > + /* Error injection token */ > + VMSTATE_UINT32_V(errinjct_token, sPAPRMachineState, 4), > + > VMSTATE_END_OF_LIST() > }, > }; > diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c > index e99e25f..64924c6 100644 > --- a/hw/ppc/spapr_rtas.c > +++ b/hw/ppc/spapr_rtas.c > @@ -604,6 +604,62 @@ out: > rtas_st(rets, 0, rc); > } > =20 > +static void rtas_ibm_open_errinjct(PowerPCCPU *cpu, > + sPAPRMachineState *spapr, > + uint32_t token, uint32_t nargs, > + target_ulong args, uint32_t nret, > + target_ulong rets) > +{ > + int32_t ret; > + > + /* Sanity check on number of arguments */ > + if (nargs !=3D 0 || nret !=3D 2) { > + ret =3D RTAS_OUT_PARAM_ERROR; > + goto out; > + } > + > + /* Check if we already had token */ > + if (spapr->errinjct_token & 1) { > + ret =3D RTAS_OUT_TOKEN_OPENED; > + goto out; > + } > + > + /* Grab the token */ > + rtas_st(rets, 0, ++spapr->errinjct_token); > + ret =3D RTAS_OUT_SUCCESS; > +out: > + rtas_st(rets, 1, ret); > +} > + > +static void rtas_ibm_close_errinjct(PowerPCCPU *cpu, > + sPAPRMachineState *spapr, > + uint32_t token, uint32_t nargs, > + target_ulong args, uint32_t nret, > + target_ulong rets) > +{ > + uint32_t open_token; > + int32_t ret; > + > + /* Sanity check on number of arguments */ > + if (nargs !=3D 1 || nret !=3D 1) { > + ret =3D RTAS_OUT_PARAM_ERROR; > + goto out; > + } > + > + /* Match with the passed token */ > + open_token =3D rtas_ld(args, 0); > + if (!(spapr->errinjct_token & 1) || > + spapr->errinjct_token !=3D open_token) { > + ret =3D RTAS_OUT_CLOSE_ERROR; > + goto out; > + } > + > + spapr->errinjct_token++; > + ret =3D RTAS_OUT_SUCCESS; > +out: > + rtas_st(rets, 0, ret); > +} > + > static struct rtas_call { > const char *name; > spapr_rtas_fn fn; > @@ -754,6 +810,10 @@ static void core_rtas_register_types(void) > rtas_get_sensor_state); > spapr_rtas_register(RTAS_IBM_CONFIGURE_CONNECTOR, "ibm,configure-con= nector", > rtas_ibm_configure_connector); > + spapr_rtas_register(RTAS_IBM_OPEN_ERRINJCT, "ibm,open-errinjct", > + rtas_ibm_open_errinjct); > + spapr_rtas_register(RTAS_IBM_CLOSE_ERRINJCT, "ibm,close-errinjct", > + rtas_ibm_close_errinjct); > } > =20 > type_init(core_rtas_register_types) > diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h > index c75cc5e..7931e18 100644 > --- a/include/hw/ppc/spapr.h > +++ b/include/hw/ppc/spapr.h > @@ -73,6 +73,9 @@ struct sPAPRMachineState { > int htab_fd; > bool htab_fd_stale; > =20 > + /* Error injection token */ > + uint32_t errinjct_token; > + > /* RTAS state */ > QTAILQ_HEAD(, sPAPRConfigureConnectorState) ccs_list; > =20 > @@ -412,6 +415,8 @@ int spapr_allocate_irq_block(int num, bool lsi, bool = msi); > #define RTAS_OUT_BUSY -2 > #define RTAS_OUT_PARAM_ERROR -3 > #define RTAS_OUT_NOT_SUPPORTED -3 > +#define RTAS_OUT_TOKEN_OPENED -4 > +#define RTAS_OUT_CLOSE_ERROR -4 > #define RTAS_OUT_NOT_AUTHORIZED -9002 > =20 > /* RTAS tokens */ > @@ -455,8 +460,10 @@ int spapr_allocate_irq_block(int num, bool lsi, bool= msi); > #define RTAS_IBM_SET_SLOT_RESET (RTAS_TOKEN_BASE + 0x23) > #define RTAS_IBM_CONFIGURE_PE (RTAS_TOKEN_BASE + 0x24) > #define RTAS_IBM_SLOT_ERROR_DETAIL (RTAS_TOKEN_BASE + 0x25) > +#define RTAS_IBM_OPEN_ERRINJCT (RTAS_TOKEN_BASE + 0x26) > +#define RTAS_IBM_CLOSE_ERRINJCT (RTAS_TOKEN_BASE + 0x27) > =20 > -#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x26) > +#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x28) > =20 > /* RTAS ibm,get-system-parameter token values */ > #define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20 --=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 --OmL7C/BU0IhhC9Of Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJV5PowAAoJEGw4ysog2bOSQ+cQAIGf29mR6d658FVPmH8tKb3T sujYvryRl8HGbuXOF2Fa3tvTLnuNbnTLVTzLBzR3vyjpOIFywU8tZoxBzKJMglbo Cj2YroOF1Gb7ru2M2IzILFY2i6+VLas4iWrLHWPEQIJ5iNnadxUYiEXWF1BI6m+i LcS9uJEYegwvvjP2YrSj1jQmQH6k0qWAeuvWwcCZoKu7zKNN4WYRd7EpF2CME2pZ cdgEG8PFoT7bBBv33yPo+P4zlS2NXrUsGDtdjbsdPcWJvhZ9Qi3DvROE3fCLRe5d 8otk5fJ964i9+UJqU8nV3bjkueg86jxSVXDeImRfULbKQAsa1qjK/Y9DvvArsOLA Sd1BeHaTzdrx4sNoTQaByETaKdPKMkakHiOOBHF5413L5kCbjCS/BkMyoEdaA/Ro 6zZD4DvqE35swsNJfhjJz/DISkDuT4sxBwXhYIsftK/h3wc4JrgwfqRGlraCL9jG 32tbFhkDyz2GHJxVxjDYjyE+PrSWe4eL2zwiBqzF1H+zRKdwVATa+LM4fm8rXjxe 02fWI9JIECuc5VZvRjxXY77jAl1QI+3eWoIlDUbA/0hVrmZw+xuzNMsyGZcIVIku 8xbGEQbW4F9ZzJ2RVRwYuLduuRuH1Fsxnx3CUZbaC/XPpoyNaMA+0cOAAbQrnjeH jyFe1LETaydhip6hZsjc =oaAB -----END PGP SIGNATURE----- --OmL7C/BU0IhhC9Of--