From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6550FC433EF for ; Mon, 18 Jul 2022 06:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233406AbiGRGbV (ORCPT ); Mon, 18 Jul 2022 02:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbiGRGbV (ORCPT ); Mon, 18 Jul 2022 02:31:21 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 874CD2DCF; Sun, 17 Jul 2022 23:31:19 -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 4LmXD32nd5z4xXF; Mon, 18 Jul 2022 16:31:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1658125878; bh=k/N2K3A9Z5dV/oTr9hSFt64T6vlj0t235fSbwzPjkEA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=rhhdlO5yl1t520u8BwcWmo9I5ryGffVzXJ8RE1EukbGFkVthHUiVLAjQDW9mzbv/g OWnQlMsP8NiwLcTMDx/u2JG1Y845X4k4XCnsJBoiWa8UdmP575Nw0RWGtzsUbxe3Jo bjBoqD+2lq0gKxXSMd0ODRCH8GSL8M6V7sL4NgfhjmUAkga44TSCl7UfnulRjDEHIo FCaFHm+TySK1rfoT4o+dES2ZEbTrcYCPeHtbeg4lIr9pHGtIWMcl595MciqG3LLg/f VdNtecuoOERxk91eMns13YSoniRlSGOaiEJZ8DZNFdGSbyIrboLkLaefUXVezPcmCK 4YiA9QdovohVg== From: Michael Ellerman To: "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 Cc: "Jason A. Donenfeld" , Will Deacon , Alexander Gordeev , Thomas Gleixner , "H . Peter Anvin" , Catalin Marinas , Borislav Petkov , Heiko Carstens , Johannes Berg , Harald Freudenberger Subject: Re: [PATCH v2] random: handle archrandom in plural words In-Reply-To: <20220717200356.75060-1-Jason@zx2c4.com> References: <20220717200356.75060-1-Jason@zx2c4.com> Date: Mon, 18 Jul 2022 16:31:11 +1000 Message-ID: <87a697dj9s.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org "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. You could avoid any confusion by defining the API in terms of "longs" rather than "words". But that's just a comment, see what others think. > arch/powerpc/include/asm/archrandom.h | 30 ++------ > arch/powerpc/kvm/book3s_hv.c | 2 +- Acked-by: Michael Ellerman (powerpc) cheers From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 B250EC433EF for ; Mon, 18 Jul 2022 06:31:54 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4LmXDn14qbz3c7K for ; Mon, 18 Jul 2022 16:31:53 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.a=rsa-sha256 header.s=201909 header.b=rhhdlO5y; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4LmXD62bVYz3bYs for ; Mon, 18 Jul 2022 16:31:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.a=rsa-sha256 header.s=201909 header.b=rhhdlO5y; dkim-atps=neutral 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 4LmXD32nd5z4xXF; Mon, 18 Jul 2022 16:31:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1658125878; bh=k/N2K3A9Z5dV/oTr9hSFt64T6vlj0t235fSbwzPjkEA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=rhhdlO5yl1t520u8BwcWmo9I5ryGffVzXJ8RE1EukbGFkVthHUiVLAjQDW9mzbv/g OWnQlMsP8NiwLcTMDx/u2JG1Y845X4k4XCnsJBoiWa8UdmP575Nw0RWGtzsUbxe3Jo bjBoqD+2lq0gKxXSMd0ODRCH8GSL8M6V7sL4NgfhjmUAkga44TSCl7UfnulRjDEHIo FCaFHm+TySK1rfoT4o+dES2ZEbTrcYCPeHtbeg4lIr9pHGtIWMcl595MciqG3LLg/f VdNtecuoOERxk91eMns13YSoniRlSGOaiEJZ8DZNFdGSbyIrboLkLaefUXVezPcmCK 4YiA9QdovohVg== From: Michael Ellerman To: "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 Subject: Re: [PATCH v2] random: handle archrandom in plural words In-Reply-To: <20220717200356.75060-1-Jason@zx2c4.com> References: <20220717200356.75060-1-Jason@zx2c4.com> Date: Mon, 18 Jul 2022 16:31:11 +1000 Message-ID: <87a697dj9s.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason A. Donenfeld" , Catalin Marinas , Heiko Carstens , Johannes Berg , Harald Freudenberger , "H . Peter Anvin" , Alexander Gordeev , Borislav Petkov , Will Deacon , Thomas Gleixner Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" "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. You could avoid any confusion by defining the API in terms of "longs" rather than "words". But that's just a comment, see what others think. > arch/powerpc/include/asm/archrandom.h | 30 ++------ > arch/powerpc/kvm/book3s_hv.c | 2 +- Acked-by: Michael Ellerman (powerpc) cheers From mboxrd@z Thu Jan 1 00:00:00 1970 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 1F916CCA479 for ; Mon, 18 Jul 2022 06:32:49 +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:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Whs+sSGLy9aO4WD4ttMECJT3fqVQsHG5M5+XpvBBr6g=; b=3bmU0tw9INVH1Q qN9bdih+vRlfYTx91TVMahvLuH0GanT/7EXepJqVz2SU6KtQm5Hbej+j6cKrrW1l771uWixvT1AQQ 0WR7HmlL6Nnl/JsmWnc37u7E7IbKqpuG5zHJ6pQFMcy9DYKKWjpMt/sjlgQpnZJ9xo68W2T/TfUmx 3LzBdzRJSLjIfAqfRePEKku+olA4T7yDCOsajkf1C/4iwEjySvoiMet29Y18uK21C9TI9HsaZP9ab hnm8y24F9MF4dCeZ687/U3r4nHQlAv1GxB6+btsd/ZzqbtkdNLztrgfcKe/kKunKiQvLGGCXQZOJJ g4ynuGkrdZFWdtdNt6Ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDKI2-00BDrm-6d; Mon, 18 Jul 2022 06:31:34 +0000 Received: from gandalf.ozlabs.org ([150.107.74.76]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDKHy-00BDmt-FC for linux-arm-kernel@lists.infradead.org; Mon, 18 Jul 2022 06:31:32 +0000 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 4LmXD32nd5z4xXF; Mon, 18 Jul 2022 16:31:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1658125878; bh=k/N2K3A9Z5dV/oTr9hSFt64T6vlj0t235fSbwzPjkEA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=rhhdlO5yl1t520u8BwcWmo9I5ryGffVzXJ8RE1EukbGFkVthHUiVLAjQDW9mzbv/g OWnQlMsP8NiwLcTMDx/u2JG1Y845X4k4XCnsJBoiWa8UdmP575Nw0RWGtzsUbxe3Jo bjBoqD+2lq0gKxXSMd0ODRCH8GSL8M6V7sL4NgfhjmUAkga44TSCl7UfnulRjDEHIo FCaFHm+TySK1rfoT4o+dES2ZEbTrcYCPeHtbeg4lIr9pHGtIWMcl595MciqG3LLg/f VdNtecuoOERxk91eMns13YSoniRlSGOaiEJZ8DZNFdGSbyIrboLkLaefUXVezPcmCK 4YiA9QdovohVg== From: Michael Ellerman To: "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 Cc: "Jason A. Donenfeld" , Will Deacon , Alexander Gordeev , Thomas Gleixner , "H . Peter Anvin" , Catalin Marinas , Borislav Petkov , Heiko Carstens , Johannes Berg , Harald Freudenberger Subject: Re: [PATCH v2] random: handle archrandom in plural words In-Reply-To: <20220717200356.75060-1-Jason@zx2c4.com> References: <20220717200356.75060-1-Jason@zx2c4.com> Date: Mon, 18 Jul 2022 16:31:11 +1000 Message-ID: <87a697dj9s.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220717_233130_703533_2881A50B X-CRM114-Status: GOOD ( 11.56 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org "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. You could avoid any confusion by defining the API in terms of "longs" rather than "words". But that's just a comment, see what others think. > arch/powerpc/include/asm/archrandom.h | 30 ++------ > arch/powerpc/kvm/book3s_hv.c | 2 +- Acked-by: Michael Ellerman (powerpc) cheers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel