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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 34C19C10F00 for ; Fri, 6 Mar 2020 17:09:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E06212072A for ; Fri, 6 Mar 2020 17:09:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E06212072A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=deltatee.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 872806B0036; Fri, 6 Mar 2020 12:09:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7AEBD6B0007; Fri, 6 Mar 2020 12:09:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F2476B0032; Fri, 6 Mar 2020 12:09:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id 207006B0007 for ; Fri, 6 Mar 2020 12:09:07 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EA865585C for ; Fri, 6 Mar 2020 17:09:06 +0000 (UTC) X-FDA: 76565572692.29.point88_4f74df3628c62 X-HE-Tag: point88_4f74df3628c62 X-Filterd-Recvd-Size: 10809 Received: from ale.deltatee.com (ale.deltatee.com [207.54.116.67]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Mar 2020 17:09:05 +0000 (UTC) Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jAGT0-0004aU-Io; Fri, 06 Mar 2020 10:08:59 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1jAGSv-0002Rc-QE; Fri, 06 Mar 2020 10:08:49 -0700 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-mm@kvack.org, Dan Williams , Michal Hocko , David Hildenbrand , Andrew Morton Cc: Christoph Hellwig , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Eric Badger , Logan Gunthorpe , Paul Mackerras , Michael Ellerman Date: Fri, 6 Mar 2020 10:08:44 -0700 Message-Id: <20200306170846.9333-6-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200306170846.9333-1-logang@deltatee.com> References: <20200306170846.9333-1-logang@deltatee.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-mm@kvack.org, dan.j.williams@intel.com, akpm@linux-foundation.org, hch@lst.de, catalin.marinas@arm.com, benh@kernel.crashing.org, tglx@linutronix.de, david@redhat.com, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, mhocko@kernel.org, will@kernel.org, luto@kernel.org, peterz@infradead.org, ebadger@gigaio.com, logang@deltatee.com, paulus@samba.org, mpe@ellerman.id.au X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH v4 5/7] powerpc/mm: Thread pgprot_t through create_section_mapping() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Content-Transfer-Encoding: quoted-printable 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: In prepartion to support a pgprot_t argument for arch_add_memory(). Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Signed-off-by: Logan Gunthorpe --- arch/powerpc/include/asm/book3s/64/hash.h | 3 ++- arch/powerpc/include/asm/book3s/64/radix.h | 3 ++- arch/powerpc/include/asm/sparsemem.h | 3 ++- arch/powerpc/mm/book3s64/hash_utils.c | 5 +++-- arch/powerpc/mm/book3s64/pgtable.c | 7 ++++--- arch/powerpc/mm/book3s64/radix_pgtable.c | 18 +++++++++++------- arch/powerpc/mm/mem.c | 5 +++-- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/inc= lude/asm/book3s/64/hash.h index 2781ebf6add4..6fc4520092c7 100644 --- a/arch/powerpc/include/asm/book3s/64/hash.h +++ b/arch/powerpc/include/asm/book3s/64/hash.h @@ -251,7 +251,8 @@ extern int __meminit hash__vmemmap_create_mapping(uns= igned long start, extern void hash__vmemmap_remove_mapping(unsigned long start, unsigned long page_size); =20 -int hash__create_section_mapping(unsigned long start, unsigned long end,= int nid); +int hash__create_section_mapping(unsigned long start, unsigned long end, + int nid, pgprot_t prot); int hash__remove_section_mapping(unsigned long start, unsigned long end)= ; =20 #endif /* !__ASSEMBLY__ */ diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/in= clude/asm/book3s/64/radix.h index d97db3ad9aae..46799f3c3d1d 100644 --- a/arch/powerpc/include/asm/book3s/64/radix.h +++ b/arch/powerpc/include/asm/book3s/64/radix.h @@ -289,7 +289,8 @@ static inline unsigned long radix__get_tree_size(void= ) } =20 #ifdef CONFIG_MEMORY_HOTPLUG -int radix__create_section_mapping(unsigned long start, unsigned long end= , int nid); +int radix__create_section_mapping(unsigned long start, unsigned long end= , + int nid, pgprot_t prot); int radix__remove_section_mapping(unsigned long start, unsigned long end= ); #endif /* CONFIG_MEMORY_HOTPLUG */ #endif /* __ASSEMBLY__ */ diff --git a/arch/powerpc/include/asm/sparsemem.h b/arch/powerpc/include/= asm/sparsemem.h index 3192d454a733..c89b32443cff 100644 --- a/arch/powerpc/include/asm/sparsemem.h +++ b/arch/powerpc/include/asm/sparsemem.h @@ -13,7 +13,8 @@ #endif /* CONFIG_SPARSEMEM */ =20 #ifdef CONFIG_MEMORY_HOTPLUG -extern int create_section_mapping(unsigned long start, unsigned long end= , int nid); +extern int create_section_mapping(unsigned long start, unsigned long end= , + int nid, pgprot_t prot); extern int remove_section_mapping(unsigned long start, unsigned long end= ); =20 #ifdef CONFIG_PPC_BOOK3S_64 diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book= 3s64/hash_utils.c index 523d4d39d11e..201738e07a1d 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -809,7 +809,8 @@ int resize_hpt_for_hotplug(unsigned long new_mem_size= ) return 0; } =20 -int hash__create_section_mapping(unsigned long start, unsigned long end,= int nid) +int hash__create_section_mapping(unsigned long start, unsigned long end, + int nid, pgprot_t prot) { int rc; =20 @@ -819,7 +820,7 @@ int hash__create_section_mapping(unsigned long start,= unsigned long end, int nid } =20 rc =3D htab_bolt_mapping(start, end, __pa(start), - pgprot_val(PAGE_KERNEL), mmu_linear_psize, + pgprot_val(prot), mmu_linear_psize, mmu_kernel_ssize); =20 if (rc < 0) { diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s6= 4/pgtable.c index 2bf7e1b4fd82..e0bb69c616e4 100644 --- a/arch/powerpc/mm/book3s64/pgtable.c +++ b/arch/powerpc/mm/book3s64/pgtable.c @@ -171,12 +171,13 @@ void mmu_cleanup_all(void) } =20 #ifdef CONFIG_MEMORY_HOTPLUG -int __meminit create_section_mapping(unsigned long start, unsigned long = end, int nid) +int __meminit create_section_mapping(unsigned long start, unsigned long = end, + int nid, pgprot_t prot) { if (radix_enabled()) - return radix__create_section_mapping(start, end, nid); + return radix__create_section_mapping(start, end, nid, prot); =20 - return hash__create_section_mapping(start, end, nid); + return hash__create_section_mapping(start, end, nid, prot); } =20 int __meminit remove_section_mapping(unsigned long start, unsigned long = end) diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/b= ook3s64/radix_pgtable.c index dd1bea45325c..0ef10b5c26ba 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -253,7 +253,7 @@ static unsigned long next_boundary(unsigned long addr= , unsigned long end) =20 static int __meminit create_physical_mapping(unsigned long start, unsigned long end, - int nid) + int nid, pgprot_t _prot) { unsigned long vaddr, addr, mapping_size =3D 0; bool prev_exec, exec =3D false; @@ -289,7 +289,7 @@ static int __meminit create_physical_mapping(unsigned= long start, prot =3D PAGE_KERNEL_X; exec =3D true; } else { - prot =3D PAGE_KERNEL; + prot =3D _prot; exec =3D false; } =20 @@ -333,7 +333,7 @@ static void __init radix_init_pgtable(void) =20 WARN_ON(create_physical_mapping(reg->base, reg->base + reg->size, - -1)); + -1, PAGE_KERNEL)); } =20 /* Find out how many PID bits are supported */ @@ -712,8 +712,10 @@ static int __meminit stop_machine_change_mapping(voi= d *data) =20 spin_unlock(&init_mm.page_table_lock); pte_clear(&init_mm, params->aligned_start, params->pte); - create_physical_mapping(__pa(params->aligned_start), __pa(params->start= ), -1); - create_physical_mapping(__pa(params->end), __pa(params->aligned_end), -= 1); + create_physical_mapping(__pa(params->aligned_start), + __pa(params->start), -1, PAGE_KERNEL); + create_physical_mapping(__pa(params->end), __pa(params->aligned_end), + -1, PAGE_KERNEL); spin_lock(&init_mm.page_table_lock); return 0; } @@ -870,14 +872,16 @@ static void __meminit remove_pagetable(unsigned lon= g start, unsigned long end) radix__flush_tlb_kernel_range(start, end); } =20 -int __meminit radix__create_section_mapping(unsigned long start, unsigne= d long end, int nid) +int __meminit radix__create_section_mapping(unsigned long start, + unsigned long end, int nid, + pgprot_t prot) { if (end >=3D RADIX_VMALLOC_START) { pr_warn("Outside the supported range\n"); return -1; } =20 - return create_physical_mapping(__pa(start), __pa(end), nid); + return create_physical_mapping(__pa(start), __pa(end), nid, prot); } =20 int __meminit radix__remove_section_mapping(unsigned long start, unsigne= d long end) diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index b4bece53bec0..19b1da5d7eca 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -96,7 +96,8 @@ int memory_add_physaddr_to_nid(u64 start) } #endif =20 -int __weak create_section_mapping(unsigned long start, unsigned long end= , int nid) +int __weak create_section_mapping(unsigned long start, unsigned long end= , + int nid, pgprot_t prot) { return -ENODEV; } @@ -137,7 +138,7 @@ int __ref arch_add_memory(int nid, u64 start, u64 siz= e, resize_hpt_for_hotplug(memblock_phys_mem_size()); =20 start =3D (unsigned long)__va(start); - rc =3D create_section_mapping(start, start + size, nid); + rc =3D create_section_mapping(start, start + size, nid, PAGE_KERNEL); if (rc) { pr_warn("Unable to create mapping for hot added memory 0x%llx..0x%llx:= %d\n", start, start + size, rc); --=20 2.20.1