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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71F87C433B4 for ; Mon, 10 May 2021 15:31:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C4A8611BE for ; Mon, 10 May 2021 15:31:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233616AbhEJPdD (ORCPT ); Mon, 10 May 2021 11:33:03 -0400 Received: from foss.arm.com ([217.140.110.172]:32776 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234452AbhEJPcy (ORCPT ); Mon, 10 May 2021 11:32:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE7F91688; Mon, 10 May 2021 08:31:49 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.4.9]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7D013F719; Mon, 10 May 2021 08:31:47 -0700 (PDT) Date: Mon, 10 May 2021 16:31:44 +0100 From: Mark Rutland To: Peter Collingbourne Cc: Catalin Marinas , Vincenzo Frascino , Will Deacon , Evgenii Stepanov , Andrey Konovalov , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org Subject: Re: [PATCH v2] arm64: mte: initialize RGSR_EL1.SEED in __cpu_setup Message-ID: <20210510153144.GC92897@C02TD0UTHF1T.local> References: <20210507185905.1745402-1-pcc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210507185905.1745402-1-pcc@google.com> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Fri, May 07, 2021 at 11:59:05AM -0700, Peter Collingbourne wrote: > A valid implementation choice for the ChooseRandomNonExcludedTag() > pseudocode function used by IRG is to behave in the same way as with > GCR_EL1.RRND=0. This would mean that RGSR_EL1.SEED is used as an LFSR > which must have a non-zero value in order for IRG to properly produce > pseudorandom numbers. However, RGSR_EL1 is reset to an UNKNOWN value > on soft reset and thus may reset to 0. Therefore we must initialize > RGSR_EL1.SEED to a non-zero value in order to ensure that IRG behaves > as expected. > > Signed-off-by: Peter Collingbourne > Fixes: 3b714d24ef17 ("arm64: mte: CPU feature detection and initial sysreg configuration") > Cc: # 5.10 > Link: https://linux-review.googlesource.com/id/I2b089b6c7d6f17ee37e2f0db7df5ad5bcc04526c FWIW: Acked-by: Mark Rutland Mark. > --- > arch/arm64/mm/proc.S | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S > index 0a48191534ff..97d7bcd8d4f2 100644 > --- a/arch/arm64/mm/proc.S > +++ b/arch/arm64/mm/proc.S > @@ -447,6 +447,18 @@ SYM_FUNC_START(__cpu_setup) > mov x10, #(SYS_GCR_EL1_RRND | SYS_GCR_EL1_EXCL_MASK) > msr_s SYS_GCR_EL1, x10 > > + /* > + * If GCR_EL1.RRND=1 is implemented the same way as RRND=0, then > + * RGSR_EL1.SEED must be non-zero for IRG to produce > + * pseudorandom numbers. As RGSR_EL1 is UNKNOWN out of reset, we > + * must initialize it. > + */ > + mrs x10, CNTVCT_EL0 > + ands x10, x10, #SYS_RGSR_EL1_SEED_MASK > + csinc x10, x10, xzr, ne > + lsl x10, x10, #SYS_RGSR_EL1_SEED_SHIFT > + msr_s SYS_RGSR_EL1, x10 > + > /* clear any pending tag check faults in TFSR*_EL1 */ > msr_s SYS_TFSR_EL1, xzr > msr_s SYS_TFSRE0_EL1, xzr > -- > 2.31.1.607.g51e8a6a459-goog > 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 X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B78FC433ED for ; Mon, 10 May 2021 15:33:35 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48BE861108 for ; Mon, 10 May 2021 15:33:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48BE861108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=Txzo6W3DkPnCtei19jQWfjchXbAw1zBzTC1ygIBY3Go=; b=gmgXeppxcJTcCMOFAOiPN5acM u9WBoa3EadXGTtLcnnoAfSNcSHSmk6sGmDm/OHxLDRTzeERyV5h46yZZSlTMpoLWv6bj8Rxi9QABy 0286ep3/Ajz8WLDdX/VsfPWbSjkfuNQ5Py0TwJ/ktj79d5E9mGXURh0oLHPVqamZDybtQAgHVlDpx XzC67vFwUXJQiL89FU8uTzzSIwhJBG0AIjqDyGVZKzmq1rNyFkBIwnQwYg8CjTE4OtwFImx/eF2TS tCM5iFoX1EICfh5DJy/cvoyrF75gZ6dyR7walwPbHPFPEap4XdTufb7QV12kJxapJYTJq8Rfocgh/ FMN+2uXug==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lg7t2-00Emrc-2n; Mon, 10 May 2021 15:32:00 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lg7sy-00Emqk-OX for linux-arm-kernel@desiato.infradead.org; Mon, 10 May 2021 15:31:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=io2pk5bgfUovESXvgK4HBHiDr8hmFODqlDgA0PqLmpk=; b=0v7aN5pQphUAKTSARLgFAuBu9P mAiB8FHLhSjlJcPTDxMugUFkLEZ06bryxNhACJLWmsGEgjE5yCj0mykG5sidvlPGUvq1FxbZ+shRN 6lDfel/1fVxfqqL0XVsw/nrmjw+3Hjmh0b349QonZ4J9Wia+pGKefY8SXgr5p64ZqLj22cTQFn7Dv 3tAG68JGyZMTCfdvmOqigDDt2Y5xI0dWPkYS2g6bD2zgJl1crti4SX1oAf6E03cq8cDKNDwUKsB9d f85bFTiS/RD+ANZkDYxouUWnsO5uIABq/LbUd51ZKo8qvhY5AROBF+R7X3GoyWj499jHDrhBiWwjq O41e+/nA==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lg7sv-008sAZ-QD for linux-arm-kernel@lists.infradead.org; Mon, 10 May 2021 15:31:55 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE7F91688; Mon, 10 May 2021 08:31:49 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.4.9]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7D013F719; Mon, 10 May 2021 08:31:47 -0700 (PDT) Date: Mon, 10 May 2021 16:31:44 +0100 From: Mark Rutland To: Peter Collingbourne Cc: Catalin Marinas , Vincenzo Frascino , Will Deacon , Evgenii Stepanov , Andrey Konovalov , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org Subject: Re: [PATCH v2] arm64: mte: initialize RGSR_EL1.SEED in __cpu_setup Message-ID: <20210510153144.GC92897@C02TD0UTHF1T.local> References: <20210507185905.1745402-1-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210507185905.1745402-1-pcc@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_083153_917793_43C5180C X-CRM114-Status: GOOD ( 18.64 ) 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 Fri, May 07, 2021 at 11:59:05AM -0700, Peter Collingbourne wrote: > A valid implementation choice for the ChooseRandomNonExcludedTag() > pseudocode function used by IRG is to behave in the same way as with > GCR_EL1.RRND=0. This would mean that RGSR_EL1.SEED is used as an LFSR > which must have a non-zero value in order for IRG to properly produce > pseudorandom numbers. However, RGSR_EL1 is reset to an UNKNOWN value > on soft reset and thus may reset to 0. Therefore we must initialize > RGSR_EL1.SEED to a non-zero value in order to ensure that IRG behaves > as expected. > > Signed-off-by: Peter Collingbourne > Fixes: 3b714d24ef17 ("arm64: mte: CPU feature detection and initial sysreg configuration") > Cc: # 5.10 > Link: https://linux-review.googlesource.com/id/I2b089b6c7d6f17ee37e2f0db7df5ad5bcc04526c FWIW: Acked-by: Mark Rutland Mark. > --- > arch/arm64/mm/proc.S | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S > index 0a48191534ff..97d7bcd8d4f2 100644 > --- a/arch/arm64/mm/proc.S > +++ b/arch/arm64/mm/proc.S > @@ -447,6 +447,18 @@ SYM_FUNC_START(__cpu_setup) > mov x10, #(SYS_GCR_EL1_RRND | SYS_GCR_EL1_EXCL_MASK) > msr_s SYS_GCR_EL1, x10 > > + /* > + * If GCR_EL1.RRND=1 is implemented the same way as RRND=0, then > + * RGSR_EL1.SEED must be non-zero for IRG to produce > + * pseudorandom numbers. As RGSR_EL1 is UNKNOWN out of reset, we > + * must initialize it. > + */ > + mrs x10, CNTVCT_EL0 > + ands x10, x10, #SYS_RGSR_EL1_SEED_MASK > + csinc x10, x10, xzr, ne > + lsl x10, x10, #SYS_RGSR_EL1_SEED_SHIFT > + msr_s SYS_RGSR_EL1, x10 > + > /* clear any pending tag check faults in TFSR*_EL1 */ > msr_s SYS_TFSR_EL1, xzr > msr_s SYS_TFSRE0_EL1, xzr > -- > 2.31.1.607.g51e8a6a459-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel