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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45C2DC433F5 for ; Sun, 10 Apr 2022 23:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sjT49AIzbJoq5zzwrsWTRRRNn53VdSFh01c4ttfmXbM=; b=M/qkmOkEDw5Oov yNYDcKB+qbk+gW9yF2AibBqiyGN7R8FKFkun307kpSLjXJp8mJYV6JgwrYb/zxF6cIOiE/b7K6zgf CwpNPankUtV6LVItuToyNR50YgcZhCsLHsvucJE+dd7X5Gt35ieLVuYwqp4EvIe+UPsu8J3+Q3b6k PTL7W3at7ewGjcsQPsCf2mgq5ejj6N3GCH+uyCfBEqThp921zDjrWYxYGCUmly/VwlCrisZ7f3ONg 0iiylf2ZKX7ZzDR0wP2zsyFUBqsMrmcxu3hX1BN2KN2Oph/jXEyjtopFmEu76Mq0HWQsqOGeY3OG9 2HPqnRokrfRUFkQfD+Vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndgah-005pNr-PN; Sun, 10 Apr 2022 23:03:31 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndgae-005pML-Hb; Sun, 10 Apr 2022 23:03:30 +0000 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 41A51B80ECA; Sun, 10 Apr 2022 23:03:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC2BEC385A4; Sun, 10 Apr 2022 23:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649631804; bh=3UW/ugtsAFc3LmqMEdhTjA4sBbB84OlrF236JWrXPJQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NR9pk0uBM1asFnTpcfZ/n5egUA0L5wn0LwY4g0wU3t6o8+s1sxwXOHR2AYAWEi6pV I2vKpdgHuCEtkbj5jgEl+6Q+z2lm60QHNjVPUndluZnUmfI2C4+KbpzY9A5VH3UpK3 P5r9Evysc6lL+rwlKglGhMFJbnFeXyKAGFovS8I7ute7Bmg1zu32YUyz4TLsfBLCTE fC/iqfphZbrVckNWFSyEQ+mV/51gW4BSq6CcPUm/8Qyydr7JRQY1FMsyTuSVmBdOKr 0g+a0Sxr4+W04a25Z9gGkMyiR61smTiTbf6h82pbMVql8l89m1uCYkKbbielAEJF1K 7i38S8/QIO/7A== Date: Sun, 10 Apr 2022 16:03:22 -0700 From: Eric Biggers To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, arnd@arndb.de, Theodore Ts'o , Dominik Brodowski , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Thomas Bogendoerfer , Paul Walmsley , Palmer Dabbelt , Albert Ou , "David S . Miller" , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Chris Zankel , Max Filippov , John Stultz , Stephen Boyd , linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, x86@kernel.org, linux-xtensa@linux-xtensa.org Subject: Re: [PATCH RFC v1 00/10] archs/random: fallback to using sched_clock() if no cycle counter Message-ID: References: <20220408182145.142506-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220408182145.142506-1-Jason@zx2c4.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220410_160328_929698_243A5CD9 X-CRM114-Status: GOOD ( 16.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 08, 2022 at 08:21:35PM +0200, Jason A. Donenfeld wrote: > By my first guess, we have ktime_get_boottime_ns(), jiffies, and > sched_clock(). It seems like sched_clock() has already done a lot of > work in being always available with some incrementing value, falling > back to jiffies as necessary. So this series goes with that as a > fallback, for when the architecture doesn't define random_get_entropy in > its own way and when there's no working cycle counter. Won't this interact badly with how try_to_generate_entropy() (a.k.a. the "Linus Jitter Dance") detects the presence of an appropriate timer currently? stack.cycles = random_get_entropy(); /* Slow counter - or none. Don't even bother */ if (stack.cycles == random_get_entropy()) return; So if random_get_entropy() always returns 0, then try_to_generate_entropy() won't run. However, if random_get_entropy() is even just a low-precision timer, then try_to_generate_entropy() will have a chance of running, since the timer might change between the two calls to random_get_entropy(). And if try_to_generate_entropy() does run, then it credits 1 bit of entropy for every iteration, regardless of the timer's precision. This is an existing problem, but this patchset will make it worse, as it changes a lot of cases from "no timer" to "low precision timer". Perhaps try_to_generate_entropy() should check the timer at least 3 times and verify that it changed each time? - Eric _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel