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=-8.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 BCC82C2D0A3 for ; Fri, 6 Nov 2020 11:43:59 +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 40622206DB for ; Fri, 6 Nov 2020 11:43:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zUfmcxQ2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40622206DB 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:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hQok5/cpCbzPOOLUjRHkUEbMSzXMt+ni59aLZxiP+1A=; b=zUfmcxQ2b7RhBl/qmutfV6oHq GFcpzcuqyiun1ndcoJkfFd+M3K8C3We5FrLdvHegOtjdh900cG2J0z86c1BILsxjpJhhukq7EHIfS vjeFptwVr7+Ew5CGMkd+/WyaWVtw7qAnPByB7H86a+FzE1wvpqspFgRg0XQJnyMZC9l5ueqalNKeJ UGYwSgwryOzAICNsmaBYxOFefoCC8OJ/k1Ovdg5J03FAdOneqmcuCeYJ71zpkedszNrvRZz3Dr/DD YY6BqJljbOF0/8hGvmH04O9Nx+zLiw8IRA1ChCRAGMol9eFjNdNSYuv5qc4gQMVoqw5WeTnV4J7Ek MNBI7AkOQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb09L-00052O-Ss; Fri, 06 Nov 2020 11:43:23 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb09I-00051a-N8 for linux-arm-kernel@lists.infradead.org; Fri, 06 Nov 2020 11:43:21 +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 B9E07147A; Fri, 6 Nov 2020 03:43:16 -0800 (PST) Received: from [10.37.12.46] (unknown [10.37.12.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 565C13F719; Fri, 6 Nov 2020 03:43:14 -0800 (PST) Subject: Re: [PATCH v8 28/43] arm64: mte: Reset the page tag in page->flags To: Catalin Marinas , Andrey Konovalov References: <20201105155859.GA30030@gaia> From: Vincenzo Frascino Message-ID: <01a55e00-0d82-7e62-cc40-c282149dbb08@arm.com> Date: Fri, 6 Nov 2020 11:46:15 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201105155859.GA30030@gaia> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201106_064320_854797_3CBB53DB X-CRM114-Status: GOOD ( 23.16 ) 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: linux-arm-kernel@lists.infradead.org, Marco Elver , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , Andrew Morton , Evgenii Stepanov 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 Catalin, On 11/5/20 3:59 PM, Catalin Marinas wrote: > On Thu, Nov 05, 2020 at 12:18:43AM +0100, Andrey Konovalov wrote: >> diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c >> index 8f99c65837fd..06ba6c923ab7 100644 >> --- a/arch/arm64/kernel/mte.c >> +++ b/arch/arm64/kernel/mte.c >> @@ -34,6 +34,7 @@ static void mte_sync_page_tags(struct page *page, pte_t *ptep, bool check_swap) >> return; >> } >> >> + page_kasan_tag_reset(page); >> mte_clear_page_tags(page_address(page)); > > I think we need an smp_wmb() between setting the flags and clearing the > actual tags. If another threads reads page->flags and builds a tagged > address out of it (see page_to_virt) there's an address dependency to > the actual memory access. However, on the current thread, we don't > guarantee that the new page->flags are visible before the tags were > updated. > Indeed, and I will add a comment as well to explain why. >> } >> >> diff --git a/arch/arm64/mm/copypage.c b/arch/arm64/mm/copypage.c >> index 70a71f38b6a9..348f4627da08 100644 >> --- a/arch/arm64/mm/copypage.c >> +++ b/arch/arm64/mm/copypage.c >> @@ -22,6 +22,7 @@ void copy_highpage(struct page *to, struct page *from) >> copy_page(kto, kfrom); >> >> if (system_supports_mte() && test_bit(PG_mte_tagged, &from->flags)) { >> + page_kasan_tag_reset(to); >> set_bit(PG_mte_tagged, &to->flags); >> mte_copy_page_tags(kto, kfrom); > > Nitpick: move page_kasan_tag_reset() just above mte_copy_page_tags() for > consistency with the other places where PG_mte_tagged is set before or > after the actual tag setting. > Fine, I will add it to the next iteration. >> } >> diff --git a/arch/arm64/mm/mteswap.c b/arch/arm64/mm/mteswap.c >> index c52c1847079c..0e7eccbe598a 100644 >> --- a/arch/arm64/mm/mteswap.c >> +++ b/arch/arm64/mm/mteswap.c >> @@ -53,6 +53,7 @@ bool mte_restore_tags(swp_entry_t entry, struct page *page) >> if (!tags) >> return false; >> >> + page_kasan_tag_reset(page); >> mte_restore_page_tags(page_address(page), tags); I just realized based on your comment above that we need smp_wmb() here as well. I will add it with a comment as well. > > There is another mte_restore_page_tags() caller in hibernate.c. That one > doesn't need page_kasan_tag_reset() since the page->flags would have > been already restored but please add a comment in that file why its not > needed. > Yes I will do, I agree on the reasoning, I will report it in the comments. -- Regards, Vincenzo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel