Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1460415iog; Sat, 25 Jun 2022 09:54:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uqgF88ieKg/3hC83G/2p45XKuJXEQ0yU3/GA92O6pQVAJqRVdMbiiPWMgNC0XlYK2GFaQ7 X-Received: by 2002:a05:6402:1058:b0:435:de3b:7f9b with SMTP id e24-20020a056402105800b00435de3b7f9bmr5868894edu.324.1656176082805; Sat, 25 Jun 2022 09:54:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656176082; cv=none; d=google.com; s=arc-20160816; b=Sr6beu2w+BK1FnZzoh8EIeXmkJW17pzh3B76HFIcBzZT8YsAGthA3BkHDam/I4xwcI 4Fuu7EouPfhQpj2fkJyxZ61giMxsiFthNZv+1DL8JwlygxJKcxvYW+T9Ej+Mm/8TY1bv FIsrbT219iaMy/IUfg71iKKEuTZOfixyRqWVW10YMm3nNr54WUfQ2YIq3c/moKq2esq+ kRijdjvasRvTuUqUGQMkNF6AF/TCQP5aZQnYjCZn5YRMfEDZQ9qajKsLOxLZ3U5ahyOV 0jeVN1hm/2JuwYVky07K/dQqqp99a09wB4w668Tbxkp3j4sbi7nA8KmLRg1r294hAsmt 7glA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=3IGpc/1YdedsfdyJlZkLtH80E8A0vEibx1sK8FxCTGk=; b=UPP6MSQEkLK+0Ckmg4LjVrXb4nXdq1vjfH78ILFVcumsidUl6j721vyD9HgFV/tfd3 pVaPDkwtozn6k55ivZT/m7UqnK423NX0l2unVZzAQqC245/HMoRCmulu8GvhP3frCZN8 4YLAkA/o4Z5ZTesc0yTULA34IgB0YeQh4VstSTFM8D+jZXSl14d1iFTUGLPRCSwxUXzk syKLiMojMUFOVz+Nl9Xt+SEDDG0L0oLl+AWXOoTlBz8N0mT7Vd3SVcWtSTRg7rHJy+4t BqfTUlYACnmp6T6e5qiQFBP0WUjuv0Ew74+jzu+QLugX0g7S+NHNcRsEqjGI+cdTYzBv Q6ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt40-20020a1709072da800b0072636ec0429si4832898ejc.18.2022.06.25.09.54.08; Sat, 25 Jun 2022 09:54:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233127AbiFYQ1y (ORCPT + 99 others); Sat, 25 Jun 2022 12:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232908AbiFYQ1s (ORCPT ); Sat, 25 Jun 2022 12:27:48 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70E3113F48; Sat, 25 Jun 2022 09:27:47 -0700 (PDT) Received: from [192.168.100.1] ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue106 [213.165.67.119]) with ESMTPSA (Nemesis) id 1M58OQ-1o42Ad3OFQ-001DqP; Sat, 25 Jun 2022 18:27:43 +0200 Message-ID: <4b0eb04d-564e-3111-a460-27934976084e@vivier.eu> Date: Sat, 25 Jun 2022 18:27:42 +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:nfqBjMzmXFtTPd3gPKZG71NthEx9WLAcXw1BVmjES4dX0Let/sF GodTz2ULpJCa1UnX/6eH7c+061e7kGrax8rZ0RgEmO6rRKkzCZYv9p7Bd7H4fTv36GxUdyv /87s2DzbmtO1huIfLAN5Sv7TzFhNXFZVvJBqy2guCJcridA3BPNpUS0J/8QYYbbIhivydQV RLch8lgLayVEoSZ6FT1TA== X-UI-Out-Filterresults: notjunk:1;V03:K0:QQZVMIufM30=:9mbWBF8rAABdASCRbK2+H4 QkTc/LgWY+x8Ur4aolIpmAN7j5sg+28PATgErX75TEN+c1pFwS6aEkfDGJ5f0QuEZmvCmu/Xv fRsywJ3lm9Rh/jy81cGuRyOLzVZ2yTv8wOA71WqQxvZgympKNX4nvyUd2kQM3xr2dmvNWA2nB bipWglQ5d8Rtvbf9CjK7YEWJ9uqDAJ6ncocISnlmpEdiczddhqC6yUns89vgkOpnTuFxF6bc+ xmZ+8XCFJwWHWa9Oj+B3IpmxCNoH8K5TCg7bvs77pggofQvNAF4YA3iyOjXTxGvNrJNLVKuNs 9JdIVQGIaLVgU6q41CAGLX7X6IgmNnWlx8yiWTlZCNsdyeWgtnzWbo4tnv2AxQVM54P6pzodR c1TZkXnJQe6r6m8U5cTpV3xjM63uaOx/uM43+YCKDi5efvRnhlg75jFLk4zyPxZLEGYO8SOeP 9GEeKyslyVcfqxVnDA+DjeYIFleyKuMuV9TP4atFs4mddoVS33guTcU5vW9GhmGJ6BIVRQzSu DBWvwPCVPJ+8qbx2dfC6LCe8Bo5sz4RVMvHH5CZoHkDh7HM05RaSOcwP7Ui+BKZo5J6CT8bL/ hhRSGUyAEyqhWjc5f/7W3z0RW8r/XBxDROtacccFDpCqkysBunAHzsrZ0I7XXcpx5DJom1GiA VX41+bn5oL5J2NjGh7a5JSievQo3Xjyv1ZnlSYL45bPNonkjrpcJKrzh7pSPtfPBf3E1VfAMq gV92MxBv8R8Wq3EfgX130AYEu98hqMaF8+A3XjpHn0OLeUaky2MBfAvUnMK1ULb09RNUlw9+1 WF0Y1bzhyMUhtMPscVB8YmMIivLNgM1xc/np01SOa1nsbiPYyK3ChDBeNlMLjr+zYbAWBmD X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 25/06/2022 à 18:26, Jason A. Donenfeld a écrit : > On Sat, Jun 25, 2022 at 6:24 PM Laurent Vivier wrote: >> >> 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? > > I guess but that's different from all other length fields, and means > we can't expand past 65k if somebody wants to use this for something > more interesting later. Again I wonder what stinginess here gets us. > This is just a boot parameter... No need to go crazy optimizing it. I agree too. Thanks, Laurent