Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp395584iog; Fri, 24 Jun 2022 06:14:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vlozpt2Dk5UQAj8xamvk1zt3cMT3Rn2XxMNavv3MmRLUu8CVwAOXFtKBeZmP6w3jGZErKO X-Received: by 2002:a17:902:e5cb:b0:16a:7321:c3a1 with SMTP id u11-20020a170902e5cb00b0016a7321c3a1mr489962plf.62.1656076467023; Fri, 24 Jun 2022 06:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656076467; cv=none; d=google.com; s=arc-20160816; b=SB6msfEaTcVau0FRhd+xVJoaO512Gcuyf9Jo8DEJrSRpAsjYY3kFsWEzjfIqlvHXWy zQ30SpzwdCP/Ci59Xl4L9zY5BNTMU1UFGdYQHcIuqNHLwK3SbLJNQDM1C9SPFrUqkWZa i+3ISNi+An+LDnLlMJKZIOFsri9mDIq9i0e4g9mra90qUpw7rnZjgl+qyDDZrhqTCcN7 vqSYtjQaxSDgH2Ozx2nclrp6/2DbCw6rylFg97XpgSAQ6t8vgeLon6+6YIfhcpQDXf1i D5gJfacBjtfihFDHl20Kp9ch3vOajSzfTOoyul97MLLGl5yvAccBNCLgE8rlHXpxYp2a 3SJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1AD2JTwzEZZmB9x9wgRCyqulDsjFck59n65sLgL8zP4=; b=wp+ODBqAnOwFVgDuL5m+OUs5tm9whkP2H/VsDzJuLTAplVw6Ov41kxWF3AFxm3w8fx i6jdOwsCYe4EHVgTWlfkklR6vSP6Ov9zdOMMP8XF/5nV3Py/TGD+5o7Lcm8KnuNYNqY/ l8twFzFpr5fAzDsKWKQsVW2fgsAa64qz9hJrcjTPgvdDVuSTkUfwcH93E8h21LukmZcc 7Lx/8V8USC24akQ+mLFK2B56LbueDv+z7uacTnLy0cTcY9ZYrp6xaTTvOm3ftjZF9UyR X6keJd5dGLqHtcKRKbawYNbT/Oj6tKx58wVwNuPUexi2gx8/5v8DjDIeu9CJ0GsIWBzF Ivmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=PKMvwX+X; 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 129-20020a621887000000b005206a41e214si2635520pfy.38.2022.06.24.06.14.01; Fri, 24 Jun 2022 06:14:27 -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=PKMvwX+X; 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 S229743AbiFXNEj (ORCPT + 99 others); Fri, 24 Jun 2022 09:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiFXNEi (ORCPT ); Fri, 24 Jun 2022 09:04:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED1C43EDF; Fri, 24 Jun 2022 06:04:37 -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 70A63B827B2; Fri, 24 Jun 2022 13:04:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B71C3C341C0; Fri, 24 Jun 2022 13:04:34 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="PKMvwX+X" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1656075872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1AD2JTwzEZZmB9x9wgRCyqulDsjFck59n65sLgL8zP4=; b=PKMvwX+XxGk0rzspnBQ4HekkUXdtfxKMr8HBrzRBdJoB4wbKFsurLTzMaDyS2JIfy1bnEn 71TB3pQWjahxttdtujDQU+LefYtu3pddo7Ddu/zXsMCNn3g7CyT0lgPCnAbRHf6ELTO4Dq KlK/4s9pWSIikfc0IQ+/9ecbb/KjWhg= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 999bdd6e (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Fri, 24 Jun 2022 13:04:31 +0000 (UTC) Received: by mail-io1-f43.google.com with SMTP id r133so2620352iod.3; Fri, 24 Jun 2022 06:04:31 -0700 (PDT) X-Gm-Message-State: AJIora/UOLJ+od33vcB+85DiBCDkmTsdLw5l5/JDbl1IvcjRzMJsyCqP lGU9+JtX5h+eUp3+64UO6dtYCkn+uYpV8DEOEtw= X-Received: by 2002:a02:9709:0:b0:339:ef87:c30b with SMTP id x9-20020a029709000000b00339ef87c30bmr3981461jai.214.1656075870353; Fri, 24 Jun 2022 06:04:30 -0700 (PDT) MIME-Version: 1.0 References: <20220423212623.1957011-1-Jason@zx2c4.com> <20220423212623.1957011-10-Jason@zx2c4.com> In-Reply-To: From: "Jason A. Donenfeld" Date: Fri, 24 Jun 2022 15:04:19 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 09/17] mips: use fallback for random_get_entropy() instead of just c0 random To: "Maciej W. Rozycki" Cc: LKML , Linux Crypto Mailing List , Thomas Gleixner , Arnd Bergmann , Thomas Bogendoerfer Content-Type: text/plain; charset="UTF-8" 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,T_SCC_BODY_TEXT_LINE 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 Hey Maciej, On Wed, Apr 27, 2022 at 3:29 AM Jason A. Donenfeld wrote: > > Hey Maciej, > > On Tue, Apr 26, 2022 at 09:28:39PM +0100, Maciej W. Rozycki wrote: > > On Sat, 23 Apr 2022, Jason A. Donenfeld wrote: > > > > > diff --git a/arch/mips/include/asm/timex.h b/arch/mips/include/asm/timex.h > > > index b05bb70a2e46..8cfa485d19e6 100644 > > > --- a/arch/mips/include/asm/timex.h > > > +++ b/arch/mips/include/asm/timex.h > > [...] > > > + if (cpu_has_3kex) > > > + c0_random = (read_c0_random() >> 8) & 0x3f; > > > > Hmm, I wonder whether we do need to mask the contents of the register out > > here given that known implementations return zeros in reserved bits. Even > > though R3000 documentation I have access to makes no guarantee as to the > > values of the reserved bits here I think we can safely proceed according > > to what systems we do actually support do (even though it only saves one > > instruction). > > > > > else > > > - return 0; /* no usable register */ > > > + c0_random = read_c0_random() & 0x3f; > > > > Here the architecture guarantees unused bits to be zero, but the number > > of them varies between implementations. However we'll only ever use this > > leg for the R4000/R4400 processors, which have 48 TLB entries, and for the > > Ingenic XBurst cores, which I have now verified in documentation (which > > user-reported dumps from /proc/cpuinfo are consistent with) that have 32 > > TLB entries. So I think this mask operation can go as well. > > > > I guess these updates can be made with a follow-up change though. > > There is lots of optimization potential on a few fronts we've identified > in this thread. Let's save these for a follow-up. I'd rather this > initial one be at least somewhat simple, so that as it gets optimized, > it'll be easy to handle regressions. Also, it probably makes sense for > you to send the patches for these, since you have both the hardware > chops and the hardware itself to assess these ideas. I am interested in > the topic though, so please do CC me. Everything has been upstream for a little while now, which means development of this can move back to the proper MIPS tree like normal. Did you want to submit some optimizations? Would be happy to look at whatever you have in mind. Jason