Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2951221pxk; Mon, 21 Sep 2020 01:01:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI0GPZWLq9RmpafMGoB4mnjmVpNHneyRrmDhXcQCn/bqg5HcpLkJ/ZQRVKCHhog6mJX7EQ X-Received: by 2002:aa7:de91:: with SMTP id j17mr51485313edv.85.1600675294748; Mon, 21 Sep 2020 01:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600675294; cv=none; d=google.com; s=arc-20160816; b=x06loFGz22Ia4S0x0gYyZnMrPcu4wQWf9dfM5fgyUxLpQSC8C2jlRCwjm/Ju3AbInq 27S31QAppWEIANVicVzFpexsuh1Ozc9QVET4fZCNHL9MWGXRMB5S3vBWZ63Ly7kJM6yq 48zHhBkiq42+B+Cq7/ADhCyp+W9Nx5WyJrYfGeqHD4pEz/i0DqU525UTDp/6MS+Hv5I2 Uglm9LwaM4iwNL3kE/x+BHvOc6DAa+fpC/XWXaNSrWhgpx0bWa3ixOIIcH0XT7F9pgcc jWEGDI6Fga8cBXWyYpNpME+CFMq7SfQmDP8ViMBQ9xkoKZSXaGnSN/gn2EIdo6F2puiU OQdQ== 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=/SkKb+x1XhrLJ8fJKzIN2KyFYno2kFmGzKLsMEVtD9A=; b=NqFeLtiCS1en+FBPHsJ49B2UZq1mB0vm+o5yAJ++ck82IdcUmwdJJsNA43i/q9oRxW iIRMbrEoSAVKmWJmVk2weGnE/lolL6iFV8Prqo6vyL0F8E7hJFkOO5T70/L3877J+qPJ C1+Y5rPjYuoQg2DVChszBF5DUu8QVBo4v9hKIs3IefHGWu5WbaRamLbd3u6GnAOrpZlh fu8/+rOMZT7/IGBVMMXaXmGMleyJnzKkbrFnPKPnIYwRPLaDEONOSYm0kaoytOZZ16Tj ZH1mF8fJdDovTzCitp4AufplVK9Ls/9yV1AoHR5fsCIu5XxlrhWm4wzdBqYBoncrudKJ B2SQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 ds20si7587529ejc.62.2020.09.21.01.01.10; Mon, 21 Sep 2020 01:01:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbgIUIAO (ORCPT + 99 others); Mon, 21 Sep 2020 04:00:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:57298 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbgIUH7X (ORCPT ); Mon, 21 Sep 2020 03:59:23 -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 C919BB512; Mon, 21 Sep 2020 07:59:57 +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 15/41] random: convert add_hwgenerator_randomness() to queued_entropy API Date: Mon, 21 Sep 2020 09:58:31 +0200 Message-Id: <20200921075857.4424-16-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-crypto@vger.kernel.org In an effort to drop credit_entropy_bits() in favor of the new queue_entropy()/dispatch_queued_entropy() API, convert add_hwgenerator_randomness() from the former to the latter. As a side effect, the pool entropy watermark as tracked over the duration of the mix_pool_bytes() operation is now taken correctly taken into account when calulating the amount of new entropy to dispatch to the pool based on the latter's fill level. Signed-off-by: Nicolai Stange --- drivers/char/random.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 60ce185d7b2d..78e65367ea86 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -2640,6 +2640,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count, size_t entropy) { struct entropy_store *poolp = &input_pool; + struct queued_entropy q = { 0 }; if (unlikely(crng_init == 0)) { crng_fast_load(buffer, count); @@ -2652,8 +2653,9 @@ void add_hwgenerator_randomness(const char *buffer, size_t count, */ wait_event_interruptible(random_write_wait, kthread_should_stop() || ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits); + queue_entropy(poolp, &q, entropy << ENTROPY_SHIFT); mix_pool_bytes(poolp, buffer, count); - credit_entropy_bits(poolp, entropy); + dispatch_queued_entropy(poolp, &q); } EXPORT_SYMBOL_GPL(add_hwgenerator_randomness); -- 2.26.2