From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CE37C43334 for ; Sat, 25 Jun 2022 16:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233187AbiFYQYa (ORCPT ); Sat, 25 Jun 2022 12:24:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233045AbiFYQY3 (ORCPT ); Sat, 25 Jun 2022 12:24:29 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C8FA3886; Sat, 25 Jun 2022 09:24:23 -0700 (PDT) Received: from [192.168.100.1] ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [213.165.67.119]) with ESMTPSA (Nemesis) id 1N33V5-1nfjzw2EiT-013QrJ; Sat, 25 Jun 2022 18:24:17 +0200 Message-ID: Date: Sat, 25 Jun 2022 18:24:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] m68k: virt: pass RNG seed via bootinfo block Content-Language: fr To: "Jason A. Donenfeld" Cc: Geert Uytterhoeven , linux-m68k , LKML References: <20220625153841.143928-1-Jason@zx2c4.com> <512bdf97-5468-e2d2-75bd-24107aaf8a34@vivier.eu> From: Laurent Vivier In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:fstY23GWpWBXVsievXkgzQyzVCyqfeGInSYRvX7xBZs9sulG7AC DyhWEVvaCiaYJ0U7Qp3OcDZnXu4S9ELWbPZBlfd5duSKb5kIn68FmmA5kGBLOraFnyaYOXX 0ACVci/en8j7esQyYl5U+NCO7FpG1R0eFTa5pwa0GbTBnfFoqk4g/lix32PtIXySeJvHi7L 8Y2I0dewHAp4GSvV9yGqA== X-UI-Out-Filterresults: notjunk:1;V03:K0:KU/oVou+EAY=:aX7Q8WeHq7CkzTvPt2lMC7 FRSyjSFJoZVrUB7T2VSTmLVLwJJygw7Ef/kl5i1vXt9S/nAE0Kqv/glSI80GF6U7y5a3OuL8C ul03yL2ERynn5qITMkJfK73wmtVxqNUvXswmMNBy2Tc6CHFI60ThdpN/l0Y0SsUDIbGUpFGme /z5ELmvejd8Io3kcwUC894n2zcfpPtStlMdJpWVFav09+vKtV+NncwDalIDg4LT7APuDkYxLp 1fjDbFMlIbpC7//W7YArmq9lOSTgol1eim5ydbV2d9Jpo+LdJKvRdltwq+1DierAWYPH6s5zL 4efsC4ELUwqxGaIqOiZXswB9hahmKk5pDXWkcEf6wNaqFE5oZhBKQpInroAymrrXxfg5I7sWa wd4T76QswTnTTszrsEpSWIJwHtPhCF7i6aHhn9PX1YK3B2oh9uzzL8d+uZlxAe1nD0/fZSE8r j2jALk1Mg5p+P46KMmlW/eGKi8s3aBsygG//c5ab7EKxrRI1MhwSEP9Uur+Svn8JTBa+9ftZW p4J2WRW9FJjQAITRXNz4QbFh1cC9XBw0fz7Uv8X3O9jFc38VOcV/Gih24A2iwGN1KMIqbZ48h JolPDDRJWmsj+fs3A1Ma6XWNNEAu5b/SZIzyXXntiVRWP5DV6VfKScU4cNZgmzvdaFPz0NaYr 6KC+pBktA5ME8SwjfoiaHaXTWZmaa+tAoCMhW5BJmTrSx/1of7+xnrexUE/roILF8oW2OjM4i kfQeB2hWdYKSkWqE3oL8IxmsnE+BWMePH7AbRA== Precedence: bulk List-ID: X-Mailing-List: linux-m68k@vger.kernel.org Le 25/06/2022 à 18:19, Jason A. Donenfeld a écrit : > On Sat, Jun 25, 2022 at 6:08 PM Laurent Vivier 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 >>> --- >>> 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 >>> #include >>> +#include >>> #include >>> >>> #include >>> @@ -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