From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bY67p-0006yw-Sk for qemu-devel@nongnu.org; Fri, 12 Aug 2016 02:39:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bY67k-0001yZ-Ra for qemu-devel@nongnu.org; Fri, 12 Aug 2016 02:39:24 -0400 Date: Fri, 12 Aug 2016 16:29:17 +1000 From: David Gibson Message-ID: <20160812062917.GT16493@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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4AfY4lbNVy6SI0IG" Content-Disposition: inline In-Reply-To: <87d1li9u85.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 --4AfY4lbNVy6SI0IG Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 wrote: > >>> 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 : UINT32_M= AX; > >>> > +=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-rng > >> 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 this > > 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 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 --4AfY4lbNVy6SI0IG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXrWy8AAoJEGw4ysog2bOS2f8QAMr57tLeaH2UhkI51AmhWDRO P9MDIDnbYpmInz549hrholRjDBEk7HEOFuE63ZqaQ3qDlr6+yZWz8ZbQKkR6itjM W3TLOcKw6cUYcZSR614PRDB7rEUNALjQhJ1ZewgY5oON4cOuNvrN2bcUgmhKsia4 B5ZKiEwmCEMejfGscYuMWkyppHc/N/90fZriKTQ1N7Sre/D/IfLQ/1xJj+CATAEq R0zRG+nvb2VDWyt3Y/SRIkMWmBoI9C622FmGdPrYmSxr/fmhd50dXy9ioXKMBBwl uUISpRgU+NQPnqCuDGzVMlZGpGiWzUsOjmzdfmJyBFxPygcI+N7PuChFH190CJ5A q2Mw68xn+yu2oEh+73jv/l9SymHUzgQioGxp0F/KRj7p+zrt8CWvKn8Kk7D7EHHs RPJ25GQiJOCaRGl3bNVexGH4rLvXigHzzt2JxjCTPU+I19Sw0Mife9ZCPcko4V1n GwUUJQsbtuyExheMIuZ0SDDTpzWsROaVDc46/dVUIKhV80LzbxBY+ayMvf6FXKOT 97jn8PNCscMemXd9ClHlSevRAOZi9DMgUrm1tUTIiOwRMmKQVAXs7F2kdVsivhWA OGFawIp7xnoxK/KlMzW+V6a16+93lh21A9x/mMhoFNlx8n9y+wQb1FratY5CjAKC 2SkBUD6OU8T0QaGjgrRS =AKv/ -----END PGP SIGNATURE----- --4AfY4lbNVy6SI0IG--