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.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 9C833C4741F for ; Thu, 5 Nov 2020 16:20:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1AFE3221FA for ; Thu, 5 Nov 2020 16:20:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AFE3221FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 68AED6B013F; Thu, 5 Nov 2020 11:19:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63BB56B0140; Thu, 5 Nov 2020 11:19:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52AC16B0141; Thu, 5 Nov 2020 11:19:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 2422E6B013F for ; Thu, 5 Nov 2020 11:19:59 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id AF46C181AC9CC for ; Thu, 5 Nov 2020 16:19:58 +0000 (UTC) X-FDA: 77450876076.18.space25_400b088272cb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 9F9A6100528DD for ; Thu, 5 Nov 2020 15:59:08 +0000 (UTC) X-HE-Tag: space25_400b088272cb X-Filterd-Recvd-Size: 3712 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 15:59:07 +0000 (UTC) Received: from gaia (unknown [2.26.170.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 637012087D; Thu, 5 Nov 2020 15:59:03 +0000 (UTC) Date: Thu, 5 Nov 2020 15:59:00 +0000 From: Catalin Marinas To: Andrey Konovalov Cc: Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 28/43] arm64: mte: Reset the page tag in page->flags Message-ID: <20201105155859.GA30030@gaia> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. > } > > 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. > } > 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); 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. -- Catalin