Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1412179pxf; Fri, 9 Apr 2021 07:49:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA1TffViH4EWkqKuRU9Qf4s9YmshNbJ1I1Zq+dAgjiCc+7yI0KO30v6e4ByWxG7UE8lQKC X-Received: by 2002:a17:90a:8815:: with SMTP id s21mr14004283pjn.200.1617979799164; Fri, 09 Apr 2021 07:49:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617979799; cv=none; d=google.com; s=arc-20160816; b=wGgrgHzME7RQBJSqGNLVQJRHu5Nl9jZqKu9uk+u/mfNvAns/Etqw9Zgfp+1fKU89hO 3I7m4b7MHixGvHDGmlNcFLF+nRj30dUEPqVoS8Om+nkCdmZmn0jw2VpKoeP8x0yA3eZQ dCVjIHVFlUCBS1wgx4ptQQkJMlTm1/K73NwfhCeS4LdbkInVnybAqpMLl62jiRn6oCAc e2KxvbxaDnTH9m2MfPlPiUsG61Ary7u1N/qbgkIeoeHDkmGUXJUPyVzgx9d3nCJhfs3J XNBkGzghS6Vmq9koHGP7OIyXWyn81CAJFkZaqpJkfnqJK4S8zUx956QDBtgQl7ypkAA2 sKkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=oRh416PNzI2PZEXFBtYAA+fhYGm9TwWVvbjFwk9VVBo=; b=GFowy58GilQNUQwMWUIfackXQocNkfgqTA42POCDq64/XRLOdgVhnIiHXp0AhumVAC cG+/HvDZjB2vBymRu5TcvmjqHNUgfn1bB5jiKP0SF8iPYxl6lB3m6clXSSZq67++cpxd c4T9YN24b+17djIIOsu1+hy+oSTm7sg09U2AEtSzP5tVXqVmEivc/JRc2ng3U2l3dtKO 0989+F1w3X+4YnSNf9ZNpwQMRewlrFn8zdGHT4+/B+N/wpEB0UPbKMI25QYdTvIRIkjc lktqyGloti3mR/q0Q+ZvOusWFS5/c1ftc2F1is9nAp9p0W1OqFwo1uMtFx6qO/Xk8hhS TboA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t13si1521078pfh.89.2021.04.09.07.49.45; Fri, 09 Apr 2021 07:49:59 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234006AbhDIOr4 (ORCPT + 99 others); Fri, 9 Apr 2021 10:47:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:43524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbhDIOrz (ORCPT ); Fri, 9 Apr 2021 10:47:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 895DD610D0; Fri, 9 Apr 2021 14:47:41 +0000 (UTC) Date: Fri, 9 Apr 2021 15:47:39 +0100 From: Catalin Marinas To: Vincenzo Frascino Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Will Deacon , stable@vger.kernel.org Subject: Re: [PATCH v3] arm64: mte: Move MTE TCF0 check in entry-common Message-ID: <20210409144738.GB24031@arm.com> References: <20210409132419.29965-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210409132419.29965-1-vincenzo.frascino@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 09, 2021 at 02:24:19PM +0100, Vincenzo Frascino wrote: > diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c > index b3c70a612c7a..84a942c25870 100644 > --- a/arch/arm64/kernel/mte.c > +++ b/arch/arm64/kernel/mte.c > @@ -166,14 +166,43 @@ static void set_gcr_el1_excl(u64 excl) > */ > } > > -void flush_mte_state(void) > +void noinstr check_mte_async_tcf0(void) Nitpick: it looks like naming isn't be entirely consistent with your kernel async patches: https://lore.kernel.org/linux-arm-kernel/20210315132019.33202-8-vincenzo.frascino@arm.com/ You could name them mte_check_tfsre0_el1() etc. Also make sure they are called in similar places in both series. > +{ > + u64 tcf0; > + > + if (!system_supports_mte()) > + return; > + > + /* > + * dsb(ish) is not required before the register read > + * because the TFSRE0_EL1 is automatically synchronized > + * by the hardware on exception entry as SCTLR_EL1.ITFSB > + * is set. > + */ > + tcf0 = read_sysreg_s(SYS_TFSRE0_EL1); > + > + if (tcf0 & SYS_TFSR_EL1_TF0) > + set_thread_flag(TIF_MTE_ASYNC_FAULT); > + > + write_sysreg_s(0, SYS_TFSRE0_EL1); Please move the write_sysreg() inside the 'if' block. If it was 0, there's no point in a potentially more expensive write. That said, we only check TFSRE0_EL1 on entry from EL0. Is there a point in clearing it before we return to EL0? Uaccess routines may set it anyway. > +} > + > +void noinstr clear_mte_async_tcf0(void) > { > if (!system_supports_mte()) > return; > > - /* clear any pending asynchronous tag fault */ > dsb(ish); > write_sysreg_s(0, SYS_TFSRE0_EL1); > +} I think Mark suggested on your first version that we should keep these functions in mte.h so that they can be inlined. They are small and only called in one or two places. -- Catalin