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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 4F3C9C433DB for ; Tue, 9 Mar 2021 12:28:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CDBA765101 for ; Tue, 9 Mar 2021 12:28:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDBA765101 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 507348D00E9; Tue, 9 Mar 2021 07:28:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DD388D007F; Tue, 9 Mar 2021 07:28:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37D688D00E9; Tue, 9 Mar 2021 07:28:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0037.hostedemail.com [216.40.44.37]) by kanga.kvack.org (Postfix) with ESMTP id 1EF458D007F for ; Tue, 9 Mar 2021 07:28:43 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C91D38249980 for ; Tue, 9 Mar 2021 12:28:42 +0000 (UTC) X-FDA: 77900264484.29.8B30123 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf22.hostedemail.com (Postfix) with ESMTP id E72B2C0007C9 for ; Tue, 9 Mar 2021 12:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615292921; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BAkudv5LkARNb6Oc1S4xm0fjMEHpBrJ1RAD0OHJvd3Y=; b=D0iYPKkmSx8ikbO7baxK6TPj4PiVvS9u/zYXfYYiTw9W+VuvJT6+p99bKYT/PrMmzJ5u22 P0rfOOBhNB40I6vF3scf/4NaM+4Prun5kTAR0tZezbkUYUFOTFcpUgK1BiAd5xQ55uXxxY Ny1f9YieO5nJ9UN4i+RoxhM0Jg4vrRQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-462-n5Nl5to0MjS9Vva3EyUBiw-1; Tue, 09 Mar 2021 07:28:37 -0500 X-MC-Unique: n5Nl5to0MjS9Vva3EyUBiw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F28411005D45; Tue, 9 Mar 2021 12:28:35 +0000 (UTC) Received: from [10.36.114.143] (ovpn-114-143.ams2.redhat.com [10.36.114.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AEAC10013C1; Tue, 9 Mar 2021 12:28:34 +0000 (UTC) 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 , Vincenzo Frascino References: <20210309122601.5543-1-catalin.marinas@arm.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <7c01d3e6-2ccc-59be-0282-8cf6662c2686@redhat.com> Date: Tue, 9 Mar 2021 13:28:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210309122601.5543-1-catalin.marinas@arm.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E72B2C0007C9 X-Stat-Signature: f78wbsxbzkptygmmzb6zg5hsgeum7rce Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=63.128.21.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615292919-714442 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 09.03.21 13:26, 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. > > 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; > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb