From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF7B2C433DB for ; Fri, 12 Mar 2021 15:14:27 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6393364DBA for ; Fri, 12 Mar 2021 15:14:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6393364DBA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=XZUvAZfyoVpMfD9AdAGWZ/HAbD7VpcHMUMrKTFqy6SM=; b=bdybx49Ophj5dcCtEJEZLuxhX RXNI19REzD/T3Lql0IBNQvUhR+7FHgrkf7I9qPmgtBaLbQsQ6qo2j0isJ5rjhp8df5uchjypd+fjZ y00E+dmGiB/Xbub3uubOroPwWnjgXOZiejVk8E4d3TLD08c3oSpcHRd5dkhXzfTsvHGjNXBXqRB7D 0IMzIEAk3mIpRV5GYiTYMT6YCI7hl3t42i/8yXed1iD8bFaP0u8JFdVWXTkLAqxwUOimIeEeJj7wS yVlWJCPYrpdj56GLQOkZgogHzras+dg4yhHKY2NpFHpc+x1GNWYYTd0c7PJ0LYJ+vVRgBskA9jdwM 2lb2rF4NQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKjTV-00BkXY-Ap; Fri, 12 Mar 2021 15:13:13 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKjTO-00BkWP-MH for linux-arm-kernel@lists.infradead.org; Fri, 12 Mar 2021 15:13:09 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id A5C7964FD9; Fri, 12 Mar 2021 15:13:02 +0000 (UTC) Date: Fri, 12 Mar 2021 15:13:00 +0000 From: Catalin Marinas To: Vincenzo Frascino Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Andrew Morton , Will Deacon , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Andrey Konovalov , Lorenzo Pieralisi Subject: Re: [PATCH v15 5/8] arm64: mte: Enable TCO in functions that can read beyond buffer limits Message-ID: <20210312151259.GB24210@arm.com> References: <20210312142210.21326-1-vincenzo.frascino@arm.com> <20210312142210.21326-6-vincenzo.frascino@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210312142210.21326-6-vincenzo.frascino@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_151307_152746_FE72561C X-CRM114-Status: GOOD ( 13.29 ) 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 On Fri, Mar 12, 2021 at 02:22:07PM +0000, Vincenzo Frascino wrote: > diff --git a/arch/arm64/include/asm/mte.h b/arch/arm64/include/asm/mte.h > index 9b557a457f24..8603c6636a7d 100644 > --- a/arch/arm64/include/asm/mte.h > +++ b/arch/arm64/include/asm/mte.h > @@ -90,5 +90,20 @@ static inline void mte_assign_mem_tag_range(void *addr, size_t size) > > #endif /* CONFIG_ARM64_MTE */ > > +#ifdef CONFIG_KASAN_HW_TAGS > +/* Whether the MTE asynchronous mode is enabled. */ > +DECLARE_STATIC_KEY_FALSE(mte_async_mode); > + > +static inline bool system_uses_mte_async_mode(void) > +{ > + return static_branch_unlikely(&mte_async_mode); > +} > +#else > +static inline bool system_uses_mte_async_mode(void) > +{ > + return false; > +} > +#endif /* CONFIG_KASAN_HW_TAGS */ You can write this with fewer lines: DECLARE_STATIC_KEY_FALSE(mte_async_mode); static inline bool system_uses_mte_async_mode(void) { return IS_ENABLED(CONFIG_KASAN_HW_TAGS) && static_branch_unlikely(&mte_async_mode); } The compiler will ensure that mte_async_mode is not referred when !CONFIG_KASAN_HW_TAGS and therefore doesn't need to be defined. > diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c > index fa755cf94e01..9362928ba0d5 100644 > --- a/arch/arm64/kernel/mte.c > +++ b/arch/arm64/kernel/mte.c > @@ -26,6 +26,10 @@ u64 gcr_kernel_excl __ro_after_init; > > static bool report_fault_once = true; > > +/* Whether the MTE asynchronous mode is enabled. */ > +DEFINE_STATIC_KEY_FALSE(mte_async_mode); > +EXPORT_SYMBOL_GPL(mte_async_mode); Maybe keep these bracketed by #ifdef CONFIG_KASAN_HW_TAGS. I think the mte_enable_kernel_*() aren't needed either if KASAN_HW is disabled (you can do it with an additional patch). With these, you can add: Reviewed-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel