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.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 D7778C433E0 for ; Wed, 10 Mar 2021 06:16:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5067A64FE7 for ; Wed, 10 Mar 2021 06:16:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5067A64FE7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D3ACD8D016F; Wed, 10 Mar 2021 01:16:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CEA868D0148; Wed, 10 Mar 2021 01:16:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8AF58D016F; Wed, 10 Mar 2021 01:16:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id 9EFD88D0148 for ; Wed, 10 Mar 2021 01:16:55 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6439E8249980 for ; Wed, 10 Mar 2021 06:16:55 +0000 (UTC) X-FDA: 77902956390.03.49CED42 Received: from m42-2.mailgun.net (m42-2.mailgun.net [69.72.42.2]) by imf19.hostedemail.com (Postfix) with ESMTP id 0E79290009ED for ; Wed, 10 Mar 2021 06:16:51 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1615357014; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=9DfLzZ2Hmz07klDVVZy91sYjWXqKgf1miT3qeGUZqsM=; b=vpGaVKZ/cJyWOt7VjXLR6SH8++7cj9IHJCAhenEY7shXdKSwKuy59Y8PuXdBS6rF0nKeqrKS 4YrTbzxgl568UhAKlS5+RhaSJrywQMw6SGDSTKUuLExgqgnCDc0M92BTgrrfMGVQPmRhFjY/ feRy+mE6RUWMXh+9pHX13mqupKo= X-Mailgun-Sending-Ip: 69.72.42.2 X-Mailgun-Sid: WyIwY2Q3OCIsICJsaW51eC1tbUBrdmFjay5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-east-1.postgun.com with SMTP id 60486448d3a53bc38f27e333 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 10 Mar 2021 06:16:40 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 2423FC433ED; Wed, 10 Mar 2021 06:16:40 +0000 (UTC) Received: from pdaly-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pdaly) by smtp.codeaurora.org (Postfix) with ESMTPSA id AD8DEC433CA; Wed, 10 Mar 2021 06:16:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org AD8DEC433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=pdaly@codeaurora.org Date: Tue, 9 Mar 2021 22:16:29 -0800 From: Patrick Daly To: Catalin Marinas Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Anshuman Khandual , Will Deacon , Andrew Morton , Vincenzo Frascino , David Hildenbrand Subject: Re: [PATCH] arm64: mte: Map hotplugged memory as Normal Tagged Message-ID: <20210310061629.GA22526@pdaly-linux.qualcomm.com> References: <20210309122601.5543-1-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210309122601.5543-1-catalin.marinas@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0E79290009ED X-Stat-Signature: rqwdtgzjhgipdrbs91bku5fjg196wsjc Received-SPF: none (mg.codeaurora.org>: No applicable sender policy available) receiver=imf19; identity=mailfrom; envelope-from=""; helo=m42-2.mailgun.net; client-ip=69.72.42.2 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615357011-616855 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 Tue, Mar 09, 2021 at 12:26:01PM +0000, 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 > --- > > Patrick, could you please give this patch a try on your platform? Thanks. > Worked for me. > 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; -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project