Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64/mm: define ptdesc_t

Define ptdesc_t type which describes the basic page table descriptor
layout on arm64 platform. Subsequently all level specific pxxval_t
descriptors are derived from ptdesc_t thus establishing a common original
format, which can also be appropriate for page table entries, masks and
protection values etc which are used at all page table levels.

Link: https://lkml.kernel.org/r/20250407053113.746295-4-anshuman.khandual@arm.com
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Suggested-by: Ryan Roberts <ryan.roberts@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Anshuman Khandual and committed by
Andrew Morton
dbb9c166 08978fc3

+26 -18
+14 -6
arch/arm64/include/asm/pgtable-types.h
··· 11 11 12 12 #include <asm/types.h> 13 13 14 - typedef u64 pteval_t; 15 - typedef u64 pmdval_t; 16 - typedef u64 pudval_t; 17 - typedef u64 p4dval_t; 18 - typedef u64 pgdval_t; 14 + /* 15 + * Page Table Descriptor 16 + * 17 + * Generic page table descriptor format from which 18 + * all level specific descriptors can be derived. 19 + */ 20 + typedef u64 ptdesc_t; 21 + 22 + typedef ptdesc_t pteval_t; 23 + typedef ptdesc_t pmdval_t; 24 + typedef ptdesc_t pudval_t; 25 + typedef ptdesc_t p4dval_t; 26 + typedef ptdesc_t pgdval_t; 19 27 20 28 /* 21 29 * These are used to make use of C type-checking.. ··· 54 46 #define pgd_val(x) ((x).pgd) 55 47 #define __pgd(x) ((pgd_t) { (x) } ) 56 48 57 - typedef struct { pteval_t pgprot; } pgprot_t; 49 + typedef struct { ptdesc_t pgprot; } pgprot_t; 58 50 #define pgprot_val(x) ((x).pgprot) 59 51 #define __pgprot(x) ((pgprot_t) { (x) } ) 60 52
+4 -4
arch/arm64/include/asm/ptdump.h
··· 24 24 }; 25 25 26 26 struct ptdump_prot_bits { 27 - u64 mask; 28 - u64 val; 27 + ptdesc_t mask; 28 + ptdesc_t val; 29 29 const char *set; 30 30 const char *clear; 31 31 }; ··· 34 34 const struct ptdump_prot_bits *bits; 35 35 char name[4]; 36 36 int num; 37 - u64 mask; 37 + ptdesc_t mask; 38 38 }; 39 39 40 40 /* ··· 51 51 const struct mm_struct *mm; 52 52 unsigned long start_address; 53 53 int level; 54 - u64 current_prot; 54 + ptdesc_t current_prot; 55 55 bool check_wx; 56 56 unsigned long wx_pages; 57 57 unsigned long uxn_pages;
+2 -2
arch/arm64/kernel/efi.c
··· 29 29 * executable, everything else can be mapped with the XN bits 30 30 * set. Also take the new (optional) RO/XP bits into account. 31 31 */ 32 - static __init pteval_t create_mapping_protection(efi_memory_desc_t *md) 32 + static __init ptdesc_t create_mapping_protection(efi_memory_desc_t *md) 33 33 { 34 34 u64 attr = md->attribute; 35 35 u32 type = md->type; ··· 83 83 84 84 int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) 85 85 { 86 - pteval_t prot_val = create_mapping_protection(md); 86 + ptdesc_t prot_val = create_mapping_protection(md); 87 87 bool page_mappings_only = (md->type == EFI_RUNTIME_SERVICES_CODE || 88 88 md->type == EFI_RUNTIME_SERVICES_DATA); 89 89
+1 -1
arch/arm64/kernel/pi/map_kernel.c
··· 159 159 static void __init remap_idmap_for_lpa2(void) 160 160 { 161 161 /* clear the bits that change meaning once LPA2 is turned on */ 162 - pteval_t mask = PTE_SHARED; 162 + ptdesc_t mask = PTE_SHARED; 163 163 164 164 /* 165 165 * We have to clear bits [9:8] in all block or page descriptors in the
+2 -2
arch/arm64/kernel/pi/map_range.c
··· 30 30 int level, pte_t *tbl, bool may_use_cont, u64 va_offset) 31 31 { 32 32 u64 cmask = (level == 3) ? CONT_PTE_SIZE - 1 : U64_MAX; 33 - pteval_t protval = pgprot_val(prot) & ~PTE_TYPE_MASK; 33 + ptdesc_t protval = pgprot_val(prot) & ~PTE_TYPE_MASK; 34 34 int lshift = (3 - level) * PTDESC_TABLE_SHIFT; 35 35 u64 lmask = (PAGE_SIZE << lshift) - 1; 36 36 ··· 87 87 } 88 88 } 89 89 90 - asmlinkage u64 __init create_init_idmap(pgd_t *pg_dir, pteval_t clrmask) 90 + asmlinkage u64 __init create_init_idmap(pgd_t *pg_dir, ptdesc_t clrmask) 91 91 { 92 92 u64 ptep = (u64)pg_dir + PAGE_SIZE; 93 93 pgprot_t text_prot = PAGE_KERNEL_ROX;
+1 -1
arch/arm64/kernel/pi/pi.h
··· 33 33 34 34 asmlinkage void early_map_kernel(u64 boot_status, void *fdt); 35 35 36 - asmlinkage u64 create_init_idmap(pgd_t *pgd, pteval_t clrmask); 36 + asmlinkage u64 create_init_idmap(pgd_t *pgd, ptdesc_t clrmask);
+1 -1
arch/arm64/mm/mmap.c
··· 83 83 84 84 pgprot_t vm_get_page_prot(unsigned long vm_flags) 85 85 { 86 - pteval_t prot; 86 + ptdesc_t prot; 87 87 88 88 /* Short circuit GCS to avoid bloating the table. */ 89 89 if (system_supports_gcs() && (vm_flags & VM_SHADOW_STACK)) {
+1 -1
arch/arm64/mm/ptdump.c
··· 194 194 struct ptdump_pg_state *st = container_of(pt_st, struct ptdump_pg_state, ptdump); 195 195 struct ptdump_pg_level *pg_level = st->pg_level; 196 196 static const char units[] = "KMGTPE"; 197 - u64 prot = 0; 197 + ptdesc_t prot = 0; 198 198 199 199 /* check if the current level has been folded dynamically */ 200 200 if (st->mm && ((level == 1 && mm_p4d_folded(st->mm)) ||