Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2321002rwi; Tue, 1 Nov 2022 06:31:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6uU0Kva9WWcynN8uLjWDiFyL62ODgDT5hmvHlO9AAZMr+Nm6hpagCNOKkm0hA5dc0/vaGy X-Received: by 2002:a17:906:9b83:b0:730:b3ae:343 with SMTP id dd3-20020a1709069b8300b00730b3ae0343mr18890956ejc.670.1667309474981; Tue, 01 Nov 2022 06:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667309474; cv=none; d=google.com; s=arc-20160816; b=nH2Zp/jZsJFNiefGJxsNycSv3OGo/X3sP4c/g5slq4A/7v+MvV5IzQOWhTBymy25wM WK2KZ0NI0QHXQx4yXHmlmgBaonauNi40rSKbDjTbRfU3HR0q9aiNq01GPg8FtYjmP3Uo KUzYV/dihnRiYpVTjGdLI3o8h1myDTgKMIyz42jYfP089KTko3iufcm6UGcnS9zzPkWC qCJ5g+Fl8I0DbrWb0l6Ip0MtwtIUtbasEvR9lj/3a5wnY84xUfawH+zNOLl50kwdFxJm kyf2MVnjv7k4ppN0dohE5ANnb0oTCPybOOz4SCJMWGOeoM34t1oJ7nSmBkQMbKKj3mIB Esew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aGf3HRCgre3btUoaDn4OQ44V8myJz/3Xau3fRCIpvUk=; b=oG7CrEFsRS5bd5KuOhwjgboZXy4lz3tnqN5JqPjf/NZ+g0MjTTO2BAfdoQ//N3waYF FeTz2aIbtcnfiH4mzVN8UzNFDFwnrVQCjgZImEHNccKngtawe1ZYd8c+uEub/SNiadWp UQhK4BzT2ZuP6/r2hnBw6Kdyxa9FaYwjHNvLBoSkvyPRnMqA92TmvK0VMlqci/FKNC6j NMSWJs2VgjDCtWHCmLutGH7v4JimfB9Ey/fFAVuYWYTYH6ta0c9Zd66+9e3y0a283puk PoxMdHBYsXT56AfIj1NZmYhmHTc6PzK8Q+wsiGhI7CfPDawy8DXPaN6Gjbz3Kx8Z0XHP Qcgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=myvlQccd; 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=QUARANTINE sp=QUARANTINE 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 r10-20020a05640251ca00b00461c852af19si13223985edd.633.2022.11.01.06.30.51; Tue, 01 Nov 2022 06:31:14 -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=myvlQccd; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiKANDJ (ORCPT + 97 others); Tue, 1 Nov 2022 09:03:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230351AbiKANDH (ORCPT ); Tue, 1 Nov 2022 09:03:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BD3D1B798 for ; Tue, 1 Nov 2022 06:03:06 -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 ams.source.kernel.org (Postfix) with ESMTPS id 128F4B81BD2 for ; Tue, 1 Nov 2022 13:03:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAB39C433D6; Tue, 1 Nov 2022 13:03:02 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="myvlQccd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1667307780; 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: in-reply-to:in-reply-to:references:references; bh=aGf3HRCgre3btUoaDn4OQ44V8myJz/3Xau3fRCIpvUk=; b=myvlQccdLLbbOrtow+kUbH/oXOYEc8Oy9LENIq4/ncat6FPoYRAVx9139m1B9/8SVuOXJ1 CIkMB7K2W8O7BGFtcBthO1d7Z+zw2tKWQkTc2ucHEyTq76TFDkgcaYSwkHDXHW/NN0rtmP RBf5hazhmW6EgCY1N4D/nZJ8eKI2Jr0= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 52812150 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 1 Nov 2022 13:03:00 +0000 (UTC) Date: Tue, 1 Nov 2022 14:02:58 +0100 From: "Jason A. Donenfeld" To: Mark Rutland Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Will Deacon , Ard Biesheuvel , Jean-Philippe Brucker Subject: Re: [PATCH v5] random: remove early archrandom abstraction Message-ID: References: <20221101115616.232884-1-Jason@zx2c4.com> <20221101122527.323843-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 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 Hi Mark, On Tue, Nov 01, 2022 at 12:36:07PM +0000, Mark Rutland wrote: > Hi Jason, > > Sorry for joining this late... > > On Tue, Nov 01, 2022 at 01:25:28PM +0100, Jason A. Donenfeld wrote: > > The arch_get_random*_early() abstraction is not completely useful and > > adds complexity, because it's not a given that there will be no calls to > > arch_get_random*() between random_init_early(), which uses > > arch_get_random*_early(), and init_cpu_features(). During that gap, > > crng_reseed() might be called, which uses arch_get_random*(), since it's > > mostly not init code. > > The original rationale for arch_get_random*_early() was just to seed the RNG > more robustly rather than to feed every possible arch_get_random() call made > early in the boot flow, and the rationale for having a separate functions was > that it was trivial to see by inspection that it was (only) called in the > expected places. > > I'm not wedded to arch_get_random*_early() specifically, but I do think that > having arch_get_random() behave differently depending on which phase of boot > we're in has more scope for error than having a separate call of some sort. > > Other than removing the lines below, what chages is this going to permit? Firstly, the issue with the API is having to remember to use it! There's already been a bug from forgetting to use the _early() call during some refactoring, and I doubt it'll be the last. But also, functions such as crng_reseed()->extract_entropy() wind up being called in both early contexts and normal contexts. It's not feasible to have different paths there, so by having two functions, we miss out on having access during early boot. So I don't want a separate call, both for the API complexity reasons, and because it doesn't really work as intended in the end. Jason