qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Dovgalyuk <dovgaluk@ispras.ru>
To: Peter Maydell <peter.maydell@linaro.org>,
	Jerome Forissier <jerome@forissier.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Jens Wiklander <jens.wiklander@linaro.org>
Subject: Re: [PATCH] hw/arm/virt: Add DT property /secure-chosen/kaslr-seed
Date: Fri, 17 Apr 2020 15:01:31 +0300	[thread overview]
Message-ID: <37b74bfc-bf61-450a-21d1-43fbdeaa400a@ispras.ru> (raw)
In-Reply-To: <CAFEAcA-JpeYgDwKRarWwggrU5XX7eWsdVy1ngLn538rC6J75vg@mail.gmail.com>


On 17.04.2020 13:18, Peter Maydell wrote:
> On Fri, 10 Apr 2020 at 18:02, Jerome Forissier <jerome@forissier.org> wrote:
>> This commit generates a random seed to be used by the secure OS for
>> ASLR when the machine is secure. The seed is a 64-bit random value
>> exported via the DT in /secure-chosen/kaslr-seed. This interface is
>> used by OP-TEE [1].
>>
>> [1] https://github.com/OP-TEE/optee_os/commit/ef262691fe0e
> The kernel devicetree documentation documents this as a generic
> property of /chosen -- should we be providing a /chosen/kaslr-seed
> too ?
>
>> Signed-off-by: Jerome Forissier <jerome@forissier.org>
>> ---
>> +static void create_secure_kaslr_seed(VirtMachineState *vms)
>> +{
>> +    Error *err = NULL;
>> +    uint64_t seed;
>> +
>> +    if (qcrypto_random_bytes(&seed, sizeof(seed), &err)) {
>> +        error_free(err);
>> +        return;
>> +    }
> Since this is exposed to the guest I'm wondering if we should
> use qemu_guest_getrandom() (which lets you make the randomness
> deterministic for the benefit of record-and-replay). But I'm
> not sure if that function is usable before the guest has even
> started running. Pavel, could you answer that?

Yes, usage of deterministic functions is possible before machine is running,

because replay_configure is executed before machine initialization.


>
>> +    qemu_fdt_setprop_u64(vms->fdt, "/secure-chosen", "kaslr-seed", seed);
>> +}
>> +
>>   static void machvirt_init(MachineState *machine)
>>   {
>>       VirtMachineState *vms = VIRT_MACHINE(machine);
>> @@ -1837,6 +1850,7 @@ static void machvirt_init(MachineState *machine)
>>       if (vms->secure) {
>>           create_secure_ram(vms, secure_sysmem);
>>           create_uart(vms, VIRT_SECURE_UART, secure_sysmem, serial_hd(1));
>> +        create_secure_kaslr_seed(vms);
> This is implicitly relying on create_uart() having created
> the "/secure-chosen" node. I think it would be better now
> that we have multiple things we might want to put there if we
> just pulled the "create /secure-chosen" code out to the
> create_fdt() function so we do it at the same place we
> create "/chosen". (You can do that as a simple patch of its own
> that comes before this one in the patchseries.)
>
>>       }
>>
>>       vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64);
> thanks
> -- PMM


  reply	other threads:[~2020-04-17 12:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10 15:39 [PATCH] hw/arm/virt: Add DT property /secure-chosen/kaslr-seed Jerome Forissier
2020-04-17 10:18 ` Peter Maydell
2020-04-17 12:01   ` Pavel Dovgalyuk [this message]
2020-04-17 12:14     ` Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2020-04-10 16:01 Jerome Forissier

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=37b74bfc-bf61-450a-21d1-43fbdeaa400a@ispras.ru \
    --to=dovgaluk@ispras.ru \
    --cc=jens.wiklander@linaro.org \
    --cc=jerome@forissier.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).