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=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 081C7C433DB for ; Fri, 12 Feb 2021 17:22:36 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 AC48464E56 for ; Fri, 12 Feb 2021 17:22:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC48464E56 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=jsmKibe6gEkBCgbjQgHQCJU8eWvApMrTX8xJGJPiRjs=; b=ffm/yLoHjpuaMpa7udNft5TRO 3do1b5XbSYVaWzXRHgD0N/PaYCuFjis2SI1IlzT1JmnLjyvkUy8AUvLu3bUaNtpmQlnA7x7i58TgT NTndyBZUzqbSopTlRJNUmz4cfCxQPf6WEhHaMhhNCcd/J1c3ynV6i1lPHjdyJuOlsoogZTcEtkxnF GrG+JPxCI6aifP5332Um2gD/1C+M2rvfQPWIXMAH6QSrgzdngjOm5HQ+sgcnhfJgJggcOIFOV/Gwu mSPL8gIeB0rTYN4/Qud+34YlQia2ReHAYl11LLRd1cFsaTDG2b1P6JlNb1w7pAvRht6KmvAUVx4Fd VlLAqarDg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lAc8P-0007Ya-2A; Fri, 12 Feb 2021 17:21:37 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lAc8M-0007Xl-Ff for linux-arm-kernel@lists.infradead.org; Fri, 12 Feb 2021 17:21:35 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 34C1964E42; Fri, 12 Feb 2021 17:21:31 +0000 (UTC) Date: Fri, 12 Feb 2021 17:21:28 +0000 From: Catalin Marinas To: Vincenzo Frascino Subject: Re: [PATCH v13 4/7] arm64: mte: Enable TCO in functions that can read beyond buffer limits Message-ID: <20210212172128.GE7718@arm.com> References: <20210211153353.29094-1-vincenzo.frascino@arm.com> <20210211153353.29094-5-vincenzo.frascino@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210211153353.29094-5-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-20210212_122134_710287_CBFFD8D0 X-CRM114-Status: GOOD ( 18.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Branislav Rankov , Marco Elver , Lorenzo Pieralisi , Andrey Konovalov , Evgenii Stepanov , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Alexander Potapenko , linux-arm-kernel@lists.infradead.org, Andrey Ryabinin , Andrew Morton , Will Deacon , Dmitry Vyukov 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 Thu, Feb 11, 2021 at 03:33:50PM +0000, Vincenzo Frascino wrote: > diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c > index 706b7ab75f31..65ecb86dd886 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); > + > static void mte_sync_page_tags(struct page *page, pte_t *ptep, bool check_swap) > { > pte_t old_pte = READ_ONCE(*ptep); > @@ -119,12 +123,24 @@ static inline void __mte_enable_kernel(const char *mode, unsigned long tcf) > void mte_enable_kernel_sync(void) > { > __mte_enable_kernel("synchronous", SCTLR_ELx_TCF_SYNC); > + > + /* > + * This function is called on each active smp core at boot > + * time, hence we do not need to take cpu_hotplug_lock again. > + */ > + static_branch_disable_cpuslocked(&mte_async_mode); > } > EXPORT_SYMBOL_GPL(mte_enable_kernel_sync); > > void mte_enable_kernel_async(void) > { > __mte_enable_kernel("asynchronous", SCTLR_ELx_TCF_ASYNC); > + > + /* > + * This function is called on each active smp core at boot > + * time, hence we do not need to take cpu_hotplug_lock again. > + */ > + static_branch_enable_cpuslocked(&mte_async_mode); > } Sorry, I missed the cpuslocked aspect before. Is there any reason you need to use this API here? I suggested to add it to the mte_enable_kernel_sync() because kasan may at some point do this dynamically at run-time, so the boot-time argument doesn't hold. But it's also incorrect as this function will be called for hot-plugged CPUs as well after boot. The only reason for static_branch_*_cpuslocked() is if it's called from a region that already invoked cpus_read_lock() which I don't think is the case here. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel