Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3130814pxj; Mon, 17 May 2021 18:35:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1FqS+Ex0iZ0YZc3DZDGVSKG73Db87KB6lxWSfazjTwdrJJ1CbMVnHqkxJ4coEFqKxt6yV X-Received: by 2002:a02:8787:: with SMTP id t7mr2860130jai.53.1621301745794; Mon, 17 May 2021 18:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621301745; cv=none; d=google.com; s=arc-20160816; b=EOfqZLubVCfLekVBqaEbiVJfOA21Of+OvV21KoeBvgxCZtzCJd9sfmQ43gq3dFZ9f8 iLpCtwxuOSIZT1myAyPnuIBrz+I0+Tc1RRMax4yEDP0FE6ML+49lqo7NdyFciiUF+WDn PtDGPzKi2mcSDnf95zgdUKY9uCTgAiH3S54+RAFaaLD95Ms+Inf9zdnck0nobTYcoPkp 6sxnOhuAxFS5xTktw766Vm/rPf/XMLFhUl9SPmkbYyG3SeBfxgBaiWRszjo9N0aGG7PE tXSACt8b1FBlGUTwSWK5eMj1cknD/r8A8N/3eJagZWUxQVZ6+VkCkWKEnWpvQSspt/rV mZyA== 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=pVfR+ZGYgAgAkUMl9MdIh6xw1CMFYCbaNHDCqFM4aGmo/E7+f/KUg6X3qnoWHPoYAy hfOVZ8hIUasWIvZJK/HBD0or0LyLQYU4+KJ4EQ9X6cN/QS2hfXyuVlYglBduXuXn57WY t7QyoHyHtS8wJVN3gRWOsC1ODRVAS2Be26iJqdnuX364wOedYoKz8z5we14Q1+qOmVO4 1MPRcYStddNstrR7XI/EVueS3fRydO351nCvLgyifQBlqvWlWVQTwZC/ctVc7zRlXcBj mdE9Z2Id8Q3z0VjlvH9wXoprv4hdGLlT+1tEje0Hdrs9CKnM0n0BCe4+YGmutXxkQQ2F DOyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ONYjUsVu; 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 f12si9474466jas.31.2021.05.17.18.35.30; Mon, 17 May 2021 18:35:45 -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=ONYjUsVu; 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 S240605AbhEQOex (ORCPT + 99 others); Mon, 17 May 2021 10:34:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:43400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239965AbhEQO3m (ORCPT ); Mon, 17 May 2021 10:29:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 564B56162C; Mon, 17 May 2021 14:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260895; bh=DRdU950bFxrQzhdl2dct9MiKkUAcUctOWsGQgNIuahM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ONYjUsVu2rdo7Z0dILEqwOjYKTTWp1hskITH4T8lrCmns5XXGfTFCvq1DtnLMKzyO bWzUx4yAPiFd7mG1w4yZe2jRyXzmj5DoH33LwB/FEpTxIiKCNQi9+H13KkFNKVRFcs ldC2eQQHChF/WgtihfeAAEQG32zSI+BTrDDOsqjQ= 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.12 262/363] arm64: mte: initialize RGSR_EL1.SEED in __cpu_setup Date: Mon, 17 May 2021 16:02:08 +0200 Message-Id: <20210517140311.464948572@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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