From patchwork Mon Jul 26 15:37:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 485842 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp3976676jao; Mon, 26 Jul 2021 09:14:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2x9ApBb18VOY0mTk4RP6kz/PIHJPe7qfc9WuuWVE8DEmoiarRottckHx+kj9mr4UD9L0g X-Received: by 2002:a17:906:3616:: with SMTP id q22mr17278430ejb.276.1627316050348; Mon, 26 Jul 2021 09:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627316050; cv=none; d=google.com; s=arc-20160816; b=I0UpF7duoPmwzNDcnYrPZMGGyZ1mKxcY/Wl6e86iyrdoGEMKT/3QmC0vGKFU+j3R2k T+WCvh1GqvHcAnsFsIZ89Yspk89JXto0anUoV3hsL1RYlIOx4r86De4aEUcqvcY6bb1D +/zU73h18JNfhafASGUmrd3yBy+r7J1Y86+GZ4fzWSR+r+BZYv5uaWgd4fnjolYGFD96 ar/crfU84UzL02+zUti2IXzoFbxRNfA8F+gNgdePlVFOn1QRXQZ4QaEL0mDehRsf3ov8 E7vqiq1//PZJKk15ELAtwmxjre+s7PCmPKVImaL88l9Y10MplPBzbCN18tUyt3dX9ttK BPuQ== 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=0dscql1ym/Oi37wo+gZY50jK+8d1ZhYMc9bIVbvSXSJfOnNT1Qlp8jSGOCBzKOXak0 rOdmTze1NywzwqBLo28dQOV9R/cTD1QZM7floEcZ8/Allcz/YBrtQKpJcEgbTsnf/yr8 XLXJ/7Y61O/Nlg42bbBJCmVjImvpZps7QNLywoF+j76xcVoa70Iuk8w0a4Ds6upStPj3 RRyaaG3Fj4glSvR+nsnz1txf4de3VOzsArJib2z6ZCLagLyeD3v9qqI+ajA6tRaMIKiv O6DEf20VocgyT9inr9NhViA+UFU4E50R7UeHb85Xc1ieou11ENTS0h0ZaIcUgUleRYzk Ul9g== 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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 pv18si289902ejb.567.2021.07.26.09.14.09; Mon, 26 Jul 2021 09:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S231248AbhGZPa7 (ORCPT + 12 others); Mon, 26 Jul 2021 11:30:59 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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(-) -- 2.30.2 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)