From patchwork Mon Sep 21 07:58:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolai Stange X-Patchwork-Id: 11788695 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BCF35618 for ; Mon, 21 Sep 2020 08:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA92020EDD for ; Mon, 21 Sep 2020 08:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726694AbgIUIA1 (ORCPT ); Mon, 21 Sep 2020 04:00:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:57142 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbgIUH7W (ORCPT ); Mon, 21 Sep 2020 03:59:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 82889B505; Mon, 21 Sep 2020 07:59:55 +0000 (UTC) From: Nicolai Stange To: "Theodore Y. Ts'o" Cc: linux-crypto@vger.kernel.org, LKML , Arnd Bergmann , Greg Kroah-Hartman , "Eric W. Biederman" , "Alexander E. Patrakov" , "Ahmed S. Darwish" , Willy Tarreau , Matthew Garrett , Vito Caputo , Andreas Dilger , Jan Kara , Ray Strode , William Jon McCann , zhangjs , Andy Lutomirski , Florian Weimer , Lennart Poettering , Peter Matthias , Marcelo Henrique Cerri , Roman Drahtmueller , Neil Horman , Randy Dunlap , Julia Lawall , Dan Carpenter , Andy Lavr , Eric Biggers , "Jason A. Donenfeld" , =?utf-8?q?Stephan_M=C3=BCller?= , Torsten Duwe , Petr Tesarik , Nicolai Stange Subject: [RFC PATCH 11/41] random: convert add_timer_randomness() to queued_entropy API Date: Mon, 21 Sep 2020 09:58:27 +0200 Message-Id: <20200921075857.4424-12-nstange@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200921075857.4424-1-nstange@suse.de> References: <20200921075857.4424-1-nstange@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org In an effort to drop __credit_entropy_bits_fast() in favor of the new __queue_entropy()/__dispatch_queued_entropy_fast() API, convert add_timer_randomness() from the former to the latter. There is no change in functionality at this point, because __credit_entropy_bits_fast() has already been reimplemented on top of the new API before. Signed-off-by: Nicolai Stange --- drivers/char/random.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index b91d1fc08ac5..e8c86abde901 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1400,6 +1400,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) long delta, delta2, delta3; bool reseed; unsigned long flags; + struct queued_entropy q = { 0 }; sample.jiffies = jiffies; sample.cycles = random_get_entropy(); @@ -1432,13 +1433,14 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) r = &input_pool; spin_lock_irqsave(&r->lock, flags); - __mix_pool_bytes(r, &sample, sizeof(sample)); /* * delta is now minimum absolute delta. * Round down by 1 bit on general principles, * and limit entropy estimate to 12 bits. */ - reseed = __credit_entropy_bits_fast(r, min_t(int, fls(delta>>1), 11)); + __queue_entropy(r, &q, min_t(int, fls(delta>>1), 11) << ENTROPY_SHIFT); + __mix_pool_bytes(r, &sample, sizeof(sample)); + reseed = __dispatch_queued_entropy_fast(r, &q); spin_unlock_irqrestore(&r->lock, flags); if (reseed) crng_reseed(&primary_crng, r);