Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1318358iob; Fri, 29 Apr 2022 02:46:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHyOYVWJNKjTPuye+w7eOtIEEOU3z1MvWBEmcVA2JCuYoEihGmQmLurdUZ7/orFsMT9YY9 X-Received: by 2002:a05:6512:3c8a:b0:472:2513:db16 with SMTP id h10-20020a0565123c8a00b004722513db16mr9811375lfv.497.1651225604722; Fri, 29 Apr 2022 02:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651225604; cv=none; d=google.com; s=arc-20160816; b=cuB3NCu3WuRiIQjm1PtDpJ7jzq9FfsWOkkywmHb6CIOLYQYaDG0ZKL1cpVdH3gYgq0 A/Wbc/xHF1TSO1Mn34nI689WggGuEmN949yt8vDzSB89m4wbw/5DDlD904AnKovpnuTa ahiekvMnAPLTfRtr4vkrcJz9VTN6jA2BmhKVILfQbPLEykYvFoIvVIIi0WUIOCx+dJuj DDQkTPehSfsTZH2PDu9KYiDSrzMjQRYYc/jZBWk1xtLBOC09qLTQmDdL2famG8afwote YnQkoDL90xct/n1jfHNlwAUMLhNnAqdxnsngMQgFLEMuLeVaNiyiWD2wjMZb/42n3dKP Tg/Q== 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 :dkim-signature; bh=N6XdKUj5iYJ5RwXtCRVRiwXorABzoye1SBxh5BDCkro=; b=w7IjcmRXemik63ukEnpX87095+fxgoXfjN3NMY1epBajF9NFftFZ84nTL2uPV3ZbX2 zCYbgYLGp+D5CcRjWRUzEd8848355bZOU1UE7Xeyfbdix2KZ2aYc+Hisrx+e4LjYPLq1 Ho3ulu6iBNAKeRAdsboXOBvjzco98ibvF2POHMOVbpzk6GhJP+sJkiQOisnG6mYf9cnj Xg5upkpgaSEjX0iTTZodQhOVGp8u93wi6tCcH0i9KMf7EJfQuVtVDibzdzKUbGAf/bGH 5ldWA2UwMBB6ueWDqJy6gxf3bOWyaS0ziNjS/OpMc8GDcwel4ZQzztVWKNi9vn+krNwt hI5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=i1c9xOsU; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a056512110600b0046d02428cabsi7094247lfg.175.2022.04.29.02.46.15; Fri, 29 Apr 2022 02:46:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=i1c9xOsU; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353546AbiD2AUZ (ORCPT + 99 others); Thu, 28 Apr 2022 20:20:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351307AbiD2AUZ (ORCPT ); Thu, 28 Apr 2022 20:20:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF9B627CF9; Thu, 28 Apr 2022 17:17:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A9E74B830A9; Fri, 29 Apr 2022 00:17:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCAC8C385AD; Fri, 29 Apr 2022 00:17:05 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="i1c9xOsU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1651191423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N6XdKUj5iYJ5RwXtCRVRiwXorABzoye1SBxh5BDCkro=; b=i1c9xOsUF+LWwlI4RpyMAD/JNy2GTZMlypd0y4aaVYhgqSJKA9SuCLEn5URQN03fYnXMCK kLQzgwp1QbQtPlr2xo7ZxFh1yv2O2PyDtLjpDEGR6XE4HnIJWQIkhTeH7M/gfkQfDcnwu1 rl9j3RbM+5TxC1rvp1p8UiHyRPgwQhg= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 9e137a29 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Fri, 29 Apr 2022 00:17:02 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Cc: Stafford Horne , "Jason A. Donenfeld" Subject: [PATCH v7 11/17] openrisc: account for 0 starting value in random_get_entropy() Date: Fri, 29 Apr 2022 02:16:48 +0200 Message-Id: <20220429001648.1671472-1-Jason@zx2c4.com> In-Reply-To: <20220423212623.1957011-12-Jason@zx2c4.com> References: <20220423212623.1957011-12-Jason@zx2c4.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org As a sanity check, this series makes sure that during early boot, the cycle counter isn't returning all zeros. However, OpenRISC's TTCR timer can be rather slow and starts out as zero during stages of early boot. We know it works, however. So just always add 1 to random_get_entropy() so that it doesn't trigger these checks. Cc: Thomas Gleixner Cc: Arnd Bergmann Cc: Jonas Bonn Cc: Stefan Kristiansson Acked-by: Stafford Horne Signed-off-by: Jason A. Donenfeld --- Changes v6->v7: - Add 1 to cycle counter to account for functional but slow-to-begin counter on QEMU. arch/openrisc/include/asm/timex.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/openrisc/include/asm/timex.h b/arch/openrisc/include/asm/timex.h index d52b4e536e3f..a78a5807c927 100644 --- a/arch/openrisc/include/asm/timex.h +++ b/arch/openrisc/include/asm/timex.h @@ -23,6 +23,9 @@ static inline cycles_t get_cycles(void) { return mfspr(SPR_TTCR); } +#define get_cycles get_cycles + +#define random_get_entropy() ((unsigned long)get_cycles() + 1) /* This isn't really used any more */ #define CLOCK_TICK_RATE 1000 -- 2.35.1