On 2/1/19 7:11 AM, Peter Maydell wrote: > On Fri, 25 Jan 2019 at 22:57, Richard Henderson > <richard.hender...@linaro.org> wrote: >> >> Initialize the keys to a non-zero value on process start. >> >> Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > >> +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~