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 45FE9C433EF for ; Tue, 17 May 2022 13:28:36 +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=finhdX1OJdjeHbEuvfdT1eBx/6qnrE9ojpBFUKHcbBU=; b=NzINxVjBa1ZUMe jlKKIs/2sUvXYU5MNhGeTnfxqq/qlYXkR5Lxs19x0tYAmLQ2/DpBGHn1R0UsqeWnY3n++GfXB9Pql nYymICqJGK0OAert8EQqFuIz/zNSwBSa7glV8Ozyt0X9+ErOtSQ3WxkrhqjYW4oZjTYiX10Pp9UBg 6iagJccSS3SaDKc1Yi3B0ud29NNW8cbuiHB81X/Z/lbfdADjkYSjVcByC6yjTVeNxz2RFmP/TISym MH0QeHinCpEnHlqWtSJ+FbBwwYrD4FvLqSW3itArL22pz8UkS83EHTSbkjU6s5Au5O1U1x8k86Fh6 iXRWA4s7Q8f3lbxpf1Dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqxEV-00DuNQ-1e; Tue, 17 May 2022 13:27:27 +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 1nqx3h-00DqKW-D6 for linux-arm-kernel@lists.infradead.org; Tue, 17 May 2022 13:16:18 +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 B00DF1063; Tue, 17 May 2022 06:16:15 -0700 (PDT) Received: from [10.57.1.151] (unknown [10.57.1.151]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 934223F718; Tue, 17 May 2022 06:16:14 -0700 (PDT) Message-ID: <389862a9-a935-7dce-df44-89c1797e45a5@arm.com> Date: Tue, 17 May 2022 14:16:13 +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 , Vladimir Murzin References: <20220517093532.127095-1-catalin.marinas@arm.com> From: Vincenzo Frascino 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_061617_570889_8BD5EF4B X-CRM114-Status: GOOD ( 18.57 ) 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 Reviewed-by: Vincenzo Frascino > --- > > 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) -- Regards, Vincenzo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel