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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 70875C433E0 for ; Tue, 9 Mar 2021 12:31:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 03B5665238 for ; Tue, 9 Mar 2021 12:31:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03B5665238 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 884BC8D00EA; Tue, 9 Mar 2021 07:31:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 80C538D007F; Tue, 9 Mar 2021 07:31:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6860F8D00EA; Tue, 9 Mar 2021 07:31:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 48A478D007F for ; Tue, 9 Mar 2021 07:31:28 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 097158249980 for ; Tue, 9 Mar 2021 12:31:28 +0000 (UTC) X-FDA: 77900271456.19.3955AD7 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 4B8E3E005F15 for ; Tue, 9 Mar 2021 12:31:23 +0000 (UTC) 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 F28FA1042; Tue, 9 Mar 2021 04:31:23 -0800 (PST) Received: from [10.37.8.8] (unknown [10.37.8.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7C8223F70D; Tue, 9 Mar 2021 04:31:22 -0800 (PST) Subject: Re: [PATCH] arm64: mte: Map hotplugged memory as Normal Tagged To: Catalin Marinas , linux-arm-kernel@lists.infradead.org Cc: linux-mm@kvack.org, Anshuman Khandual , Patrick Daly , Will Deacon , Andrew Morton , David Hildenbrand References: <20210309122601.5543-1-catalin.marinas@arm.com> From: Vincenzo Frascino Message-ID: <12132bf8-860a-59d9-6ce9-2e59f5d90738@arm.com> Date: Tue, 9 Mar 2021 12:35:47 +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: <20210309122601.5543-1-catalin.marinas@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Stat-Signature: yzuapmbgmc96967bpso4nro5kyf17ypw X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4B8E3E005F15 Received-SPF: none (arm.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=foss.arm.com; client-ip=217.140.110.172 X-HE-DKIM-Result: none/none X-HE-Tag: 1615293083-510265 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 3/9/21 12:26 PM, Catalin Marinas wrote: > In a system supporting MTE, the linear map must allow reading/writing > allocation tags by setting the memory type as Normal Tagged. Currently, > this is only handled for memory present at boot. Hotplugged memory uses > Normal non-Tagged memory. > > Introduce pgprot_mhp() for hotplugged memory and use it in > add_memory_resource(). The arm64 code maps pgprot_mhp() to > pgprot_tagged(). > > Note that ZONE_DEVICE memory should not be mapped as Tagged and > therefore setting the memory type in arch_add_memory() is not feasible. > > Signed-off-by: Catalin Marinas > Fixes: 0178dc761368 ("arm64: mte: Use Normal Tagged attributes for the linear map") > Reported-by: Patrick Daly > Link: https://lore.kernel.org/r/1614745263-27827-1-git-send-email-pdaly@codeaurora.org > Cc: # 5.10.x > Cc: Will Deacon > Cc: Andrew Morton > Cc: Vincenzo Frascino > Cc: David Hildenbrand Reviewed-by: Vincenzo Frascino > --- > > Patrick, could you please give this patch a try on your platform? Thanks. > > arch/arm64/include/asm/pgtable-prot.h | 1 - > arch/arm64/include/asm/pgtable.h | 3 +++ > arch/arm64/mm/mmu.c | 3 ++- > include/linux/pgtable.h | 4 ++++ > mm/memory_hotplug.c | 2 +- > 5 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h > index 046be789fbb4..9a65fb528110 100644 > --- a/arch/arm64/include/asm/pgtable-prot.h > +++ b/arch/arm64/include/asm/pgtable-prot.h > @@ -66,7 +66,6 @@ extern bool arm64_use_ng_mappings; > #define _PAGE_DEFAULT (_PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL)) > > #define PAGE_KERNEL __pgprot(PROT_NORMAL) > -#define PAGE_KERNEL_TAGGED __pgprot(PROT_NORMAL_TAGGED) > #define PAGE_KERNEL_RO __pgprot((PROT_NORMAL & ~PTE_WRITE) | PTE_RDONLY) > #define PAGE_KERNEL_ROX __pgprot((PROT_NORMAL & ~(PTE_WRITE | PTE_PXN)) | PTE_RDONLY) > #define PAGE_KERNEL_EXEC __pgprot(PROT_NORMAL & ~PTE_PXN) > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index e17b96d0e4b5..47027796c2f9 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -486,6 +486,9 @@ static inline pmd_t pmd_mkdevmap(pmd_t pmd) > __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN) > #define pgprot_device(prot) \ > __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_PXN | PTE_UXN) > +#define pgprot_tagged(prot) \ > + __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_TAGGED)) > +#define pgprot_mhp pgprot_tagged > /* > * DMA allocations for non-coherent devices use what the Arm architecture calls > * "Normal non-cacheable" memory, which permits speculation, unaligned accesses > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 3802cfbdd20d..9c8aa1b44cd5 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -512,7 +512,8 @@ static void __init map_mem(pgd_t *pgdp) > * if MTE is present. Otherwise, it has the same attributes as > * PAGE_KERNEL. > */ > - __map_memblock(pgdp, start, end, PAGE_KERNEL_TAGGED, flags); > + __map_memblock(pgdp, start, end, pgprot_tagged(PAGE_KERNEL), > + flags); > } > > /* > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index cdfc4e9f253e..5e772392a379 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -904,6 +904,10 @@ static inline void ptep_modify_prot_commit(struct vm_area_struct *vma, > #define pgprot_device pgprot_noncached > #endif > > +#ifndef pgprot_mhp > +#define pgprot_mhp(prot) (prot) > +#endif > + > #ifdef CONFIG_MMU > #ifndef pgprot_modify > #define pgprot_modify pgprot_modify > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 5ba51a8bdaeb..0cdbbfbc5757 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1072,7 +1072,7 @@ static int online_memory_block(struct memory_block *mem, void *arg) > */ > int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) > { > - struct mhp_params params = { .pgprot = PAGE_KERNEL }; > + struct mhp_params params = { .pgprot = pgprot_mhp(PAGE_KERNEL) }; > u64 start, size; > bool new_node = false; > int ret; > -- Regards, Vincenzo 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=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,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 96339C433DB for ; Tue, 9 Mar 2021 12:32:59 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 29EC065238 for ; Tue, 9 Mar 2021 12:32:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29EC065238 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/LJHJJTQ1iGMqozZZ5m6+rg8c4u8fkAiJmgYMyuDlDU=; b=Bwt0hFK9NIbSnoeYvKa0A/jKf OyyxhRsPp1BrwLhOFbpfMyMD72ryzwqitPKZOfObnICjeF6OnTdPz6+sB8N8DYnaqha7Pnw96ygpX 8G4ALMNCyAEDFd9Fi1/GwZ3QGsF3Xtt/I/0Fx1/mX8ifDM2Lc/lg3YGlW3WcJcvnlUqRn/bUsnYee 5RuJ27L26ZHIKTbRye6YufC+d9sVT/TmDT/XTwgF3tuYrC5y/f7/YjjkU5XuTJEYbOAX0AHuZ/2JL 7NiD3+BiNz4Ka/P03gGjlW0svM2epR4tfndRZ3HaUwKNYKjYFL76JJSLUhY5IJy07VR9OYZpCEdLU MtcsrJZMQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJbWO-004Sw9-TO; Tue, 09 Mar 2021 12:31:33 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJbWI-004SvU-U2 for linux-arm-kernel@lists.infradead.org; Tue, 09 Mar 2021 12:31:29 +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 F28FA1042; Tue, 9 Mar 2021 04:31:23 -0800 (PST) Received: from [10.37.8.8] (unknown [10.37.8.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7C8223F70D; Tue, 9 Mar 2021 04:31:22 -0800 (PST) Subject: Re: [PATCH] arm64: mte: Map hotplugged memory as Normal Tagged To: Catalin Marinas , linux-arm-kernel@lists.infradead.org Cc: linux-mm@kvack.org, Anshuman Khandual , Patrick Daly , Will Deacon , Andrew Morton , David Hildenbrand References: <20210309122601.5543-1-catalin.marinas@arm.com> From: Vincenzo Frascino Message-ID: <12132bf8-860a-59d9-6ce9-2e59f5d90738@arm.com> Date: Tue, 9 Mar 2021 12:35:47 +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: <20210309122601.5543-1-catalin.marinas@arm.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210309_123127_791010_F1FBAFC3 X-CRM114-Status: GOOD ( 25.61 ) 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 3/9/21 12:26 PM, Catalin Marinas wrote: > In a system supporting MTE, the linear map must allow reading/writing > allocation tags by setting the memory type as Normal Tagged. Currently, > this is only handled for memory present at boot. Hotplugged memory uses > Normal non-Tagged memory. > > Introduce pgprot_mhp() for hotplugged memory and use it in > add_memory_resource(). The arm64 code maps pgprot_mhp() to > pgprot_tagged(). > > Note that ZONE_DEVICE memory should not be mapped as Tagged and > therefore setting the memory type in arch_add_memory() is not feasible. > > Signed-off-by: Catalin Marinas > Fixes: 0178dc761368 ("arm64: mte: Use Normal Tagged attributes for the linear map") > Reported-by: Patrick Daly > Link: https://lore.kernel.org/r/1614745263-27827-1-git-send-email-pdaly@codeaurora.org > Cc: # 5.10.x > Cc: Will Deacon > Cc: Andrew Morton > Cc: Vincenzo Frascino > Cc: David Hildenbrand Reviewed-by: Vincenzo Frascino > --- > > Patrick, could you please give this patch a try on your platform? Thanks. > > arch/arm64/include/asm/pgtable-prot.h | 1 - > arch/arm64/include/asm/pgtable.h | 3 +++ > arch/arm64/mm/mmu.c | 3 ++- > include/linux/pgtable.h | 4 ++++ > mm/memory_hotplug.c | 2 +- > 5 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h > index 046be789fbb4..9a65fb528110 100644 > --- a/arch/arm64/include/asm/pgtable-prot.h > +++ b/arch/arm64/include/asm/pgtable-prot.h > @@ -66,7 +66,6 @@ extern bool arm64_use_ng_mappings; > #define _PAGE_DEFAULT (_PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL)) > > #define PAGE_KERNEL __pgprot(PROT_NORMAL) > -#define PAGE_KERNEL_TAGGED __pgprot(PROT_NORMAL_TAGGED) > #define PAGE_KERNEL_RO __pgprot((PROT_NORMAL & ~PTE_WRITE) | PTE_RDONLY) > #define PAGE_KERNEL_ROX __pgprot((PROT_NORMAL & ~(PTE_WRITE | PTE_PXN)) | PTE_RDONLY) > #define PAGE_KERNEL_EXEC __pgprot(PROT_NORMAL & ~PTE_PXN) > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index e17b96d0e4b5..47027796c2f9 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -486,6 +486,9 @@ static inline pmd_t pmd_mkdevmap(pmd_t pmd) > __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN) > #define pgprot_device(prot) \ > __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_PXN | PTE_UXN) > +#define pgprot_tagged(prot) \ > + __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_TAGGED)) > +#define pgprot_mhp pgprot_tagged > /* > * DMA allocations for non-coherent devices use what the Arm architecture calls > * "Normal non-cacheable" memory, which permits speculation, unaligned accesses > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 3802cfbdd20d..9c8aa1b44cd5 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -512,7 +512,8 @@ static void __init map_mem(pgd_t *pgdp) > * if MTE is present. Otherwise, it has the same attributes as > * PAGE_KERNEL. > */ > - __map_memblock(pgdp, start, end, PAGE_KERNEL_TAGGED, flags); > + __map_memblock(pgdp, start, end, pgprot_tagged(PAGE_KERNEL), > + flags); > } > > /* > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index cdfc4e9f253e..5e772392a379 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -904,6 +904,10 @@ static inline void ptep_modify_prot_commit(struct vm_area_struct *vma, > #define pgprot_device pgprot_noncached > #endif > > +#ifndef pgprot_mhp > +#define pgprot_mhp(prot) (prot) > +#endif > + > #ifdef CONFIG_MMU > #ifndef pgprot_modify > #define pgprot_modify pgprot_modify > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 5ba51a8bdaeb..0cdbbfbc5757 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1072,7 +1072,7 @@ static int online_memory_block(struct memory_block *mem, void *arg) > */ > int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) > { > - struct mhp_params params = { .pgprot = PAGE_KERNEL }; > + struct mhp_params params = { .pgprot = pgprot_mhp(PAGE_KERNEL) }; > u64 start, size; > bool new_node = false; > int ret; > -- Regards, Vincenzo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel