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=-14.8 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,SIGNED_OFF_BY,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 C2319C43461 for ; Thu, 10 Sep 2020 10:25:10 +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 4FD842078E for ; Thu, 10 Sep 2020 10:25:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eSUtT5gg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FD842078E Authentication-Results: mail.kernel.org; dmarc=none (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-Type: Content-Transfer-Encoding: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=lyu4aFka7KFKjTWEDWX6UmPwUFA2FmxaXgL5ftWpZoY=; b=eSUtT5gg+KXvsnhDsXbQZz4Le cz4qqbI2pDiDhewDYNigQpNVH3PWbso2v3M9T2ahlIvNr3Tr3HGD7zeuAWUqvpAnlxdaKZisUVUcS AyShigWAGpcMNP4+M7HiWE4n8GjqBJb0VJcutswZAuJH5ytnYTvXo0bjNWbfxRQ4Nc9sDDoU1BWGa tGyF0z4SIda2mkOryYQdhqeyYPujgbpnpo4WD20EcKfDbd5i1q/8l87VAghHepdaF/Tdsta7uGQuy 6N6W6rjKRoAZuvaiEounD5qgyX4q50VDcKmPLs1t2km9WIodWVYsmOxTTJZSm8pZuPW8XraQvQYZU 6/Fmjq49A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGJk4-0002mi-7Z; Thu, 10 Sep 2020 10:23:48 +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 1kGJk2-0002lV-8Q for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 10:23:47 +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 B4B941063; Thu, 10 Sep 2020 03:23:44 -0700 (PDT) Received: from [192.168.1.179] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2D4693F68F; Thu, 10 Sep 2020 03:23:43 -0700 (PDT) Subject: Re: [PATCH v9 09/29] arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE To: Catalin Marinas , linux-arm-kernel@lists.infradead.org References: <20200904103029.32083-1-catalin.marinas@arm.com> <20200904103029.32083-10-catalin.marinas@arm.com> From: Steven Price Message-ID: <5c2ebe16-2ac9-6cff-3456-6d8ac96b5fb7@arm.com> Date: Thu, 10 Sep 2020 11:23:33 +0100 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: <20200904103029.32083-10-catalin.marinas@arm.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200910_062346_345278_3533FFFD X-CRM114-Status: GOOD ( 20.76 ) 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-arch@vger.kernel.org, Szabolcs Nagy , Andrey Konovalov , Kevin Brodsky , Peter Collingbourne , linux-mm@kvack.org, Andrew Morton , Vincenzo Frascino , Will Deacon , Dave P Martin Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 04/09/2020 11:30, Catalin Marinas wrote: > Pages allocated by the kernel are not guaranteed to have the tags > zeroed, especially as the kernel does not (yet) use MTE itself. To > ensure the user can still access such pages when mapped into its address > space, clear the tags via set_pte_at(). A new page flag - PG_mte_tagged > (PG_arch_2) - is used to track pages with valid allocation tags. > > Since the zero page is mapped as pte_special(), it won't be covered by > the above set_pte_at() mechanism. Clear its tags during early MTE > initialisation. > > Co-developed-by: Steven Price > Signed-off-by: Steven Price > Signed-off-by: Catalin Marinas > Cc: Will Deacon [...] > diff --git a/arch/arm64/lib/mte.S b/arch/arm64/lib/mte.S > new file mode 100644 > index 000000000000..a36705640086 > --- /dev/null > +++ b/arch/arm64/lib/mte.S > @@ -0,0 +1,34 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (C) 2020 ARM Ltd. > + */ > +#include > + > +#include > +#include > + > + .arch armv8.5-a+memtag > + > +/* > + * multitag_transfer_size - set \reg to the block size that is accessed by the > + * LDGM/STGM instructions. > + */ > + .macro multitag_transfer_size, reg, tmp > + mrs_s \reg, SYS_GMID_EL1 > + ubfx \reg, \reg, #SYS_GMID_EL1_BS_SHIFT, #SYS_GMID_EL1_BS_SIZE > + mov \tmp, #4 > + lsl \reg, \tmp, \reg > + .endm > + > +/* > + * Clear the tags in a page > + * x0 - address of the page to be cleared > + */ > +SYM_FUNC_START(mte_clear_page_tags) > + multitag_transfer_size x1, x2 > +1: stgm xzr, [x0] > + add x0, x0, x1 > + tst x0, #(PAGE_SIZE - 1) > + b.ne 1b > + ret > +SYM_FUNC_END(mte_clear_page_tags) > Could the value of SYS_GMID_EL1 vary between CPUs and do we therefore need a preempt_disable() around mte_clear_page_tags() (and other functions in later patches)? Steve _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel