Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1448372imw; Tue, 5 Jul 2022 09:36:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1umJpMpdBLYC/4D+hoFjMdwViCKpwc5+nXjF17bJ/8wiSY3TLPuvO+htAyHLF0IodHSB6vm X-Received: by 2002:a05:6402:1659:b0:43a:1735:e1ce with SMTP id s25-20020a056402165900b0043a1735e1cemr20982022edx.196.1657039013827; Tue, 05 Jul 2022 09:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657039013; cv=none; d=google.com; s=arc-20160816; b=ZLJSh0osxXMUHTMlm7dTbkYL+EuSlOLhf+5VgyMRSmjUhgGBhVyT9Kpxjg57+QnAA1 tkt5lLY4rfIvVsKaKksEfnkiOVS0DgUVK7U3aHipDNCHwf6v02oClN/LUan86AHvGKpB QvxIaSAcSLUZzf7m/3jGQKeXSAfex7OC+pERtapHs/nOiywQq4m7yk/8mDg+wVTIZRjp yJphXEz+yFhpn8CXuMFAcbrLVz3lrPLlHbxinESLF5WU1+6CyCCZqxnsfw+6E/LtzozY 1cUMYmQ+L5fULyQaCLW54EGa51rgRS9JXoF0CQOwwics0QzfyowNkOXPDWLsciYCMX01 NSGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LxFVUUohYoI+YzKE4WruBWc0PMGA7Ua1ICVm9wDLh1s=; b=txA6ijaNKlXmNLHEXNYzoYppkiOcHcQZXQmlfX+/UHdmuXsup/Y9xBPoB0ZY2EGc1W yjZB9lzvgJ/PhAbCvvk8odGPP54Ly/GeNsrR0PYw3L/TJiEZbFIhB6yDktIP3fpjql97 PFK8nsmN+pSs+ajCAfcEffQT5ADzSwMXIBZKoVkJe0VTDcG5N5pQecfex+aWT7qNWlSm y4vd1R6V2ZA8WxvBblTtiWJ65TG7t00VFTbkmpndMoMUj0bx+Pxg/XlU5YUSb34hZrvh +oxPRr6qw4PN2MislAdhIvvZgcF1t7rYGyso17WdLSHYEmTPcLSXPpAYamE0bON4Ktjs jo4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b="L5fb/qCE"; 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=QUARANTINE sp=QUARANTINE 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 c4-20020a056402158400b0043a4f592ea8si8073312edv.199.2022.07.05.09.36.29; Tue, 05 Jul 2022 09:36:53 -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="L5fb/qCE"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbiGEQfs (ORCPT + 99 others); Tue, 5 Jul 2022 12:35:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbiGEQfr (ORCPT ); Tue, 5 Jul 2022 12:35:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05232B26; Tue, 5 Jul 2022 09:35:47 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9B48F61BD9; Tue, 5 Jul 2022 16:35:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F18B1C341C7; Tue, 5 Jul 2022 16:35:44 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="L5fb/qCE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1657038943; 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=LxFVUUohYoI+YzKE4WruBWc0PMGA7Ua1ICVm9wDLh1s=; b=L5fb/qCEG+OhfafI7Kj/Q3/B4+6xROzqf4otMv4EjSRGVoOhlJx7KmHTJXJmSCpLlhfjgY tr6nMUhYdv9yUr8ccgFIoS1I+N8e6YwcKpi9iXH9EbRp5H/INB4za1RaLyBLjkPox9euYu CGaZypkgPJxyoTy08LIdBtGqQC/jN1I= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id ef1ae2a8 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Tue, 5 Jul 2022 16:35:43 +0000 (UTC) Date: Tue, 5 Jul 2022 18:35:40 +0200 From: "Jason A. Donenfeld" To: Holger Dengler Cc: Harald Freudenberger , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Juergen Christ , linux-crypto@vger.kernel.org, linux-s390@vger.kernel.org Subject: Re: [PATCH v1 1/1] s390/arch_random: Buffer true random data Message-ID: References: <20220705112712.4433-1-dengler@linux.ibm.com> <20220705112712.4433-2-dengler@linux.ibm.com> <9a0561c0-68f7-b630-4440-3ca32bf28dc2@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 Hi Holger, On Tue, Jul 05, 2022 at 06:27:59PM +0200, Holger Dengler wrote: > I saw a few calls in interrupt context during my tracing, but I didn't > look to see which ones they were. Let me figure that out in the next > few days and provide more information on that. One thing to keep in mind is that it's used at boot time, when technically IRQs are turned off, so it appears like interrupt context depending on which way you squint. But boot time obviously isn't a problem. So be sure that's not the usage you're seeing. > For the moment, I would propose to drop the buffering but also return > false, if arch_random_get_seed_long() is called in interrupt context. As a last ditch, maybe that's best. Maybe... Do you know off hand how many cycles each call takes? > diff --git a/arch/s390/include/asm/archrandom.h b/arch/s390/include/asm/archrandom.h > index 2c6e1c6ecbe7..711357bdc464 100644 > --- a/arch/s390/include/asm/archrandom.h > +++ b/arch/s390/include/asm/archrandom.h > @@ -32,7 +32,8 @@ static inline bool __must_check arch_get_random_int(unsigned int *v) > > static inline bool __must_check arch_get_random_seed_long(unsigned long *v) > { > - if (static_branch_likely(&s390_arch_random_available)) { > + if (static_branch_likely(&s390_arch_random_available) && > + !in_interrupt()) { in_interrupt() is deprecated. You want in_hardirq() here. You'll also want to verify that this doesn't prevent random_init() from working. Jason