Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09BC0C25B76 for ; Tue, 11 Jun 2024 10:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1C4Y3AqPn+QOZE27UEnWLkUYMxh2d8snfUrHbJanPU8=; b=m3fWzt7qiwSPm6 eOqaQQugmvj3PBiQA0A/FvCOW92LQe4VouUu7ayWenhLF+hnhdYDPcnMAZVQ5OXcd0jRgA1O1OUOG /J8BD967+Nk83tLQeOgTTtz0SNrIunoqZZgGH+e9ZEFTmoG8nFuvkzfHwYfD7I42XBi0oKppVQata f9TinQzOKbfUJv4qJ9S5MAmPF/vPL7XSfAboc7VI1eM94MJF8bcN5uz/RDga0KIuTwBZLSVtV58OV NoAYIdHtOpL82JdwqjVZpeNqkHsKMD07u2yMHpMkO/sg3CsI0hqTdSnUVXkNUGkP45VbcYaq30OTJ P2JbRb5pBQRIEftBE6YA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGyx6-00000008Tnk-1P1D; Tue, 11 Jun 2024 10:42:08 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGyx3-00000008Tmk-1zOY for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2024 10:42:06 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 284E01424; Tue, 11 Jun 2024 03:42:26 -0700 (PDT) Received: from arm.com (e121798.cambridge.arm.com [10.1.197.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DCBCD3F5A1; Tue, 11 Jun 2024 03:42:00 -0700 (PDT) Date: Tue, 11 Jun 2024 11:41:58 +0100 From: Alexandru Elisei To: Peter Collingbourne Cc: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Evgenii Stepanov Subject: Re: [PATCH] arm64: mte: Make mte_check_tfsr_*() conditional on KASAN instead of MTE Message-ID: References: <20240528225131.3577704-1-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240528225131.3577704-1-pcc@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240611_034205_606564_7215A9AA X-CRM114-Status: GOOD ( 22.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Tue, May 28, 2024 at 03:51:30PM -0700, Peter Collingbourne wrote: > The check in mte_check_tfsr_el1() is only necessary if HW tag > based KASAN is enabled. However, we were also executing the check > if MTE is enabled and KASAN is enabled at build time but disabled > at runtime. This turned out to cause a measurable increase in > power consumption on a specific microarchitecture after enabling > MTE. Moreover, on the same system, an increase in invalid syscall > latency (as measured by [1]) of around 20-30% (depending on the > cluster) was observed after enabling MTE; this almost entirely goes > away after removing this check. Therefore, make the check conditional > on whether KASAN is enabled rather than on whether MTE is enabled. > > [1] https://lore.kernel.org/all/CAMn1gO4MwRV8bmFJ_SeY5tsYNPn2ZP56LjAhafygjFaKuu5ouw@mail.gmail.com/ > > Signed-off-by: Peter Collingbourne > Link: https://linux-review.googlesource.com/id/I22d98d1483dd400a95595946552b769a5a1ad7bd > --- > arch/arm64/include/asm/mte.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/mte.h b/arch/arm64/include/asm/mte.h > index 91fbd5c8a3911..0f84518632b4a 100644 > --- a/arch/arm64/include/asm/mte.h > +++ b/arch/arm64/include/asm/mte.h > @@ -182,7 +182,7 @@ void mte_check_tfsr_el1(void); > > static inline void mte_check_tfsr_entry(void) > { > - if (!system_supports_mte()) > + if (!kasan_hw_tags_enabled()) > return; > > mte_check_tfsr_el1(); > @@ -190,7 +190,7 @@ static inline void mte_check_tfsr_entry(void) > > static inline void mte_check_tfsr_exit(void) > { > - if (!system_supports_mte()) > + if (!kasan_hw_tags_enabled()) > return; The change looks correct to me - tag check faults for the kernel are enabled only when hw kasan is enabled. The functions are already compiled only when CONFIG_KASAN_HW_TAGS=y, so it makes sense to further restrict them based on kasan_hw_tags_enabled(): Reviewed-by: Alexandru Elisei Can't speak for the performance results, altough skipping the dsb + isb on the exit path sure looks nice. Thanks, Alex > > /* > -- > 2.45.1.288.g0e0cd299f1-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel