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 2A715C43334 for ; Fri, 22 Jul 2022 12:08:34 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kL/5mUgaY3IKQODWnCVRfhXAeNoN8/Z+nWsci6DeZEE=; b=1BKD1/LcQF960o R2r0o1iYYf5cPYm+HLFyBVsdL2C3/t2OCGRF7RFZp/tZC/pfcXK4db9jZKRJcdMeIM/PtQ1JpAqSk yv9ACqhox3DSDDtM5QcWcuKacnEzMS/ME3B4AIfrkUJvtEcqYO6YwR5HxEHrxodb5b8Z9mA7D9WJs QfbQiPBfgwh5ikrP3iOOf8J5hTyZxt6e/iNY0MffGUWglrUQPDm2mvKYOpYhdaFOIpmAGk0RUPU+a RP4B5QoSzHWN1XO5Q9Rm239wiDhoD5jkwFjcXyZ9PAAUf9gPH53BWqFBdwFC6nWdnA9N1XHOdrO73 jdvi2V89gXbO2/iUlk6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oErRF-003wdL-6M; Fri, 22 Jul 2022 12:07:25 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oErRB-003wWZ-4e for linux-arm-kernel@lists.infradead.org; Fri, 22 Jul 2022 12:07:23 +0000 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26MBGsuu020972; Fri, 22 Jul 2022 12:07:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=o+BTY/uCMLQWXsj6/f4TbfVVZ0qdoDBQEnzK950VUC0=; b=IQD7FPF3gcg6KE7gIU6/9u9ZFLMf0cC3DH4vM5/231C859/xzYN5gZtrBfDiCqvB2dJn AtZaTkHXGxaQNBI4sC6VllYWQ4bNLpjMQ6LKe2mN0M1Pbujyz80vVVmCj8cQ9J4dL6iz P6CzMVccjkwt71XG45cOKBpwm1vrF+zEd1/F+xmjesufYtKz+ZAucdCd9ih5co1wZNl3 97F1pCMH0Lg03Uv2evsVQY2W2qz/XJg7Z+SplprJe9oBhcSzWowsuFzRnaD6Nav0usRg j6keLppQqCzCAZnsoKgihu97++4k6/PXgDDlapctZM947l1jCAuHmx58LPdlf7lsSfwX fQ== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hftvr9f8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Jul 2022 12:07:05 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26MBr9xZ010882; Fri, 22 Jul 2022 12:07:03 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 3hbmkj885a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Jul 2022 12:07:03 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26MC70SL23790004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jul 2022 12:07:00 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7582242049; Fri, 22 Jul 2022 12:07:00 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8AE442041; Fri, 22 Jul 2022 12:06:59 +0000 (GMT) Received: from osiris (unknown [9.145.178.215]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 22 Jul 2022 12:06:59 +0000 (GMT) Date: Fri, 22 Jul 2022 14:06:58 +0200 From: Heiko Carstens To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, x86@kernel.org, Will Deacon , Alexander Gordeev , Thomas Gleixner , "H . Peter Anvin" , Catalin Marinas , Borislav Petkov , Johannes Berg , Mark Rutland , Harald Freudenberger , Michael Ellerman , Holger Dengler Subject: Re: [PATCH v3] random: handle archrandom with multiple longs Message-ID: References: <20220719130207.147536-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220719130207.147536-1-Jason@zx2c4.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: BYpjYolDJC7Jn9NzSuNRht8fsbIWP_U- X-Proofpoint-ORIG-GUID: BYpjYolDJC7Jn9NzSuNRht8fsbIWP_U- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-22_03,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 clxscore=1011 malwarescore=0 impostorscore=0 priorityscore=1501 mlxlogscore=571 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207220051 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220722_050721_307628_CB2DAFA0 X-CRM114-Status: GOOD ( 26.10 ) 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 On Tue, Jul 19, 2022 at 03:02:07PM +0200, Jason A. Donenfeld wrote: > 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 longs. On > s390, the CPACF TRNG interface can return arbitrary amounts, with 32 > longs having the same cost as one. On UML, the os_getrandom() interface > can return arbitrary amounts. > > So change the api signature to take a "max_longs" parameter designating > the maximum number of longs requested, and then return the number of > longs generated. > > Since callers need to check this return value and loop anyway, each arch > implementation does not bother implementing its own loop to try again to > fill the maximum number of longs. Additionally, all existing callers > pass in a constant max_longs parameter. Taken together, these two things > mean that the codegen doesn't really change much for one-word-at-a-time > platforms, while performance is greatly improved on platforms such as > s390. > > Cc: Will Deacon > Cc: Alexander Gordeev > Cc: Thomas Gleixner > Cc: H. Peter Anvin > Cc: Catalin Marinas > Cc: Borislav Petkov > Cc: Heiko Carstens > Cc: Johannes Berg > Cc: Mark Rutland > Cc: Harald Freudenberger > Acked-by: Michael Ellerman > Signed-off-by: Jason A. Donenfeld > --- > arch/arm64/include/asm/archrandom.h | 102 ++++++++++++-------------- > arch/arm64/kernel/kaslr.c | 2 +- > arch/powerpc/include/asm/archrandom.h | 30 ++------ > arch/powerpc/kvm/book3s_hv.c | 2 +- > arch/s390/include/asm/archrandom.h | 29 ++------ > arch/um/include/asm/archrandom.h | 21 ++---- > arch/x86/include/asm/archrandom.h | 41 +---------- > arch/x86/kernel/espfix_64.c | 2 +- > drivers/char/random.c | 45 ++++++++---- > include/asm-generic/archrandom.h | 18 +---- > include/linux/random.h | 12 +-- > 11 files changed, 116 insertions(+), 188 deletions(-) For s390: Acked-by: Heiko Carstens _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel