From patchwork Mon Sep 21 07:58:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolai Stange X-Patchwork-Id: 11788729 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 7EF36618 for ; Mon, 21 Sep 2020 08:01:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A7FA20874 for ; Mon, 21 Sep 2020 08:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726357AbgIUIBc (ORCPT ); Mon, 21 Sep 2020 04:01:32 -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 S1726590AbgIUH7j (ORCPT ); Mon, 21 Sep 2020 03:59:39 -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 874A5B52A; Mon, 21 Sep 2020 08:00:06 +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 30/41] random: add a queued_entropy instance to struct fast_pool Date: Mon, 21 Sep 2020 09:58:46 +0200 Message-Id: <20200921075857.4424-31-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 When health tests are introduced with upcoming patches, it will become necessary to keep entropy queued across add_interrupt_randomness() invocations for later dispatch to the global balance. Prepare for this by adding a struct queued_entropy member to the per-CPU fast_pool. Use it in place of that queue with automatic storage duration in add_interrupt_randomness(). Signed-off-by: Nicolai Stange --- drivers/char/random.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 55e784a5a2ec..37746df53acf 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -885,6 +885,7 @@ struct fast_pool { unsigned short reg_idx; unsigned char count; int event_entropy_shift; + struct queued_entropy q; }; /* @@ -1655,7 +1656,7 @@ void add_interrupt_randomness(int irq, int irq_flags) __u32 c_high, j_high; __u64 ip; bool reseed; - struct queued_entropy q = { 0 }; + struct queued_entropy *q = &fast_pool->q; unsigned int nfrac; if (cycles == 0) @@ -1700,9 +1701,9 @@ void add_interrupt_randomness(int irq, int irq_flags) nfrac = fast_pool_entropy(fast_pool->count, fast_pool->event_entropy_shift); } - __queue_entropy(r, &q, nfrac); + __queue_entropy(r, q, nfrac); __mix_pool_bytes(r, &fast_pool->pool, sizeof(fast_pool->pool)); - reseed = __dispatch_queued_entropy_fast(r, &q); + reseed = __dispatch_queued_entropy_fast(r, q); spin_unlock(&r->lock); fast_pool->last = now;