[PATCH] Added Getentropy() support to beagle BSP

Udit agarwal dev.madaari at gmail.com
Thu Mar 15 08:20:45 UTC 2018


On Thu, Mar 15, 2018 at 1:19 PM, Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> On 15/03/18 08:13, Udit agarwal wrote:
>
>> Oh yes, i think i misinterpreted your previous suggestion of surrounding
>> the while loop by mutex, it should be the outer while loop. some thing like
>> this?:
>> while (n > 0) {
>>         uint32_t random;
>>         size_t copy;
>>
>>         rtems_mutex_lock(&atsam_trng_mutex);
>>
>
> Now you correctly use the mutex to produce 32-bits of random data.
> Currently the likely user of getrandom() is
>
> https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=
> blob;f=newlib/libc/stdlib/arc4random.c;h=3cccc3ed46a5e9e
> 756d4e216cb7686589eb60993;hb=HEAD#l89
>
> So, you need 12 mutex lock/unlock operations for this. I would protect the
> while (n > 0) loop with a single mutex lock/unlock.

Ok,Like this?
rtems_mutex_lock(&atsam_trng_mutex);
    while (n > 0) {
   .........
   .........
    }
rtems_mutex_unlock(&atsam_trng_mutex);

Also, will it be ok to keep atsam_trng_mutex even after user has finished
using getentropy() i.e when we don't use destroy(&atsam_trng_mutex) at all?

>
>
> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax     : +49 89 189 47 41-09
> E-Mail  : sebastian.huber at embedded-brains.de
> PGP     : Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20180315/1d7cc87f/attachment-0002.html>


More information about the devel mailing list