From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYEF9-00061x-C0 for qemu-devel@nongnu.org; Fri, 12 Aug 2016 11:19:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bYEF8-0001J8-1U for qemu-devel@nongnu.org; Fri, 12 Aug 2016 11:19:31 -0400 Date: Fri, 12 Aug 2016 16:56:06 +1000 From: David Gibson Message-ID: <20160812065606.GX16493@voom.fritz.box> References: <1470591415-3268-1-git-send-email-nikunj@linux.vnet.ibm.com> <1470591415-3268-3-git-send-email-nikunj@linux.vnet.ibm.com> <1470605617.12584.182.camel@kernel.crashing.org> <20160809032817.GG9057@voom.fritz.box> <87invaa6fg.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> <87d1li9u85.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> <20160812062917.GT16493@voom.fritz.box> <87fuqa8p22.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fqQSV+MVmQEkpBtA" Content-Disposition: inline In-Reply-To: <87fuqa8p22.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania Cc: Benjamin Herrenschmidt , qemu-ppc@nongnu.org, rth@twiddle.net, qemu-devel@nongnu.org, Ravi Bangoria --fqQSV+MVmQEkpBtA Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 12, 2016 at 12:13:49PM +0530, Nikunj A Dadhania wrote: > David Gibson writes: >=20 > > [ Unknown signature status ] > > On Tue, Aug 09, 2016 at 02:47:46PM +0530, Nikunj A Dadhania wrote: > >> Nikunj A Dadhania writes: > >>=20 > >> > David Gibson writes: > >> > > >> >> [ Unknown signature status ] > >> >> On Mon, Aug 08, 2016 at 07:33:37AM +1000, Benjamin Herrenschmidt wr= ote: > >> >>> On Sun, 2016-08-07 at 23:06 +0530, Nikunj A Dadhania wrote: > >> >>> > +target_ulong helper_darn(uint32_t l) > >> >>> > +{ > >> >>> > +=A0=A0=A0 target_ulong r =3D UINT64_MAX; > >> >>> > + > >> >>> > +=A0=A0=A0 if (l <=3D 2) { > >> >>> > +=A0=A0=A0=A0=A0=A0=A0 do { > >> >>> > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 r =3D random() * random(); > >> >>> > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 r &=3D l ? UINT64_MAX : UINT3= 2_MAX; > >> >>> > +=A0=A0=A0=A0=A0=A0=A0 } while (r =3D=3D UINT64_MAX); > >> >>> > +=A0=A0=A0 } > >> >>> > + > >> >>> > +=A0=A0=A0 return r; > >> >>> > +} > >> >>> > =A0#endif > >> >>>=20 > >> >>> Isn't this a bit week ? Look at the implementation of H_RANDOM... > >> >> > >> >> Indeed, you should be using the rng backend that H_RANDOM, virtio-r= ng > >> >> and the Intel random number instruction all use. > >>=20 > >> Can you point me to the intel instruction, I couldn't get rdrand > >> implementation. > > > > Ah.. turns out no. I'd assumed it was there and used the same backend > > as virtio-rng and H_RANDOM, but I hadn't actually looked at the code, > > and now that I'm trying I can't see it either. > > > >>=20 > >> > I was looking at implementing this, AFAIU, I have to get a new RNG > >> > object in the initialization routine. We would need an instance of t= his > >> > per machine. So for pseries I can add in ppc_spapr_init(). I am not = sure > >> > in case of linux-user where should this be initialized. > >> > > >> > One other place was init_proc_POWER9(), but that will be per cpu and > >> > member of CPUPPCState structure. Advantage is it will work for system > >> > emulation and linux-user both and we would not need a lock. > >>=20 > >> More issues here. Random backend is not compiled for linux-user, adding > >> that wasn't difficult, but then rng_backend_request_entropy() uses > >> qemu_set_fd_handler() which is a stub for linux-user > >> (stubs/set-fd-handler.c)7 > > > > > > Ah.. yeah, not sure how we'll need to handle that. >=20 > I have sent updated patch, reading from /dev/random. Not sure if that is > allowed in tcg. Works fine though. Hrm. From a helper, there's nothing inherently wrong with reading =66rom /dev/random, AFAIK. However, it may not work on non-Linux hosts, and doesn't let you connect it to urandom instead which probably make it unsuitable to be merged. --=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 --fqQSV+MVmQEkpBtA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXrXMGAAoJEGw4ysog2bOSmbIQAOI+xEKFT29Kf1QIHeHw/LL4 ngBXG40ZOTaWRQupspcx4PEJ5TrDfyJdT3uF0+V7CWob26bkEN7eEf7O2xN+Vme6 U2V+ix2daQzEBq+ILG264pZQ1n9M5gJJOkjTz+hbD7MihVONAAZx/eaYbtQ4TVmu JgZNvK12eOLCY9onWXxRStCMr+P9bjda4MfdIUoVVqB7jf0fxtTsJ1hCvK4zm3wl VduTfEaxbtxzUTA1BIRS7//mXhRi9dlFsnkT3dLNNison/Cy6L1qvDhizHVBnR8f 42wgDysN6wVh5yHtyMYZ4R8JLbWJP+a9BSbxq6ABFzikmhZUGvHWwm7pt5k3yRND 8E7zKUsXIOq/Hd3T4EpEYgVpNkiXLmPe0n9b/CIfR1J+psOZbSA2OFUB9E/Q8JB3 jdYe/1lkCqP2KKf2lcZQzv4QUnFhB97s5qTeB58NwCP0RsjgMVSiW43XOSGIKUeJ rCO9xBQ+DG9ziOuV/ABIe1ctiO2ed9rIOxJcDCuDVIUDxMFedPXTfFqxvdL13hiu +V/+b2Io8l3W1JROwt3D/sIj1GzdyeROE7nvPI2FoZI96HlIc1eVzJs5NnNldbSP hXP9QRBu9daH1ne55bXAZql9avMZxn1eXJ7igE0d5WEKg42C/XPDBe4Ji4U/EJKS xT0MfG4d2Hvx9JZegZfN =ktzq -----END PGP SIGNATURE----- --fqQSV+MVmQEkpBtA--