[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: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 4/6] linux-user: Initialize aarch64 pac keys |
Date: |
Fri, 1 Feb 2019 15:11:40 +0000 |
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().)
thanks
-- PMM
- Re: [Qemu-devel] [PATCH 4/6] linux-user: Initialize aarch64 pac keys,
Peter Maydell <=