Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp565931pxj; Tue, 18 May 2021 09:22:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5TrcPoqgqFJQZwALUPN60yQc8z6UI/fkBGHrZakqgQtGpPMyEnE5hrMi+7pPcKrlZ/VGt X-Received: by 2002:a6b:f815:: with SMTP id o21mr4675530ioh.0.1621354920236; Tue, 18 May 2021 09:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621354920; cv=none; d=google.com; s=arc-20160816; b=jZr+A1P2EZcxYXqHV3AUCLyZ9j1h0lpMEf5lsmprT1czhVvvh7kQlozKqXkd6Mcbhy Q57QmGIuOTgSWxHuB8An2BJWpSA8hKwZUyqP5uAly4lAc57Mnf0jHjvlFFhXFxL9NH6G oOvq8jjg02b9NZpghLW6kkPixb4YwqzraS4QsnjbOUIBKqesH8ALPbESku9bBj1Q+u5b YceFagz0tCF2R3jwO+1LA9BOXOdNjmxK6IcMCU6Iq1l0JDVVaNqNdMyZBhx7Fehy0y8s bVYWedmoeA5QVLtvrnd/yAHMxS8y+MIPGiAcCfKkX8qZtAEYXkBTnRvY5j5oQGjK/r4J K4vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iSQYcjeVC8vBzwKlqE4i02DfUoHeydhLqPRyCWacqk8=; b=c2dmBK1ENo/aNojGnOvHicZO0BuERtyXKrNDCi/txy/iOpBViaYXTC1z/w7sKjat0J I4PLMnVthuYPLCzggzCJpiXsATdaMmDe0vtcF5LkPGfyiqWQ1b6naLH6bnCiAQsKwJsM IVbNoenshPlB+q4PgKxDz5wkSaMZ5aUgOeZFoj/Seuwa+x5xGZhf5Q6+u5M++qPgdLkX WHj2DZeVpGjzFsceNKjwyWNT/BlN/8FvG1z98CuzaBAb5uabiCySdA4nz2qpgR4to2HW uLeI6O7qWf/OzvcyUP/dES7Ge3udezgkETefcnQ1UFEhdSYhLPjImOJUsC8PIPFfxW20 b64g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IWFk8jwk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y19si12517706jap.30.2021.05.18.09.21.36; Tue, 18 May 2021 09:22:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IWFk8jwk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239391AbhEQQAz (ORCPT + 99 others); Mon, 17 May 2021 12:00:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:50648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243423AbhEQPlM (ORCPT ); Mon, 17 May 2021 11:41:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1711F61D0E; Mon, 17 May 2021 14:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262518; bh=DRdU950bFxrQzhdl2dct9MiKkUAcUctOWsGQgNIuahM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IWFk8jwkTAGWZV2seK6BePcZPp/Sm0xbGQfvzuxlXggPq59L2P5PwuL6y1K2wp4IS R3jZAPbGHm1S8YjEsdmf6k4n5HLDX1yPUWnuwrjuvYK7ILeDb3EZ53Qq7C4vWN9x8W RiNQP+ooEhI+psqLnMkFpMUNtmsGqML+I2Nt/O5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Collingbourne , Mark Rutland , Catalin Marinas Subject: [PATCH 5.10 205/289] arm64: mte: initialize RGSR_EL1.SEED in __cpu_setup Date: Mon, 17 May 2021 16:02:10 +0200 Message-Id: <20210517140312.014073830@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Collingbourne commit 37a8024d265564eba680575df6421f19db21dfce upstream. 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 Acked-by: Mark Rutland Link: https://lore.kernel.org/r/20210507185905.1745402-1-pcc@google.com Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/proc.S | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -444,6 +444,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