Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5066088imw; Tue, 19 Jul 2022 20:20:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u1F1gyV2AVB2G5kM0XzQV7NjD2lUvestwsWypmKVYi4PrNF6fek2hHIuIs7bvoGcoawbTL X-Received: by 2002:a17:907:c27:b0:72b:8118:b899 with SMTP id ga39-20020a1709070c2700b0072b8118b899mr33785128ejc.739.1658287222252; Tue, 19 Jul 2022 20:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658287222; cv=none; d=google.com; s=arc-20160816; b=UIlHRwtVvBbrU8QOW+K43ropj8+cssybNCBmB0veRwn5FXT/ReVsY6VJcLxSamHe96 zCghIRCqxzQSRJOcqxt4Li5DKmT/xSlnWmG+1fTJ+yRVcdacqlInjznnx1EIjso/oZqi zoBjMbXH0WnhtGQ7pU0G5NDu+LqOAeTxWHR44ibaXhUZ8HcfQmhkdeSdWsoye+6pDGUF Iz763CxIgsyok0jM2eY1oAZINyEcq461GPfVPmIe/mXPUwZlV2hDtwWb33vpZU3hCOVl bIagyY7ck1kGUt7SNQUp01LLoi3l1Awd243SHAoK7QaL9fLtUH5FNl9nT9ccT1Hru+Ev xLJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=07a5cjF0e9SE4ghrWPN59Y1xcS8Op+XIj+zd97Y/sD4=; b=pBhWYXSJ4RVxFEnQlKwkdeBtlN1CGJFNh/iDlwz9Y4vefdN3Tn4eoOshxlU365snr9 XUsUWMx7WTAlU8iD9B8fql5MYOxKnS0iCHaSAuWvg3fYwBBzwhwYyIhxDKKVEauTmnXw 2QWb8Wsp+sRjX2HIqMbe+q873jYhYnNH4X5HA4mS9lMBjHPbu1vo9v1MBHHrSGCkF/ER Cu1iBki0rdoM6CGjZSOeYrzxZR9BrqWP2/VBQ07v/Hd0FVKnOPc122tJABeDntFtj5Ra lGcR+TesG/2zFFllJNvgJ4Zhm+XVneUf5CTCeLAUrvSrTUleE6vA/qui0HvFauHLnUuq Khpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=VBUywPF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs7-20020a1709072d0700b0072b95dee668si28734256ejc.489.2022.07.19.20.19.57; Tue, 19 Jul 2022 20:20:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@ellerman.id.au header.s=201909 header.b=VBUywPF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240090AbiGTDDb (ORCPT + 99 others); Tue, 19 Jul 2022 23:03:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239226AbiGTDD1 (ORCPT ); Tue, 19 Jul 2022 23:03:27 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCFF1BEAB; Tue, 19 Jul 2022 20:03:25 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4LngWD5dzkz4x7X; Wed, 20 Jul 2022 13:03:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1658286203; bh=07a5cjF0e9SE4ghrWPN59Y1xcS8Op+XIj+zd97Y/sD4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=VBUywPF7BJl/iHXB6z0aZcik5dkO6ISMryTwHHBOfdsHO/F7DusRlENuecPpb0ocU h0aptq1KpohsSf3IbkKyI8f/yuYSR1zSllHmHraP+a2MZhaIo0+7L6e50EE+01F76G phcNILJZ/UkLOwibUep6WX+/H3wRxrGPwmLv8gGFpgLZV+3zJCq9ePTtD4Z+2l0JX6 qTSYLwY1fVjmsG5ebVAceqlzLnx4mIDtEmy+qrMvPYMF6f58UUhgep38kjZhOXRySi 5zet7uxpBCKVR+InMq55C9PgjnZUsRY+/vkd5H1wFqmQ6FjMy34sVQ45g1LvS6H0Ty Ff7032tCwAY/Q== From: Michael Ellerman To: Gabriel Paubert Cc: "Jason A. Donenfeld" , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, x86@kernel.org, Catalin Marinas , Heiko Carstens , Johannes Berg , Harald Freudenberger , "H . Peter Anvin" , Alexander Gordeev , Borislav Petkov , Will Deacon , Thomas Gleixner Subject: Re: [PATCH v2] random: handle archrandom in plural words In-Reply-To: References: <20220717200356.75060-1-Jason@zx2c4.com> <87a697dj9s.fsf@mpe.ellerman.id.au> Date: Wed, 20 Jul 2022 13:03:19 +1000 Message-ID: <87y1wocwp4.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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-kernel@vger.kernel.org Gabriel Paubert writes: > On Mon, Jul 18, 2022 at 04:31:11PM +1000, Michael Ellerman wrote: >> "Jason A. Donenfeld" writes: >> > The archrandom interface was originally designed for x86, which supplies >> > RDRAND/RDSEED for receiving random words into registers, resulting in >> > one function to generate an int and another to generate a long. However, >> > other architectures don't follow this. >> > >> > On arm64, the SMCCC TRNG interface can return between 1 and 3 words. On >> > s390, the CPACF TRNG interface can return between 1 and 32 words for the >> > same cost as for one word. On UML, the os_getrandom() interface can return >> > arbitrary amounts. >> > >> > So change the api signature to take a "words" parameter designating the >> > maximum number of words requested, and then return the number of words >> > generated. >> >> On powerpc a word is 32-bits and a doubleword is 64-bits (at least >> according to the ISA). I think that's also true on other 64-bit >> architectures. > > IIRC, this is (or was) not the case on Alpha, where word was defined as > 16 bits. All assembly mnemonics had w for 16 bits, l for 32 bits, and q > for 64 bits. Yeah I should have said on *some* other 64-bit arches. Seems to be a common feature/hack on arches that have evolved over time, or been inspired by earlier arches. The latest Power ISA has octwords :) cheers