Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp460676pxj; Tue, 18 May 2021 07:15:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9V1rVPLuke1CD/ca9gKFDXJqDcYqsUVUkK1j5Q4bshdICEyM7o0nAdjyAMe9wHHhP9j2R X-Received: by 2002:a17:906:7e55:: with SMTP id z21mr6391482ejr.225.1621347327462; Tue, 18 May 2021 07:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621347327; cv=none; d=google.com; s=arc-20160816; b=NERLVFID+Yy4gLxUMWsBFeEfUSM6+4DsbNGjl85cQ2uHClZJC7AZuP99PDeaXoLK12 57A7dVbr9ADtFeKmAYTdjbigNfCb8LcLUvWSHd7iTWoiUh7NgFyoRAwVVn9HYeENSQqH qNVRzULVFlUhfnsPe2tLRJSpeNCQgnaNapu1pLb6zPGWrFtDU6XqSG/qUitkGY7/woRU L51xY/Np9uQmihVS6W/LTYP7+8LJlERRKkeebne1rYfAFIMFXHY2ksOKPnZYqaw6hdV7 TbmAR6dnTVDKcr+pp+fK2oh6UD5z9zJk0zv6jHzblvZdpkQtQzCmbJdbPpoInzYgrNzn 5v+w== 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=Cd50PH8z4UYO929WINw4GAjyaz8fWTaIBRM25CaQfts=; b=fz71U889DAIRihIO2z6tVUshx4beUrhnbtV+1yMhxPXB3XoVLKxCWnsyYlOq2FI1Dx XExqtC6k8kC/2K8asIV+w2iBzYGGL1D1/FDWEpMEeMLJ8cWCGFTZxxUltY6m2HNEgbQ5 k0gD4XMF6p3xDQ0hZHdw5cn3ys84jUMdyC8KD+XXJKHTXA4xnSVmhjps7GrmGyPLXduc D8AZG9qxiC6nCR6sZKM3N8r3+Z2b0iNeHc7NuhRwJi6vdl8VM23mrIi5d1/pONGQeV7O UuIpHnIGb5boS7LEgEH+VYB3Zvd76U/Kv+DQjRJbOLszOIUiiRafItsW5w7xb9V0jnZM Ckkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gJ7X9Iu4; 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 q29si16127894edb.218.2021.05.18.07.15.04; Tue, 18 May 2021 07:15:27 -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=gJ7X9Iu4; 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 S243603AbhEQPn3 (ORCPT + 99 others); Mon, 17 May 2021 11:43:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:54302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244620AbhEQP2M (ORCPT ); Mon, 17 May 2021 11:28:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1BAA96192B; Mon, 17 May 2021 14:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262223; bh=CwzVLBOwKRg26UVtCessCg/6EUEGMoygoRyT+GpjEis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gJ7X9Iu4+uiXII/nDQRkg5x/MybbsNIjLQC0cgQ4mJ8QxGh4JLla5fS5JV7q9MHL3 HaX0/HrBk4BWQw/LV4k0H+5Qz3V54M4600MUSmM3W8WctHmAfQwLBvAFREeRjc3lFs xixiTm0a6QzuPlXWFiN3ROiAH1RnSQC50kiU29L0= 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.11 242/329] arm64: mte: initialize RGSR_EL1.SEED in __cpu_setup Date: Mon, 17 May 2021 16:02:33 +0200 Message-Id: <20210517140310.297246516@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.043055203@linuxfoundation.org> References: <20210517140302.043055203@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 @@ -454,6 +454,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