[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/6] target-ppc: Implement darn instruction
From: |
David Gibson |
Subject: |
Re: [Qemu-devel] [PATCH 2/6] target-ppc: Implement darn instruction |
Date: |
Tue, 9 Aug 2016 13:28:17 +1000 |
User-agent: |
Mutt/1.6.2 (2016-07-01) |
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)
> > +{
> > + target_ulong r = UINT64_MAX;
> > +
> > + if (l <= 2) {
> > + do {
> > + r = random() * random();
> > + r &= l ? UINT64_MAX : UINT32_MAX;
> > + } while (r == UINT64_MAX);
> > + }
> > +
> > + return r;
> > +}
> > #endif
>
> 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.
But, worse than that: even if random() was a good RNG, I'm pretty sure
than although random() * random() will give you a random number with
twice as many bits as random() alone, it won't be uniformly
distributed. That's probably not what you want.
--
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
signature.asc
Description: PGP signature
- [Qemu-devel] [PATCH 0/6] POWER9 TCG enablements - part4, Nikunj A Dadhania, 2016/08/07
- [Qemu-devel] [PATCH 1/6] target-ppc: add xxspltib instruction, Nikunj A Dadhania, 2016/08/07
- [Qemu-devel] [PATCH 2/6] target-ppc: Implement darn instruction, Nikunj A Dadhania, 2016/08/07
- Re: [Qemu-devel] [PATCH 2/6] target-ppc: Implement darn instruction,
David Gibson <=
- Re: [Qemu-devel] [PATCH 2/6] target-ppc: Implement darn instruction, Nikunj A Dadhania, 2016/08/09
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction, Nikunj A Dadhania, 2016/08/09
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction, David Gibson, 2016/08/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction, Nikunj A Dadhania, 2016/08/12
- Message not available
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction, Nikunj A Dadhania, 2016/08/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction, Thomas Huth, 2016/08/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction, Nikunj A Dadhania, 2016/08/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction, Thomas Huth, 2016/08/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction, Nikunj A Dadhania, 2016/08/12
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction, Thomas Huth, 2016/08/12