qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/6] linux-user: Initialize aarch64 pac keys


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH 4/6] linux-user: Initialize aarch64 pac keys
Date: Fri, 1 Feb 2019 10:13:05 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 2/1/19 7:11 AM, Peter Maydell wrote:
> On Fri, 25 Jan 2019 at 22:57, Richard Henderson
> <address@hidden> wrote:
>>
>> Initialize the keys to a non-zero value on process start.
>>
>> Signed-off-by: Richard Henderson <address@hidden>
> 
>> +static uint64_t arm_rand64(void)
>> +{
>> +    int shift = 64 - clz64(RAND_MAX);
>> +    int i, n = 64 / shift + (64 % shift != 0);
>> +    uint64_t ret = 0;
>> +
>> +    for (i = 0; i < n; i++) {
>> +        ret = (ret << shift) | rand();
>> +    }
>> +    return ret;
>> +}
> 
> I'm not a huge fan of the use of rand() here, but it's what
> we're using to initialize AT_RANDOM in linux-user, so I guess
> it's OK here. At some point we should investigate whether
> there's something better we are guaranteed to have available,
> I suppose. (Coverity gripes about use of rand().)

I considered implementing a qemu version of getentropy,
but then I saw our "-seed" option and thought perhaps
repeatability is more important for qemu.


r~




reply via email to

[Prev in Thread] Current Thread [Next in Thread]