From nobody Sun May 10 17:53:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9433C433F5 for ; Wed, 27 Apr 2022 12:02:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233328AbiD0MFl (ORCPT ); Wed, 27 Apr 2022 08:05:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233424AbiD0MFc (ORCPT ); Wed, 27 Apr 2022 08:05:32 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB8D3B2B3 for ; Wed, 27 Apr 2022 05:02:20 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KpHLd2cYQzCsSQ; Wed, 27 Apr 2022 19:57:45 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:02:18 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:02:17 +0800 From: Kefeng Wang To: Catalin Marinas , Will Deacon , Andrew Morton , , CC: , Kefeng Wang Subject: [PATCH 1/4] mm: ioremap: Setup phys_addr of struct vm_struct Date: Wed, 27 Apr 2022 20:14:10 +0800 Message-ID: <20220427121413.168468-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220427121413.168468-1-wangkefeng.wang@huawei.com> References: <20220427121413.168468-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Show physical address in /proc/vmallocinfo. Signed-off-by: Kefeng Wang Acked-by: Andrew Morton Reviewed-by: Christoph Hellwig --- mm/ioremap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 5fe598ecd9b7..522ef899c35f 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -32,6 +32,7 @@ void __iomem *ioremap_prot(phys_addr_t addr, size_t size,= unsigned long prot) if (!area) return NULL; vaddr =3D (unsigned long)area->addr; + area->phys_addr =3D addr; =20 if (ioremap_page_range(vaddr, vaddr + size, addr, __pgprot(prot))) { free_vm_area(area); --=20 2.26.2 From nobody Sun May 10 17:53:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12EFFC433EF for ; Wed, 27 Apr 2022 12:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233391AbiD0MFi (ORCPT ); Wed, 27 Apr 2022 08:05:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233435AbiD0MFc (ORCPT ); Wed, 27 Apr 2022 08:05:32 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2B4D3B2BD for ; Wed, 27 Apr 2022 05:02:20 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KpHQr4cVVz1JBqV; Wed, 27 Apr 2022 20:01:24 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:02:18 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:02:18 +0800 From: Kefeng Wang To: Catalin Marinas , Will Deacon , Andrew Morton , , CC: , Kefeng Wang Subject: [PATCH 2/4] mm: ioremap: Add arch_ioremap/iounmap_check() Date: Wed, 27 Apr 2022 20:14:11 +0800 Message-ID: <20220427121413.168468-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220427121413.168468-1-wangkefeng.wang@huawei.com> References: <20220427121413.168468-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add special check hook for architecture to verify addr, size or prot when ioremap() or iounmap(), which will make the generic ioremap more useful. Signed-off-by: Kefeng Wang Acked-by: Andrew Morton --- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 7ce93aaf69f8..26924fded7c3 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -964,6 +964,9 @@ static inline void iounmap(volatile void __iomem *addr) #elif defined(CONFIG_GENERIC_IOREMAP) #include =20 +bool arch_ioremap_check(phys_addr_t addr, size_t size, unsigned long prot); +bool arch_iounmap_check(void __iomem *addr); + void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long pr= ot); void iounmap(volatile void __iomem *addr); =20 diff --git a/mm/ioremap.c b/mm/ioremap.c index 522ef899c35f..d1117005dcc7 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,6 +11,16 @@ #include #include =20 +bool __weak arch_ioremap_check(phys_addr_t addr, size_t size, unsigned lon= g prot) +{ + return true; +} + +bool __weak arch_iounmap_check(void __iomem *addr) +{ + return true; +} + void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long pr= ot) { unsigned long offset, vaddr; @@ -27,6 +37,9 @@ void __iomem *ioremap_prot(phys_addr_t addr, size_t size,= unsigned long prot) addr -=3D offset; size =3D PAGE_ALIGN(size + offset); =20 + if (!arch_ioremap_check(addr, size, prot)) + return NULL; + area =3D get_vm_area_caller(size, VM_IOREMAP, __builtin_return_address(0)); if (!area) @@ -45,6 +58,11 @@ EXPORT_SYMBOL(ioremap_prot); =20 void iounmap(volatile void __iomem *addr) { - vunmap((void *)((unsigned long)addr & PAGE_MASK)); + void *vaddr =3D (void *)((unsigned long)addr & PAGE_MASK); + + if (!arch_iounmap_check(vaddr)) + return; + + vunmap(vaddr); } EXPORT_SYMBOL(iounmap); --=20 2.26.2 From nobody Sun May 10 17:53:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BBE2C433F5 for ; Wed, 27 Apr 2022 12:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233452AbiD0MFo (ORCPT ); Wed, 27 Apr 2022 08:05:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233436AbiD0MFc (ORCPT ); Wed, 27 Apr 2022 08:05:32 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFBA13B3C4 for ; Wed, 27 Apr 2022 05:02:20 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KpHRX4NRxzhYqv; Wed, 27 Apr 2022 20:02:00 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:02:19 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:02:18 +0800 From: Kefeng Wang To: Catalin Marinas , Will Deacon , Andrew Morton , , CC: , Kefeng Wang Subject: [PATCH 3/4] arm64: mm: Convert to GENERIC_IOREMAP Date: Wed, 27 Apr 2022 20:14:12 +0800 Message-ID: <20220427121413.168468-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220427121413.168468-1-wangkefeng.wang@huawei.com> References: <20220427121413.168468-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add hook for arch's special check when ioremap() and iounmap(), then ioremap_wc/np/cache is converted to use ioremap_prot() from GENERIC_IOREMAP, update the Copyright and kill the unused inclusions. Signed-off-by: Kefeng Wang --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/io.h | 14 +++--- arch/arm64/kernel/acpi.c | 2 +- arch/arm64/mm/ioremap.c | 86 +++++-------------------------------- 4 files changed, 21 insertions(+), 82 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 57c4c995965f..838c45f1517b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -123,6 +123,7 @@ config ARM64 select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP select GENERIC_IDLE_POLL_SETUP + select GENERIC_IOREMAP select GENERIC_IRQ_IPI select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 7fd836bea7eb..773fffa62a14 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -163,13 +163,15 @@ extern void __memset_io(volatile void __iomem *, int,= size_t); /* * I/O memory mapping functions. */ -extern void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_= t prot); -extern void iounmap(volatile void __iomem *addr); -extern void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size); =20 -#define ioremap(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVIC= E_nGnRE)) -#define ioremap_wc(addr, size) __ioremap((addr), (size), __pgprot(PROT_NO= RMAL_NC)) -#define ioremap_np(addr, size) __ioremap((addr), (size), __pgprot(PROT_DE= VICE_nGnRnE)) +#define _PAGE_IOREMAP PROT_DEVICE_nGnRE + +#define ioremap_wc(addr, size) ioremap_prot((addr), (size), PROT_NORMAL_N= C) +#define ioremap_np(addr, size) ioremap_prot((addr), (size), PROT_DEVICE_n= GnRnE) +#define ioremap_cache(addr, size) ({ \ + pfn_is_map_memory(__phys_to_pfn(addr)) ? \ + (void __iomem *)__phys_to_virt(addr) : ioremap_prot(addr, size, PROT_NORM= AL); \ +}) =20 /* * io{read,write}{16,32,64}be() macros diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index e4dea8db6924..a5a256e3f9fe 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -351,7 +351,7 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phy= s, acpi_size size) prot =3D __acpi_get_writethrough_mem_attribute(); } } - return __ioremap(phys, size, prot); + return ioremap_prot(phys, size, pgprot_val(prot)); } =20 /* diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index b7c81dacabf0..90e8a248e733 100644 --- a/arch/arm64/mm/ioremap.c +++ b/arch/arm64/mm/ioremap.c @@ -1,96 +1,32 @@ // SPDX-License-Identifier: GPL-2.0-only -/* - * Based on arch/arm/mm/ioremap.c - * - * (C) Copyright 1995 1996 Linus Torvalds - * Hacked for ARM by Phil Blundell - * Hacked to allow all architectures to build, and various cleanups - * by Russell King - * Copyright (C) 2012 ARM Ltd. - */ =20 -#include #include #include #include =20 -#include -#include - -static void __iomem *__ioremap_caller(phys_addr_t phys_addr, size_t size, - pgprot_t prot, void *caller) +bool arch_ioremap_check(phys_addr_t addr, size_t size, unsigned long prot) { - unsigned long last_addr; - unsigned long offset =3D phys_addr & ~PAGE_MASK; - int err; - unsigned long addr; - struct vm_struct *area; - - /* - * Page align the mapping address and size, taking account of any - * offset. - */ - phys_addr &=3D PAGE_MASK; - size =3D PAGE_ALIGN(size + offset); - - /* - * Don't allow wraparound, zero size or outside PHYS_MASK. - */ - last_addr =3D phys_addr + size - 1; - if (!size || last_addr < phys_addr || (last_addr & ~PHYS_MASK)) - return NULL; - - /* - * Don't allow RAM to be mapped. - */ - if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr)))) - return NULL; + unsigned long last_addr =3D addr + size - 1; =20 - area =3D get_vm_area_caller(size, VM_IOREMAP, caller); - if (!area) - return NULL; - addr =3D (unsigned long)area->addr; - area->phys_addr =3D phys_addr; + /* Don't allow outside PHYS_MASK */ + if (last_addr & ~PHYS_MASK) + return false; =20 - err =3D ioremap_page_range(addr, addr + size, phys_addr, prot); - if (err) { - vunmap((void *)addr); - return NULL; - } + /* Don't allow RAM to be mapped. */ + if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(addr)))) + return false; =20 - return (void __iomem *)(offset + addr); -} - -void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot) -{ - return __ioremap_caller(phys_addr, size, prot, - __builtin_return_address(0)); + return true; } -EXPORT_SYMBOL(__ioremap); =20 -void iounmap(volatile void __iomem *io_addr) +bool arch_iounmap_check(void __iomem *addr) { - unsigned long addr =3D (unsigned long)io_addr & PAGE_MASK; - /* * We could get an address outside vmalloc range in case * of ioremap_cache() reusing a RAM mapping. */ - if (is_vmalloc_addr((void *)addr)) - vunmap((void *)addr); -} -EXPORT_SYMBOL(iounmap); - -void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size) -{ - /* For normal memory we already have a cacheable mapping. */ - if (pfn_is_map_memory(__phys_to_pfn(phys_addr))) - return (void __iomem *)__phys_to_virt(phys_addr); - - return __ioremap_caller(phys_addr, size, __pgprot(PROT_NORMAL), - __builtin_return_address(0)); + return is_vmalloc_addr(addr); } -EXPORT_SYMBOL(ioremap_cache); =20 /* * Must be called after early_fixmap_init --=20 2.26.2 From nobody Sun May 10 17:53:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4430C433EF for ; Wed, 27 Apr 2022 12:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233428AbiD0MFr (ORCPT ); Wed, 27 Apr 2022 08:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233461AbiD0MFd (ORCPT ); Wed, 27 Apr 2022 08:05:33 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2808E3B3CD for ; Wed, 27 Apr 2022 05:02:21 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KpHRY0LbgzhYpX; Wed, 27 Apr 2022 20:02:01 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:02:19 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 20:02:19 +0800 From: Kefeng Wang To: Catalin Marinas , Will Deacon , Andrew Morton , , CC: , Kefeng Wang Subject: [PATCH 4/4] arm64: Add HAVE_IOREMAP_PROT support Date: Wed, 27 Apr 2022 20:14:13 +0800 Message-ID: <20220427121413.168468-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220427121413.168468-1-wangkefeng.wang@huawei.com> References: <20220427121413.168468-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With ioremap_prot() defination from generic ioremap, also move pte_pgprot() from hugetlbpage.c into pgtable.h, then arm64 could have HAVE_IOREMAP_PROT, which will enable generic_access_phys() code. Signed-off-by: Kefeng Wang --- .../features/vm/ioremap_prot/arch-support.txt | 2 +- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/pgtable.h | 10 ++++++++++ arch/arm64/mm/hugetlbpage.c | 10 ---------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Documentation/features/vm/ioremap_prot/arch-support.txt b/Docu= mentation/features/vm/ioremap_prot/arch-support.txt index a6dcbe5f47b6..b39ad5d61216 100644 --- a/Documentation/features/vm/ioremap_prot/arch-support.txt +++ b/Documentation/features/vm/ioremap_prot/arch-support.txt @@ -9,7 +9,7 @@ | alpha: | TODO | | arc: | ok | | arm: | TODO | - | arm64: | TODO | + | arm64: | ok | | csky: | TODO | | h8300: | TODO | | hexagon: | TODO | diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 838c45f1517b..0357708c4d32 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -188,6 +188,7 @@ config ARM64 select HAVE_FUNCTION_GRAPH_TRACER select HAVE_GCC_PLUGINS select HAVE_HW_BREAKPOINT if PERF_EVENTS + select HAVE_IOREMAP_PROT select HAVE_IRQ_TIME_ACCOUNTING select HAVE_KVM select HAVE_NMI diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgta= ble.h index 94e147e5456c..4d8ae0b7f814 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -402,6 +402,16 @@ static inline pgprot_t mk_pmd_sect_prot(pgprot_t prot) return __pgprot((pgprot_val(prot) & ~PMD_TABLE_BIT) | PMD_TYPE_SECT); } =20 +/* + * Select all bits except the pfn + */ +static inline pgprot_t pte_pgprot(pte_t pte) +{ + unsigned long pfn =3D pte_pfn(pte); + + return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte)); +} + #ifdef CONFIG_NUMA_BALANCING /* * See the comment in include/linux/pgtable.h diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index cbace1c9e137..38d03406f6aa 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -100,16 +100,6 @@ int pud_huge(pud_t pud) #endif } =20 -/* - * Select all bits except the pfn - */ -static inline pgprot_t pte_pgprot(pte_t pte) -{ - unsigned long pfn =3D pte_pfn(pte); - - return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte)); -} - static int find_num_contig(struct mm_struct *mm, unsigned long addr, pte_t *ptep, size_t *pgsize) { --=20 2.26.2