Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1461044iog; Sat, 25 Jun 2022 09:55:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v0qOW+3Tw3jCK0JsCVMyJ7A9HbjcZ5b1hrnJt6Ufichuwyc8ZvYpBMnWHUwkJc9eMWpYp3 X-Received: by 2002:a05:6402:1e88:b0:435:bf05:f0f with SMTP id f8-20020a0564021e8800b00435bf050f0fmr6133554edf.2.1656176136930; Sat, 25 Jun 2022 09:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656176136; cv=none; d=google.com; s=arc-20160816; b=fvqHKBUAxNxl9WaowKZU5I0C5GrClXNOAlRa70z1G2LEkgEgNnu3fdCYPWEVLg89wl 7SERQ90Q7KMEb3ur3gZZeTMASfx5bkQYyUH4P9Yw6BaTZ7cpjwTA6QbbpLo9H+9md6M9 Ah/D13NYx8l/+qs6oKYKiFZff0vorAoovfHm5JlBmXq3iswFpfhqxa0w9Zb3mHVpfFrV zE4DWc9JvOb408h5Am7g4fE2NV7rtKwRVXTClOHihhakOpvMt5a/y18N4U6rAbzyGBw/ 2Yuza353/BRxOFOGWLyVJmJk0tvc2G8ks6jGhVE687a948J4Q5dP7LQoDyzhSUg7E6Ae zsVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=2l1JO0EvImXtJesW/U27TBwPd7olHN9f3zn4k5kPBrY=; b=rJl1V3oo0QvPXPB3md2TBK4bZwtboWtBAqraGdCBg4ajfNEABX5D+387iq4T0zfw4k oAJb/Out4ybE2I2Lo+UvXInj7cSkZ2vMB/qfa7zegUBNRpKJd/CJ81dSnRilMtTHnHpS 21EkEv8OifTTs7/Ea2R5Rb7S7AkzUYGMKE1PxHoZj9A9zdBkR9an9Vlan7YC/Ctsq47c tkY7OzuAmRcO8HqCSwWqti0cuB1qrBUXNK4Eo1wiVfIxP5w5qLyMYChS/aE/pE4K/Cbl r6xQ38DdbpuJ5m59emAd6ctOSygsoMxjY4DbSq1OkfUubGBNM5Mw+hMvXmyMFoIEm2vr tzuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=O3QXPAgk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l12-20020aa7d94c000000b004357d46d8a6si6950551eds.424.2022.06.25.09.55.12; Sat, 25 Jun 2022 09:55:36 -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; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=O3QXPAgk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233011AbiFYQ07 (ORCPT + 99 others); Sat, 25 Jun 2022 12:26:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbiFYQ04 (ORCPT ); Sat, 25 Jun 2022 12:26:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E452A13E26 for ; Sat, 25 Jun 2022 09:26:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7B0E661524 for ; Sat, 25 Jun 2022 16:26:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B3DAC3411C for ; Sat, 25 Jun 2022 16:26:54 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="O3QXPAgk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1656174411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2l1JO0EvImXtJesW/U27TBwPd7olHN9f3zn4k5kPBrY=; b=O3QXPAgkbO0yfkZl7OTm1vmasZ/LvH4HI32b0Xn/soW9X5G8Qq6E0NIaerD0buUt1X+Q36 OWOlKhlxfoinM2rXuHSiNj+VfiGLp/cCWOCFY5CUYZ/1n+6rui6FJApdHsaqqlK7Yzwl5X YUs3AbjoFB7vbq3MrEZCg1vBeJuGK9E= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id a4eff193 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Sat, 25 Jun 2022 16:26:51 +0000 (UTC) Received: by mail-il1-f181.google.com with SMTP id k6so3406394ilq.2 for ; Sat, 25 Jun 2022 09:26:50 -0700 (PDT) X-Gm-Message-State: AJIora9+3OyOAnaR27B2EKXiGqC2srEGFyweFKUUDqWq7nm7+QQmQWES +Q/9F0d1dkjFOHRboU8ag0d2Rqdt7hnTNKWKHF4= X-Received: by 2002:a05:6e02:20c6:b0:2d8:e62f:349f with SMTP id 6-20020a056e0220c600b002d8e62f349fmr2590564ilq.160.1656174409792; Sat, 25 Jun 2022 09:26:49 -0700 (PDT) MIME-Version: 1.0 References: <20220625153841.143928-1-Jason@zx2c4.com> <512bdf97-5468-e2d2-75bd-24107aaf8a34@vivier.eu> In-Reply-To: From: "Jason A. Donenfeld" Date: Sat, 25 Jun 2022 18:26:38 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] m68k: virt: pass RNG seed via bootinfo block To: Laurent Vivier Cc: Geert Uytterhoeven , linux-m68k , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Sat, Jun 25, 2022 at 6:24 PM Laurent Vivier wrote: > > Le 25/06/2022 =C3=A0 18:19, Jason A. Donenfeld a =C3=A9crit : > > On Sat, Jun 25, 2022 at 6:08 PM Laurent Vivier wrot= e: > >> > >> Le 25/06/2022 =C3=A0 17:38, Jason A. Donenfeld a =C3=A9crit : > >>> 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 it= s > >>> own bootinfo protocol. So this commit adds support for receiving a RN= G > >>> seed from it, which will be used at the earliest possible time in boo= t, > >>> 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/i= nclude/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_reco= rd *record) > >>> data +=3D 4; > >>> virt_bi_data.virtio.irq =3D 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 buf= fer? > >> > >> 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 encod= ed 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. Jason