From patchwork Fri Oct 28 16:00:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 13023937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1D32C38A02 for ; Fri, 28 Oct 2022 16:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=Ow3FJAB+jxiwmGVc3DdMCODO0PvqABv7dfm0SDliQs0=; b=uwM4HfXSSjdLK0 XhqFvquP1wWRdvq2XPbOUQSe3W75vmOjdCUsOPT9mDETgdl1/7aWWcTOCnZt4LC5qTdSAm0LwogOX 6yyOxQJd7ODyD72o0vcf2IwkXLza0wQQwIe0mqWaGQ+/1fdSMNF35t9FCg/a5MdZUuNgqj/wo1L3z psUh8jkm7FUz9inEqQi5X/+C2UqlOGuNyqkKK67G50BTJcayMT+QjkHu0lqzIMQebSSt9ECgr1ttT 9Jv/a/RFmuTZOpY3P3koDUycXYgdUTp8ylP4SMN00cTgafB9TwM1FpNwcQ4Z1uT1mxwLZ2TOtDe5u 8b20kJbx7Evm08TUOAAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooRrW-000lqn-Eo; Fri, 28 Oct 2022 16:05:39 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooRrQ-000lnG-01 for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 16:05:34 +0000 Received: by mail-wr1-x42a.google.com with SMTP id v1so7162576wrt.11 for ; Fri, 28 Oct 2022 09:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EwmCRs4VSiMfypRrD7D2mR4onALfK9W6TO7PXOA1Xlw=; b=fTjuqZyXsmSTk2cIPQ/0aCdcmB+/FsutYK3NdLqf0DNci1I6j4hl4AqlqJPNqSeZB5 iDopaXFIaQajYePTXR/Usccjn+rhQ9YX6MbdOUr0ZesAHQlVZooI4D5brDiy7dhu7agq Q/NstEV5l8VKCLuC9BJpvAswKqto1GtwHQh+Hw40PzQiaCjkBS6jy3nbos9b9boaZlmY X2pFBOtPo/H288fAyaWlJY5gX5XDRG96CynvLC8nfaSz1HNYXON2ICyXFoZdGqeyA1ey VtWHe6HwzBGqTVOm7vA8I5pQlC1XDtdkd4p4fIyvk7gHki9UnZeRYFFL1pj4YmTx47gq 0L5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EwmCRs4VSiMfypRrD7D2mR4onALfK9W6TO7PXOA1Xlw=; b=0kIAbUm52fTwJKyJP3aT5VKRYC2AlSZ1+KQLGaCswl9JnjEqBQG/uNY+YHBcyl/On7 3blrHvSPeQ6L5OD+Ge7X0t4gC6FnIBrjuHn3lrAA9pAWrBxq5G1bbiI8gpJIfTpNhTt9 AqQxi+9uH8fi2gIf7vS9Efl1o1hABTzRLcbMgAWv87tZPRfJDtyjB+M46jKL5v5Q+xhO nvcNsLtUr+ESWNu70halIn5xp2IlVnXOOvsYoqIORSyRljVX8FMJ7fz4hbqVV+by0BUO KPkBVY+qMSbabd6ggGYIjW2Ug+Us2airbVd1FI9Edr2zVKAsnSmFwtjqU7WlMgrnX+Sz z4OQ== X-Gm-Message-State: ACrzQf09T6EZkuQw4+JXS6Hy16uMiCp/4i7SvzlW0SWSIi5X40CeYYDY fm6GA4HTBTOVQbQXGqYnEeTSkw== X-Google-Smtp-Source: AMsMyM6LAIow3wsRy3i/XkJRAuc+KOqBrJiL8BkCF5fHKU+6HuYulPKWA1OkiKQ5ODgHDgEeChW/0g== X-Received: by 2002:adf:f384:0:b0:236:64ad:c958 with SMTP id m4-20020adff384000000b0023664adc958mr63408wro.174.1666973126321; Fri, 28 Oct 2022 09:05:26 -0700 (PDT) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id dn10-20020a05600c654a00b003a3170a7af9sm4560049wmb.4.2022.10.28.09.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:05:25 -0700 (PDT) From: Jean-Philippe Brucker To: Jason@zx2c4.com, tytso@mit.edu Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ardb@kernel.org, andre.przywara@arm.com, Jean-Philippe Brucker Subject: [PATCH] random: Use arch_get_random*_early() in random_init() Date: Fri, 28 Oct 2022 17:00:42 +0100 Message-Id: <20221028160041.753052-1-jean-philippe@linaro.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_090532_113795_D5B7B9D9 X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org While reworking the archrandom handling, commit d349ab99eec7 ("random: handle archrandom with multiple longs") switched to the non-early archrandom helpers in random_init(), which broke initialization of the entropy pool from the arm64 random generator. Indeed at that point the arm64 CPU features, which verify that all CPUs have compatible capabilities, are not finalized so arch_get_random_seed_longs() is unsuccessful. Instead random_init() should use the _early functions, which check only the boot CPU on arm64. On other architectures the _early functions directly call the normal ones. Fixes: d349ab99eec7 ("random: handle archrandom with multiple longs") Signed-off-by: Jean-Philippe Brucker --- drivers/char/random.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 2fe28eeb2f38..085af17c32f5 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -791,13 +791,14 @@ void __init random_init_early(const char *command_line) #endif for (i = 0, arch_bits = sizeof(entropy) * 8; i < ARRAY_SIZE(entropy);) { - longs = arch_get_random_seed_longs(entropy, ARRAY_SIZE(entropy) - i); + longs = arch_get_random_seed_longs_early(entropy, + ARRAY_SIZE(entropy) - i); if (longs) { _mix_pool_bytes(entropy, sizeof(*entropy) * longs); i += longs; continue; } - longs = arch_get_random_longs(entropy, ARRAY_SIZE(entropy) - i); + longs = arch_get_random_longs_early(entropy, ARRAY_SIZE(entropy) - i); if (longs) { _mix_pool_bytes(entropy, sizeof(*entropy) * longs); i += longs;