All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
	David Gibson <david@gibson.dropbear.id.au>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org, rth@twiddle.net
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/6] target-ppc: Implement darn instruction
Date: Fri, 12 Aug 2016 13:09:33 +0530	[thread overview]
Message-ID: <87a8gi8mh6.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <3c439ecd-57dc-eabe-fc68-d8c7cdce9e44@redhat.com>

Thomas Huth <thuth@redhat.com> writes:

> On 12.08.2016 08:43, Nikunj A Dadhania wrote:
>> David Gibson <david@gibson.dropbear.id.au> writes:
>> 
>>> [ Unknown signature status ]
>>> On Tue, Aug 09, 2016 at 02:47:46PM +0530, Nikunj A Dadhania wrote:
>>>> Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> writes:
>>>>
>>>>> David Gibson <david@gibson.dropbear.id.au> 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)
>>>>>>>> +{
>>>>>>>> +    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.
>>>>
>>>> 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.
>>>
>>>>
>>>>> 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.
>>>>
>>>> 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.
>> 
>> I have sent updated patch, reading from /dev/random. Not sure if that is
>> allowed in tcg. Works fine though.
>
> You can not rely on /dev/random for this job, since it might block. So
> your guest would stop executing when there is not enough random data
> available in the host, and I think that's quite a bad behavior...

Hmm.. rng-random does use this, but it might have way to time out probably:

backends/rng-random.c:    s->filename = g_strdup("/dev/random");

Regards
Nikunj

  reply	other threads:[~2016-08-12 14:27 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-07 17:36 [Qemu-devel] [PATCH 0/6] POWER9 TCG enablements - part4 Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 1/6] target-ppc: add xxspltib instruction Nikunj A Dadhania
2016-08-08  4:43   ` Richard Henderson
2016-08-08  6:19     ` Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 2/6] target-ppc: Implement darn instruction Nikunj A Dadhania
2016-08-07 21:33   ` Benjamin Herrenschmidt
2016-08-08  1:52     ` Nikunj A Dadhania
2016-08-08  3:22       ` Benjamin Herrenschmidt
2016-08-08  3:32         ` Nikunj A Dadhania
2016-08-09  3:28     ` David Gibson
2016-08-09  4:54       ` Nikunj A Dadhania
2016-08-09  9:17         ` [Qemu-devel] [Qemu-ppc] " Nikunj A Dadhania
2016-08-12  6:29           ` David Gibson
2016-08-12  6:43             ` Nikunj A Dadhania
2016-08-12  6:56               ` David Gibson
2016-08-12  7:13                 ` Nikunj A Dadhania
2016-08-12  7:29               ` Thomas Huth
2016-08-12  7:39                 ` Nikunj A Dadhania [this message]
2016-08-12  7:55                   ` Thomas Huth
2016-08-12  8:41                     ` Nikunj A Dadhania
2016-08-12  9:29                       ` Thomas Huth
2016-08-12  9:51                         ` Nikunj A Dadhania
2016-08-12 13:26                           ` Richard Henderson
2016-08-12 13:39                             ` Nikunj A Dadhania
2016-08-15 10:28                         ` David Gibson
2016-08-08  5:01   ` [Qemu-devel] " Richard Henderson
2016-08-08  6:20     ` Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 3/6] target-ppc: add lxsi[bw]zx instruction Nikunj A Dadhania
2016-08-08  5:08   ` Richard Henderson
2016-08-08  6:21     ` Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 4/6] target-ppc: add stxsi[bh]x instruction Nikunj A Dadhania
2016-08-08  5:08   ` Richard Henderson
2016-08-07 17:36 ` [Qemu-devel] [PATCH 5/6] target-ppc: add lxvb16x and lxvh8x Nikunj A Dadhania
2016-08-08  5:27   ` Richard Henderson
2016-08-08  6:35     ` Richard Henderson
2016-08-10  9:21       ` Nikunj A Dadhania
2016-08-10 10:12         ` Richard Henderson
2016-08-10 10:33           ` Nikunj A Dadhania
2016-08-10 15:21           ` Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 6/6] target-ppc: add stxvb16x and stxvh8x Nikunj A Dadhania
2016-08-08  5:27   ` Richard Henderson
2016-08-09  3:30 ` [Qemu-devel] [PATCH 0/6] POWER9 TCG enablements - part4 David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a8gi8mh6.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me \
    --to=nikunj@linux.vnet.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=ravi.bangoria@linux.vnet.ibm.com \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.