Re: [PATCH v2 01/13] arm64: mm: Add p?d_large() definitions

From: Mark Rutland
Date: Thu Feb 21 2019 - 08:52:09 EST


On Thu, Feb 21, 2019 at 11:34:50AM +0000, Steven Price wrote:
> From: James Morse <james.morse@xxxxxxx>
>
> Exposing the pud/pgd levels of the page tables to walk_page_range() means
> we may come across the exotic large mappings that come with large areas
> of contiguous memory (such as the kernel's linear map).
>
> Expose p?d_large() from each architecture to detect these large mappings.
>
> arm64 already has these macros defined, but with a different name.
> p?d_large() is used by s390, sparc and x86. Only arm/arm64 use p?d_sect().
> Add a macro to allow both names.

So that we can avoid conflciting terminology, could we reword this as:

A generic walk_page_range() needs to handle exotic leaf entries at
arbitrary depths in the page tables (e.g. section mappings in the
kernel's linear map, or huge pages in userspace page tables).

Currently there is no generic API to detect such entries, but s390,
sparc, and x86 have all aligned on p?d_large(). Let's implement the same
for arm64 atop of p?d_cont().

With that:

Acked-by: Mark Rutland <mark.rutland@xxxxxxx>

Thanks,
Mark.

>
> Signed-off-by: James Morse <james.morse@xxxxxxx>
> Signed-off-by: Steven Price <steven.price@xxxxxxx>
> ---
> arch/arm64/include/asm/pgtable.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index de70c1eabf33..09d308921625 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -428,6 +428,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
> PMD_TYPE_TABLE)
> #define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \
> PMD_TYPE_SECT)
> +#define pmd_large(x) pmd_sect(x)
>
> #if defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS < 3
> #define pud_sect(pud) (0)
> @@ -435,6 +436,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
> #else
> #define pud_sect(pud) ((pud_val(pud) & PUD_TYPE_MASK) == \
> PUD_TYPE_SECT)
> +#define pud_large(x) pud_sect(x)
> #define pud_table(pud) ((pud_val(pud) & PUD_TYPE_MASK) == \
> PUD_TYPE_TABLE)
> #endif
> --
> 2.20.1
>