Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2952236pxk; Mon, 21 Sep 2020 01:03:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvPa9BjPrPwIlDyECfTzQmhniHteAHb20nOzi5VdTJVMUuopl7q0fRJ/as3wqVtvHyhj5z X-Received: by 2002:a05:6402:1694:: with SMTP id a20mr49911481edv.286.1600675401319; Mon, 21 Sep 2020 01:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600675401; cv=none; d=google.com; s=arc-20160816; b=VqwzH7rXB5+S2P90/DfdWQXxvvqd3Dk9e2dpYcaqzGtwp91qdxlJ3Fmj6af/g0121k nfwsWfBeuvJzLZ8UUkkWCtVd8CuISkWliRUhZNpKNSdX+MKSilCqx3mNxWcl1QCl3+9J YkelHbozsFwc+45PtGTrMIq3rSvEhppni3X5lGAUr+Fb01n+uZ5f8uAMd50EfEJ626z3 xKU4ZNKZ9/+4oJg5BADpizXFEJgFj+R5eiZQ+FWV4F1qGuIi3sIImn/dB+Ey6tJchgaZ C+qGdvsJnm/YMQry14si9QaI/mRDypy8WURlZ9sLJ5JintXESJLW1ZyK0z+nJTK4XLKG KAZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mEqrqiYR1Xz6e0Rb4GB/TpTOLEguaUBDJCZTofsVCU0=; b=BPkvAm9IlTp8g+GnTyIK2GqPaVUtOHG+Oj/D0gCkFw3M7CV3UbKziOvTI08Zi3p9yK 6T1tCHeRtrpLaiOuaTfe/rp6ihWewKH8txrKwDUwQHQrxRDsl9/9YHZZVLlMafvCiW04 2bOU3xCQNjRCIJCfBaq/IxJtPt7mtd8VvrVW3Pf/zoqtcfYFLdWP3yi9GQdMaVygB0B1 o72wUqvxwu4JknpEFAjzPY+LZbm4DX+eT0xTssnoRAkd0Wvg99lZ89bV0EoFAgFh8KHp VlVFJHAP8b1Ow1CIZGBIkDckGmJeN5FfIATa7PO+93b3xz7xxf7n0WVrdxzlgfWwolrA qQQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y22si7715038edo.147.2020.09.21.01.02.57; Mon, 21 Sep 2020 01:03:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbgIUIBJ (ORCPT + 99 others); Mon, 21 Sep 2020 04:01:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:58044 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726587AbgIUH7j (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 1D565B52C; Mon, 21 Sep 2020 08:00:07 +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=20M=C3=BCller?= , Torsten Duwe , Petr Tesarik , Nicolai Stange Subject: [RFC PATCH 31/41] random: introduce struct health_test + health_test_reset() placeholders Date: Mon, 21 Sep 2020 09:58:47 +0200 Message-Id: <20200921075857.4424-32-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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The to be implemented health tests will maintain some per-CPU state as they successively process the IRQ samples fed into the resp. fast_pool from add_interrupt_randomness(). In order to not to clutter future patches with trivialities, introduce an empty struct health_test supposed to keep said state in the future. Add a member of this new type to struct fast_pool. Introduce a health_test_reset() stub, which is supposed to (re)initialize instances of struct health_test. Invoke it from the fast_pool_init_accounting() to make sure that a fast_pool's contained health_test instance gets initialized once before its first usage. Make add_interrupt_randomness call fast_pool_init_accounting() earlier: health test functionality will get invoked before the latter's old location and it must have been initialized by that time. Signed-off-by: Nicolai Stange --- drivers/char/random.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 37746df53acf..0f56c873a501 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -879,6 +879,11 @@ static void discard_queued_entropy(struct entropy_store *r, spin_unlock_irqrestore(&r->lock, flags); } +struct health_test {}; + +static void health_test_reset(struct health_test *h) +{} + struct fast_pool { __u32 pool[4]; unsigned long last; @@ -886,6 +891,7 @@ struct fast_pool { unsigned char count; int event_entropy_shift; struct queued_entropy q; + struct health_test health; }; /* @@ -1644,6 +1650,7 @@ static inline void fast_pool_init_accounting(struct fast_pool *f) return; f->event_entropy_shift = min_irq_event_entropy_shift(); + health_test_reset(&f->health); } void add_interrupt_randomness(int irq, int irq_flags) @@ -1674,6 +1681,8 @@ void add_interrupt_randomness(int irq, int irq_flags) add_interrupt_bench(cycles); this_cpu_add(net_rand_state.s1, fast_pool->pool[cycles & 3]); + fast_pool_init_accounting(fast_pool); + if (unlikely(crng_init == 0)) { if ((fast_pool->count >= 64) && crng_fast_load((char *) fast_pool->pool, @@ -1692,8 +1701,6 @@ void add_interrupt_randomness(int irq, int irq_flags) if (!spin_trylock(&r->lock)) return; - fast_pool_init_accounting(fast_pool); - if (!fips_enabled) { /* award one bit for the contents of the fast pool */ nfrac = 1 << ENTROPY_SHIFT; -- 2.26.2