Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3718390pxv; Mon, 26 Jul 2021 10:09:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEZ2GMpR/Xg5yzZGaDmVRKapWJKwXQaXS5e2fNT4H+RDGCCM9K7AaC7ye1qt8G9yu0FW2e X-Received: by 2002:a05:600c:17d8:: with SMTP id y24mr13204460wmo.91.1627319349896; Mon, 26 Jul 2021 10:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319349; cv=none; d=google.com; s=arc-20160816; b=wNwxQ+K+Q9EW/pofAuaDvcJfTPTPscZpCJUniFyxndx19x6clD+As6sZgK9DFIxVQB yugJSvghwghL6BuHKjl9eQEIakJZL3qq63WTY9lYj3ZJPj6/mwznHJa4WOAqZqnRJ+7K 1q77S5NI2jqq5eKQhRolzpc7hgkxzUEzh4sjlAlCdRR9A7p63UftZMdqnv4AB5lwUYMv NkFZKw4FOtKlPpNdg235GwFdJis69c+PiiCUYdDrgADMpa3eX8PCzm8P0dtUmSL7r8rE Kd0cFsYo50/tUF5ECJ3tYbQ8bdBIdC38+e0E+IwCw330+alyjAxWvGXx+EPebNEQRbux gTDw== 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=2vHEWc6Tb3OS+C2YNf63BPvSRiUpNAYYmTfYs9tTMQA=; b=VqlPWP4MY/7MyCrGJX8uJtJEChVjYGc5/GNMjLSEZ60IsGSwznVax7vXPb2tVXJ+P0 8afdw5O8njtXn//gByKujgZuwwqFiPXoFlZD+K1tEB5gZlIRNuTa9MQn2u6NKkA8k0Bb rDiGxBdA4RuM/rA+ECy+m2XSYaJFW+o1NXQnLfzorZA7WZ9WBdTSpJU5+/yAWl/nNBWY YKjTm8owFk0M1W9kPjMyPGca8fzhbg8yplYf1LV+ThrrQnDBq1ESEiwnueieGwcnrbDn VMMtkgj6JA8S9qvmAF/BWguqsWFWSjWcxV2zIlgbp0GpddSTUhYSQ3bpB2bnxphXILic aZzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e2Ej5nAV; 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 r26si389641ejz.423.2021.07.26.10.08.42; Mon, 26 Jul 2021 10:09:09 -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=e2Ej5nAV; 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 S238813AbhGZPqn (ORCPT + 99 others); Mon, 26 Jul 2021 11:46:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:43124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237846AbhGZP3Z (ORCPT ); Mon, 26 Jul 2021 11:29:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51ED461042; Mon, 26 Jul 2021 16:08:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315734; bh=GHr51w815V5K43UucPOUv5I/mia81NkzcNJB3oHSkeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e2Ej5nAVA+RgbOEl6FvvU+3A5mkX3ARyqh92/m5+tp8RBRhOcIaZPqqLQ2ja866zx wzQekTVor3Tf9fKDE0UisJGj6TvyTiiCfFYV540ISLKnmPw4t2qXNT9X54KEQfwget xDY2QJ9kQ0YNb8i+bgp/5W2TP64yK/iiud5ZHzFE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Andrey Konovalov , Catalin Marinas , Vincenzo Frascino , Will Deacon , Sasha Levin Subject: [PATCH 5.13 046/223] arm64: mte: fix restoration of GCR_EL1 from suspend Date: Mon, 26 Jul 2021 17:37:18 +0200 Message-Id: <20210726153847.773328197@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@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: Mark Rutland [ Upstream commit 59f44069e0527523f27948da7b77599a73dab157 ] Since commit: bad1e1c663e0a72f ("arm64: mte: switch GCR_EL1 in kernel entry and exit") we saved/restored the user GCR_EL1 value at exception boundaries, and update_gcr_el1_excl() is no longer used for this. However it is used to restore the kernel's GCR_EL1 value when returning from a suspend state. Thus, the comment is misleading (and an ISB is necessary). When restoring the kernel's GCR value, we need an ISB to ensure this is used by subsequent instructions. We don't necessarily get an ISB by other means (e.g. if the kernel is built without support for pointer authentication). As __cpu_setup() initialised GCR_EL1.Exclude to 0xffff, until a context synchronization event, allocation tag 0 may be used rather than the desired set of tags. This patch drops the misleading comment, adds the missing ISB, and for clarity folds update_gcr_el1_excl() into its only user. Fixes: bad1e1c663e0 ("arm64: mte: switch GCR_EL1 in kernel entry and exit") Signed-off-by: Mark Rutland Cc: Andrey Konovalov Cc: Catalin Marinas Cc: Vincenzo Frascino Cc: Will Deacon Link: https://lore.kernel.org/r/20210714143843.56537-2-mark.rutland@arm.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/kernel/mte.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c index 125a10e413e9..23e9879a6e78 100644 --- a/arch/arm64/kernel/mte.c +++ b/arch/arm64/kernel/mte.c @@ -185,18 +185,6 @@ void mte_check_tfsr_el1(void) } #endif -static void update_gcr_el1_excl(u64 excl) -{ - - /* - * Note that the mask controlled by the user via prctl() is an - * include while GCR_EL1 accepts an exclude mask. - * No need for ISB since this only affects EL0 currently, implicit - * with ERET. - */ - sysreg_clear_set_s(SYS_GCR_EL1, SYS_GCR_EL1_EXCL_MASK, excl); -} - static void set_gcr_el1_excl(u64 excl) { current->thread.gcr_user_excl = excl; @@ -257,7 +245,8 @@ void mte_suspend_exit(void) if (!system_supports_mte()) return; - update_gcr_el1_excl(gcr_kernel_excl); + sysreg_clear_set_s(SYS_GCR_EL1, SYS_GCR_EL1_EXCL_MASK, gcr_kernel_excl); + isb(); } long set_mte_ctrl(struct task_struct *task, unsigned long arg) -- 2.30.2