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 8B995C433F5 for ; Tue, 17 May 2022 09:41:05 +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:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cIFnGe0639YwH1s175C1RXpUgJ/VHjBlMrqfGaJsauU=; b=ceQRGgBnxBkjLG +72OC+MgbTy+OdsbZXM2fuJH5y9zvdEVjZF15Z6SJEH2ccFYWmVex1nlYkfqTMTsFp91GIpFlcdC9 evqaV2uLvCLFTAHYpRA0xRHqBCZZF+8DpgGngxAyGFDt5toHL/ZRYmnCRXWD/AUZv1WFoSZQnxgz4 98fcTNdgHcOSD2FI//u65TRCaKjr4O7Blu0Qj8HurPPTBdvMQUcMhNi14bE6F4CrnQ2NjlIaabBYt qS8cxbreYkfkAxS8OTmUDfHJk9/Be5eDWTgE5QuA4l+gDyb62hMGHcHcvdM4o4qpBzIJ9JCLUh0wq 1a3BhTL//BI3t3z9mCfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqtgV-00CoGK-0w; Tue, 17 May 2022 09:40:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqtgM-00CoCC-2R for linux-arm-kernel@lists.infradead.org; Tue, 17 May 2022 09:39:59 +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 0F9D11042; Tue, 17 May 2022 02:39:57 -0700 (PDT) Received: from [10.1.27.154] (e121487-lin.cambridge.arm.com [10.1.27.154]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DDF573F66F; Tue, 17 May 2022 02:39:55 -0700 (PDT) Message-ID: <9d73e55a-4979-d304-238e-0b63dba5d8ee@arm.com> Date: Tue, 17 May 2022 10:39:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v2] arm64: mte: Ensure the cleared tags are visible before setting the PTE Content-Language: en-US To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Steven Price , Vincenzo Frascino References: <20220517093532.127095-1-catalin.marinas@arm.com> From: Vladimir Murzin In-Reply-To: <20220517093532.127095-1-catalin.marinas@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220517_023958_223329_C4805EC9 X-CRM114-Status: GOOD ( 18.81 ) 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 5/17/22 10:35, Catalin Marinas wrote: > As an optimisation, only pages mapped with PROT_MTE in user space have > the MTE tags zeroed. This is done lazily at the set_pte_at() time via > mte_sync_tags(). However, this function is missing a barrier and another > CPU may see the PTE updated before the zeroed tags are visible. Add an > smp_wmb() barrier if the mapping is Normal Tagged. > > Signed-off-by: Catalin Marinas > Fixes: 34bfeea4a9e9 ("arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE") > Cc: # 5.10.x > Reported-by: Vladimir Murzin > Cc: Will Deacon > --- > > Changes in v2: > - make the barrier unconditional > - not including reviewed-by, tested-by tags for v1 as the patch is slightly > different > > arch/arm64/kernel/mte.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c > index 90994aca54f3..d565ae25e48f 100644 > --- a/arch/arm64/kernel/mte.c > +++ b/arch/arm64/kernel/mte.c > @@ -67,6 +67,9 @@ void mte_sync_tags(pte_t old_pte, pte_t pte) > mte_sync_page_tags(page, old_pte, check_swap, > pte_is_tagged); > } > + > + /* ensure the tags are visible before the PTE is set */ > + smp_wmb(); > } > > int memcmp_pages(struct page *page1, struct page *page2) As I said in another e-mail this version has been tested in parallel to v1, so Tested-by: Vladimir Murzin Cheers Vladimir _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel