Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp740144pxb; Fri, 22 Apr 2022 10:10:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy50R2rdRBLyePks3Hsgz7OP7E9/adgkFFHg1bPZua/QRKO+ugpMuTC8MhPECNa0qlgg2Bk X-Received: by 2002:a65:638d:0:b0:39d:74ad:ce0b with SMTP id h13-20020a65638d000000b0039d74adce0bmr4811664pgv.103.1650647438515; Fri, 22 Apr 2022 10:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650647438; cv=none; d=google.com; s=arc-20160816; b=nKZDZC/1Tav74x3HzgodVfR6z63eoyz7VdRNFZeoHJppN9e1S91D0PVP6z0jnoyxi5 ynhhLtd6MjgYONiIKntxcSfvb88UTBXlmdQZ2+D2ffZcN1wuDXoq8N8v95npZs81BeZX Zy2t1561KX0ULXdPj+u1RKg4rFRuT1+FF0agzgH1i+jDeOW6AQHwyfOxsBjW5RjX7NGz rgEkAGdHg2KCIVWC4PJTATuL/qyshJ0fGBXTxe/XGpVptnuXV/GjZOPQzoiPC62qB+ZK b3WAvy7qdJrcwvgjLKoZHCyPVwgFenNThsJflCEg39REWxzLUcpkewrL7Z7OQXUvFlXd n7rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=NARKgukQk8Uk582G9U3fuWAeKQL39TQNM0zp4fFpkv4=; b=KET9n730pCsA6XDFUcTHdeIsOGrwftjYPXqAEUYiyUxZkNSo2x1messZ8jf7oDjSSA CH+PYutuvnxQ2FRZjkBghlRtFZjklfVYwHQvn4rmX5FKVS6lwoYQsAudcHUlIZWS3aUU lTblwT5dkCbudbFAuxHyD4TsAkBtVaNjGW/K9mW7aGL2DtlHhDCsiIyJPDFZKvrdVWiR GXKHSv1gKYzUVB/NDaADbgrGCQ4LXyq8w6xxOVSh4enX7bR3GbJbagV/q0+eWYBS8IKC iKaJ+Y0/Y3W4Sx+anW4AU5SrWbdy1cNEmUjYorxPJr/ugna5xDDOvk4p/KUprlrPHRFo dZyA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l19-20020a635b53000000b003a30633d0a5si8754087pgm.489.2022.04.22.10.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 10:10:38 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 411DD939DD; Fri, 22 Apr 2022 10:10:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391930AbiDUT2s (ORCPT + 99 others); Thu, 21 Apr 2022 15:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1391925AbiDUT2r (ORCPT ); Thu, 21 Apr 2022 15:28:47 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6A13D4D26C; Thu, 21 Apr 2022 12:25:56 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 1C9CB92009D; Thu, 21 Apr 2022 21:25:53 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 18FDA92009C; Thu, 21 Apr 2022 20:25:53 +0100 (BST) Date: Thu, 21 Apr 2022 20:25:53 +0100 (BST) From: "Maciej W. Rozycki" To: "Jason A. Donenfeld" cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, tglx@linutronix.de, arnd@arndb.de, Theodore Ts'o , Dominik Brodowski , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Thomas Bogendoerfer , Paul Walmsley , Palmer Dabbelt , Albert Ou , "David S . Miller" , Richard Weinberger , Anton Ivanov , Johannes Berg , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Chris Zankel , Max Filippov , Stephen Boyd , Dinh Nguyen , linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, x86@kernel.org, linux-xtensa@linux-xtensa.org Subject: Re: [PATCH v5 04/11] mips: use fallback for random_get_entropy() instead of just c0 random In-Reply-To: <20220419111650.1582274-5-Jason@zx2c4.com> Message-ID: References: <20220419111650.1582274-1-Jason@zx2c4.com> <20220419111650.1582274-5-Jason@zx2c4.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 On Tue, 19 Apr 2022, Jason A. Donenfeld wrote: > For situations in which we don't have a c0 counter register available, > we've been falling back to reading the c0 "random" register, which is > usually bounded by the amount of TLB entries and changes every other > cycle or so. This means it wraps extremely often. We can do better by > combining this fast-changing counter with a potentially slower-changing > counter from random_get_entropy_fallback() in the more significant bits. > This commit combines the two, taking into account that the changing bits > are in a different bit position depending on the CPU model. In addition, > we previously were falling back to 0 for ancient CPUs that Linux does > not support anyway; remove that dead path entirely. Tested-by: Maciej W. Rozycki I've pushed the algorithm through testing with a number of suitable systems: - an R2000A and an R3000A with no timer of any kind, only jiffies, - an R3400 with a chipset timer only, - an R4400SC with a usable buggy CP0 counter and a chipset timer, - a 5Kc with a good CP0 counter only, with no obvious issues spotted. Thank you for working on this! Maciej