162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _PGTABLE_NOP4D_H 362306a36Sopenharmony_ci#define _PGTABLE_NOP4D_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#define __PAGETABLE_P4D_FOLDED 1 862306a36Sopenharmony_ci 962306a36Sopenharmony_citypedef struct { pgd_t pgd; } p4d_t; 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define P4D_SHIFT PGDIR_SHIFT 1262306a36Sopenharmony_ci#define PTRS_PER_P4D 1 1362306a36Sopenharmony_ci#define P4D_SIZE (1UL << P4D_SHIFT) 1462306a36Sopenharmony_ci#define P4D_MASK (~(P4D_SIZE-1)) 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* 1762306a36Sopenharmony_ci * The "pgd_xxx()" functions here are trivial for a folded two-level 1862306a36Sopenharmony_ci * setup: the p4d is never bad, and a p4d always exists (as it's folded 1962306a36Sopenharmony_ci * into the pgd entry) 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_cistatic inline int pgd_none(pgd_t pgd) { return 0; } 2262306a36Sopenharmony_cistatic inline int pgd_bad(pgd_t pgd) { return 0; } 2362306a36Sopenharmony_cistatic inline int pgd_present(pgd_t pgd) { return 1; } 2462306a36Sopenharmony_cistatic inline void pgd_clear(pgd_t *pgd) { } 2562306a36Sopenharmony_ci#define p4d_ERROR(p4d) (pgd_ERROR((p4d).pgd)) 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define pgd_populate(mm, pgd, p4d) do { } while (0) 2862306a36Sopenharmony_ci#define pgd_populate_safe(mm, pgd, p4d) do { } while (0) 2962306a36Sopenharmony_ci/* 3062306a36Sopenharmony_ci * (p4ds are folded into pgds so this doesn't get actually called, 3162306a36Sopenharmony_ci * but the define is needed for a generic inline function.) 3262306a36Sopenharmony_ci */ 3362306a36Sopenharmony_ci#define set_pgd(pgdptr, pgdval) set_p4d((p4d_t *)(pgdptr), (p4d_t) { pgdval }) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_cistatic inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address) 3662306a36Sopenharmony_ci{ 3762306a36Sopenharmony_ci return (p4d_t *)pgd; 3862306a36Sopenharmony_ci} 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci#define p4d_val(x) (pgd_val((x).pgd)) 4162306a36Sopenharmony_ci#define __p4d(x) ((p4d_t) { __pgd(x) }) 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define pgd_page(pgd) (p4d_page((p4d_t){ pgd })) 4462306a36Sopenharmony_ci#define pgd_page_vaddr(pgd) ((unsigned long)(p4d_pgtable((p4d_t){ pgd }))) 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci/* 4762306a36Sopenharmony_ci * allocating and freeing a p4d is trivial: the 1-entry p4d is 4862306a36Sopenharmony_ci * inside the pgd, so has no extra memory associated with it. 4962306a36Sopenharmony_ci */ 5062306a36Sopenharmony_ci#define p4d_alloc_one(mm, address) NULL 5162306a36Sopenharmony_ci#define p4d_free(mm, x) do { } while (0) 5262306a36Sopenharmony_ci#define p4d_free_tlb(tlb, x, a) do { } while (0) 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#undef p4d_addr_end 5562306a36Sopenharmony_ci#define p4d_addr_end(addr, end) (end) 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */ 5862306a36Sopenharmony_ci#endif /* _PGTABLE_NOP4D_H */ 59