From patchwork Fri Nov 13 16:19:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 11904067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADE9BC388F7 for ; Fri, 13 Nov 2020 16:19:55 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E3382076B for ; Fri, 13 Nov 2020 16:19:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="B/qYbxFg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E3382076B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=NWBy6koQa/o/hFXHZdoy/kKcQMP4qkRqV0d8T3K7ej0=; b=B/qYbxFgEGzUhktKEYz3NHpei1 VRrZpEpCCbcglzK2zLmDY21y96w5ABSF0nz5gqTW9ZoCwoe24uHoU1ajuISYie7ITjTRfIjqcGA+t gh0mPEzVkBBzv79I1Nh5xCSqX1rKR1XlrghWsOos/LnrfVSztAIB1aD7vVVexWs3cEkJYF45A5pLB BUgciZIJKPpLlEB5nKSnhWcZ5NpN70WbLTtV+Gnd2hEI4PCJc4isRXzmdmouFDgySeKt+LFwmvMSg zYT13sBl7nJY8+VBS4jm0DvgV5AJrEoCWHSJqTk5/REzZvzHEKkMsGV2ucGxHHoux4nvn8aihQsFy d/ZG/aHA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdbnK-0003dW-8b; Fri, 13 Nov 2020 16:19:26 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdbnI-0003co-0g for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 16:19:24 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 097BF1042; Fri, 13 Nov 2020 08:19:22 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.195.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF1363F718; Fri, 13 Nov 2020 08:19:20 -0800 (PST) From: Andre Przywara To: Theodore Ts'o Subject: [PATCH] random: Use arch_get_random_long_early() for init_std_data() Date: Fri, 13 Nov 2020 16:19:12 +0000 Message-Id: <20201113161912.62068-1-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201113_111924_111601_4B09F195 X-CRM114-Status: GOOD ( 14.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , linux-kernel@vger.kernel.org, Mark Brown , Will Deacon , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In commit 253d3194c2b5 ("random: add arch_get_random_*long_early()") we introduced _early versions of arch_get_random_long(), that are used on arm64 to use the CPU RNDR instruction early in the boot process, before we have established system-wide availability. This covers the calls in crng_initialize_primary(), but missed the calls in init_std_data(), happening just before that. Use the _early versions of the arch_get_random* calls also in init_std_data(), to help initialising the pool with proper seed values. Fixes: 253d3194c2b5 ("random: add arch_get_random_*long_early()") Cc: Mark Rutland Signed-off-by: Andre Przywara Acked-by: Will Deacon --- drivers/char/random.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 2a41b21623ae..43bb331a67bd 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1778,8 +1778,8 @@ static void __init init_std_data(struct entropy_store *r) mix_pool_bytes(r, &now, sizeof(now)); for (i = r->poolinfo->poolbytes; i > 0; i -= sizeof(rv)) { - if (!arch_get_random_seed_long(&rv) && - !arch_get_random_long(&rv)) + if (!arch_get_random_seed_long_early(&rv) && + !arch_get_random_long_early(&rv)) rv = random_get_entropy(); mix_pool_bytes(r, &rv, sizeof(rv)); }