[RFC 1/8] arm64/mm: split out __create_pgd_mapping() routines

Pingfan Liu kernelfans at gmail.com
Wed Apr 14 14:19:51 BST 2021


On Sat, Apr 10, 2021 at 5:57 PM Pingfan Liu <kernelfans at gmail.com> wrote:
>
> Split out the routines for __create_pgd_mapping(), in order to use it
> to generate two sets of operations for CONFIG_PGTABLE_LEVELS and
> CONFIG_PGTABLE_LEVELS + 1
>
> Later the one generated with 'CONFIG_PGTABLE_LEVELS + 1' can be used for
> idmap if VA_BITS is too small to cover system RAM, which is located
> sufficiently high in the physical address space.
>
> Later, idmap can be created by __create_pgd_mapping() directly.
>
> Signed-off-by: Pingfan Liu <kernelfans at gmail.com>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Will Deacon <will at kernel.org>
> Cc: Marc Zyngier <maz at kernel.org>
> Cc: Kristina Martsenko <kristina.martsenko at arm.com>
> Cc: James Morse <james.morse at arm.com>
> Cc: Steven Price <steven.price at arm.com>
> Cc: Jonathan Cameron <Jonathan.Cameron at huawei.com>
> Cc: Pavel Tatashin <pasha.tatashin at soleen.com>
> Cc: Anshuman Khandual <anshuman.khandual at arm.com>
> Cc: Atish Patra <atish.patra at wdc.com>
> Cc: Mike Rapoport <rppt at kernel.org>
> Cc: Logan Gunthorpe <logang at deltatee.com>
> Cc: Mark Brown <broonie at kernel.org>
> To: linux-arm-kernel at lists.infradead.org
> ---
>  arch/arm64/Kconfig          |   4 +
>  arch/arm64/mm/Makefile      |   2 +
>  arch/arm64/mm/idmap_mmu.c   |  45 ++++++
>  arch/arm64/mm/mmu.c         | 263 +-----------------------------------
>  arch/arm64/mm/mmu_include.c | 262 +++++++++++++++++++++++++++++++++++
>  5 files changed, 315 insertions(+), 261 deletions(-)
>  create mode 100644 arch/arm64/mm/idmap_mmu.c
>  create mode 100644 arch/arm64/mm/mmu_include.c
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index e4e1b6550115..989fc501a1b4 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -327,6 +327,10 @@ config PGTABLE_LEVELS
>         default 3 if ARM64_16K_PAGES && ARM64_VA_BITS_47
>         default 4 if !ARM64_64K_PAGES && ARM64_VA_BITS_48
>
> +config IDMAP_PGTABLE_EXPAND
> +       def_bool y
> +       depends on (ARM64_4K_PAGES && ARM64_VA_BITS_39) || (ARM64_64K_PAGES && ARM64_VA_BITS_42)
> +
>  config ARCH_SUPPORTS_UPROBES
>         def_bool y
>
> diff --git a/arch/arm64/mm/Makefile b/arch/arm64/mm/Makefile
> index f188c9092696..f9283cb9a201 100644
> --- a/arch/arm64/mm/Makefile
> +++ b/arch/arm64/mm/Makefile
> @@ -3,6 +3,8 @@ obj-y                           := dma-mapping.o extable.o fault.o init.o \
>                                    cache.o copypage.o flush.o \
>                                    ioremap.o mmap.o pgd.o mmu.o \
>                                    context.o proc.o pageattr.o
> +
> +obj-$(CONFIG_IDMAP_PGTABLE_EXPAND)     += idmap_mmu.o
>  obj-$(CONFIG_HUGETLB_PAGE)     += hugetlbpage.o
>  obj-$(CONFIG_PTDUMP_CORE)      += ptdump.o
>  obj-$(CONFIG_PTDUMP_DEBUGFS)   += ptdump_debugfs.o
> diff --git a/arch/arm64/mm/idmap_mmu.c b/arch/arm64/mm/idmap_mmu.c
> new file mode 100644
> index 000000000000..7e9a4f4017d3
> --- /dev/null
> +++ b/arch/arm64/mm/idmap_mmu.c
> @@ -0,0 +1,45 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <linux/kernel.h>
> +#include <linux/errno.h>
> +#include <linux/mm.h>
> +
> +#include <asm/barrier.h>
> +#include <asm/cputype.h>
> +#include <asm/fixmap.h>
> +#include <asm/kasan.h>
> +#include <asm/kernel-pgtable.h>
> +#include <asm/sections.h>
> +#include <asm/setup.h>
> +#include <linux/sizes.h>
> +#include <asm/tlb.h>
> +#include <asm/mmu_context.h>
> +#include <asm/ptdump.h>
> +#include <asm/tlbflush.h>
> +#include <asm/pgalloc.h>
> +
> +#if CONFIG_IDMAP_PGTABLE_EXPAND
> +
> +#if CONFIG_PGTABLE_LEVELS == 2
> +#define EXTEND_LEVEL 3
> +#elif CONFIG_PGTABLE_LEVELS == 3
> +#define EXTEND_LEVEL 4
> +#endif
> +
> +#undef CONFIG_PGTABLE_LEVELS
> +#define CONFIG_PGTABLE_LEVELS EXTEND_LEVEL

In order to take effect, the redefinition of CONFIG_PGTABLE_LEVELS
should be moved to the head of this file.

I will fix it in V2.

Thanks,
Pingfan



More information about the linux-arm-kernel mailing list