public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-m68k <linux-m68k@lists.linux-m68k.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] m68k: virt: pass RNG seed via bootinfo block
Date: Sat, 25 Jun 2022 18:24:16 +0200	[thread overview]
Message-ID: <fa4f2fba-ad77-e5a9-a78a-680ed5137157@vivier.eu> (raw)
In-Reply-To: <CAHmME9qKkL8r7QSwq+2DA54mpMHzqpnq=pi5f0DhKOcB-qezoQ@mail.gmail.com>

Le 25/06/2022 à 18:19, Jason A. Donenfeld a écrit :
> On Sat, Jun 25, 2022 at 6:08 PM Laurent Vivier <laurent@vivier.eu> wrote:
>>
>> Le 25/06/2022 à 17:38, Jason A. Donenfeld a écrit :
>>> Other virt VMs can pass RNG seeds via the "rng-seed" device tree
>>> property or via UEFI, but m68k doesn't have either. Instead it has its
>>> own bootinfo protocol. So this commit adds support for receiving a RNG
>>> seed from it, which will be used at the earliest possible time in boot,
>>> just like device tree.
>>>
>>> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
>>> ---
>>>    arch/m68k/include/uapi/asm/bootinfo-virt.h | 1 +
>>>    arch/m68k/virt/config.c                    | 4 ++++
>>>    2 files changed, 5 insertions(+)
>>>
>>> diff --git a/arch/m68k/include/uapi/asm/bootinfo-virt.h b/arch/m68k/include/uapi/asm/bootinfo-virt.h
>>> index e4db7e2213ab..7c3044acdf4a 100644
>>> --- a/arch/m68k/include/uapi/asm/bootinfo-virt.h
>>> +++ b/arch/m68k/include/uapi/asm/bootinfo-virt.h
>>> @@ -12,6 +12,7 @@
>>>    #define BI_VIRT_GF_TTY_BASE 0x8003
>>>    #define BI_VIRT_VIRTIO_BASE 0x8004
>>>    #define BI_VIRT_CTRL_BASE   0x8005
>>> +#define BI_VIRT_RNG_SEED     0x8006
>>>
>>>    #define VIRT_BOOTI_VERSION  MK_BI_VERSION(2, 0)
>>>
>>> diff --git a/arch/m68k/virt/config.c b/arch/m68k/virt/config.c
>>> index 632ba200ad42..ad71af8273ec 100644
>>> --- a/arch/m68k/virt/config.c
>>> +++ b/arch/m68k/virt/config.c
>>> @@ -2,6 +2,7 @@
>>>
>>>    #include <linux/reboot.h>
>>>    #include <linux/serial_core.h>
>>> +#include <linux/random.h>
>>>    #include <clocksource/timer-goldfish.h>
>>>
>>>    #include <asm/bootinfo.h>
>>> @@ -92,6 +93,9 @@ int __init virt_parse_bootinfo(const struct bi_record *record)
>>>                data += 4;
>>>                virt_bi_data.virtio.irq = be32_to_cpup(data);
>>>                break;
>>> +     case BI_VIRT_RNG_SEED:
>>> +             add_bootloader_randomness(data + 4, be32_to_cpup(data));
>>
>> In fact, why don't you use the record->size to get the size of the buffer?
>>
>> It seems useless to encode twice the length of the buffer, the second time on a 32bit while the
>> length cannot exceed a 16bit value.
> 
> Doesn't that make the length ambiguous because of required alignment?

I agree, it's why I understand reviewing the QEMU part of your patch.

> Would rather keep this general. As is, it's also much more like the
> others and more uniform to keep it that way. You were able to review
> it and see that it was right after glancing for a second. That seems
> superior to any imaginary gains we'd get by overloading the record
> size.

And what about using a 16bit field rather than a 32bit field as the encoded length cannot be greater 
than the record length?

Thanks,
Laurent


  reply	other threads:[~2022-06-25 16:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-25 15:38 [PATCH] m68k: virt: pass RNG seed via bootinfo block Jason A. Donenfeld
2022-06-25 15:51 ` Laurent Vivier
2022-06-25 16:08 ` Laurent Vivier
2022-06-25 16:19   ` Jason A. Donenfeld
2022-06-25 16:24     ` Laurent Vivier [this message]
2022-06-25 16:26       ` Jason A. Donenfeld
2022-06-25 16:27         ` Laurent Vivier
2022-06-26  9:39         ` Geert Uytterhoeven
2022-06-26 10:50           ` Jason A. Donenfeld
2022-06-26 11:15             ` [PATCH v2] m68k: virt: use RNG seed from " Jason A. Donenfeld
2022-07-06  9:00               ` Geert Uytterhoeven

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=fa4f2fba-ad77-e5a9-a78a-680ed5137157@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=Jason@zx2c4.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.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