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 3040EFA373D for ; Tue, 1 Nov 2022 11:47:09 +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=DmIjHzeK5PprDzpy2ZeRN9WZG2ztci8jRd0AVuauvgE=; b=tna+KBBIqujF+p 69xvurojbtY932vYss/1GrEL5o8xaT8ohRcuTdkIsc0Wo7xkJofWzdJfL7q/NNcb2Z/OE7NLkfwBN Ab7nMrTGpsRu0TCI+FamH1i7+QigOy1UYYFsoKffeWsbEQ56NZTuf3WU3T77jK8PGwilE3JqDeIK7 Yf3DobzrUIYvc0J4X/9xgTIhri2XQMkg/7fuOe4x0qIVmErsgavZkUfBJq+HuMK+OVTf9egbx75Pi nmeWH93dut7P5JnDr6rxLtHSsEBnHA5+ajPnuvC8A5nPiAVv/DcfOaeaX6B+096TTbxYr2sXqZNSg 6iE9jqDw5ahoYbRLEtYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oppiV-004kdQ-QM; Tue, 01 Nov 2022 11:46:03 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oppbz-004gqM-U8 for linux-arm-kernel@lists.infradead.org; Tue, 01 Nov 2022 11:39:21 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id BE9BCB81CC1; Tue, 1 Nov 2022 11:39:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BFA9C433D7; Tue, 1 Nov 2022 11:39:15 +0000 (UTC) Date: Tue, 1 Nov 2022 11:39:11 +0000 From: Catalin Marinas To: "Jason A. Donenfeld" Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Will Deacon , Ard Biesheuvel , Jean-Philippe Brucker Subject: Re: [PATCH v3] random: remove early archrandom abstraction Message-ID: References: <20221030212123.1022049-1-Jason@zx2c4.com> <20221031102840.85621-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221031102840.85621-1-Jason@zx2c4.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221101_043920_141493_3D9623A0 X-CRM114-Status: GOOD ( 19.85 ) 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 Mon, Oct 31, 2022 at 11:28:40AM +0100, Jason A. Donenfeld wrote: > Catalin - Though this touches arm64's archrandom.h, I intend to take > this through the random.git tree, if that's okay. I have other patches > that will build off of this one. -Jason I'm fine with the patch going through your tree but I have a comment below. > diff --git a/arch/arm64/include/asm/archrandom.h b/arch/arm64/include/asm/archrandom.h > index 109e2a4454be..4b0f28730ab2 100644 > --- a/arch/arm64/include/asm/archrandom.h > +++ b/arch/arm64/include/asm/archrandom.h > @@ -58,6 +58,20 @@ static inline bool __arm64_rndrrs(unsigned long *v) > return ok; > } > > +static inline bool __early_cpu_has_rndr(void) > +{ > + /* Open code as we run prior to the first call to cpufeature. */ > + unsigned long ftr = read_sysreg_s(SYS_ID_AA64ISAR0_EL1); > + return (ftr >> ID_AA64ISAR0_EL1_RNDR_SHIFT) & 0xf; > +} > + > +static __always_inline bool __cpu_has_rng(void) > +{ > + if (!system_capabilities_finalized() && early_boot_irqs_disabled) > + return __early_cpu_has_rndr(); > + return cpus_have_const_cap(ARM64_HAS_RNG); > +} I'm not sure about using early_boot_irqs_disabled, it is described as a debug helper. It's also set to 'false' before system_capabilities_finalized() (once the full SMP is enabled). Would something like this work: if (system_capabilities_finalized()) return cpus_have_final_cap(ARM64_HAS_RNG); if (!preemptible()) return __early_cpu_has_rndr(); return false; We also have a this_cpu_has_cap() function, though it's likely more expensive than the hand-coded __early_cpu_has_rndr() (if we care about performance here). -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel