18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _PGTABLE_NOP4D_H
38c2ecf20Sopenharmony_ci#define _PGTABLE_NOP4D_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#define __PAGETABLE_P4D_FOLDED 1
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_citypedef struct { pgd_t pgd; } p4d_t;
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define P4D_SHIFT		PGDIR_SHIFT
128c2ecf20Sopenharmony_ci#define MAX_PTRS_PER_P4D	1
138c2ecf20Sopenharmony_ci#define PTRS_PER_P4D		1
148c2ecf20Sopenharmony_ci#define P4D_SIZE		(1UL << P4D_SHIFT)
158c2ecf20Sopenharmony_ci#define P4D_MASK		(~(P4D_SIZE-1))
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/*
188c2ecf20Sopenharmony_ci * The "pgd_xxx()" functions here are trivial for a folded two-level
198c2ecf20Sopenharmony_ci * setup: the p4d is never bad, and a p4d always exists (as it's folded
208c2ecf20Sopenharmony_ci * into the pgd entry)
218c2ecf20Sopenharmony_ci */
228c2ecf20Sopenharmony_cistatic inline int pgd_none(pgd_t pgd)		{ return 0; }
238c2ecf20Sopenharmony_cistatic inline int pgd_bad(pgd_t pgd)		{ return 0; }
248c2ecf20Sopenharmony_cistatic inline int pgd_present(pgd_t pgd)	{ return 1; }
258c2ecf20Sopenharmony_cistatic inline void pgd_clear(pgd_t *pgd)	{ }
268c2ecf20Sopenharmony_ci#define p4d_ERROR(p4d)				(pgd_ERROR((p4d).pgd))
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define pgd_populate(mm, pgd, p4d)		do { } while (0)
298c2ecf20Sopenharmony_ci#define pgd_populate_safe(mm, pgd, p4d)		do { } while (0)
308c2ecf20Sopenharmony_ci/*
318c2ecf20Sopenharmony_ci * (p4ds are folded into pgds so this doesn't get actually called,
328c2ecf20Sopenharmony_ci * but the define is needed for a generic inline function.)
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci#define set_pgd(pgdptr, pgdval)	set_p4d((p4d_t *)(pgdptr), (p4d_t) { pgdval })
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistatic inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)
378c2ecf20Sopenharmony_ci{
388c2ecf20Sopenharmony_ci	return (p4d_t *)pgd;
398c2ecf20Sopenharmony_ci}
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define p4d_val(x)				(pgd_val((x).pgd))
428c2ecf20Sopenharmony_ci#define __p4d(x)				((p4d_t) { __pgd(x) })
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define pgd_page(pgd)				(p4d_page((p4d_t){ pgd }))
458c2ecf20Sopenharmony_ci#define pgd_page_vaddr(pgd)			((unsigned long)(p4d_pgtable((p4d_t){ pgd })))
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci/*
488c2ecf20Sopenharmony_ci * allocating and freeing a p4d is trivial: the 1-entry p4d is
498c2ecf20Sopenharmony_ci * inside the pgd, so has no extra memory associated with it.
508c2ecf20Sopenharmony_ci */
518c2ecf20Sopenharmony_ci#define p4d_alloc_one(mm, address)		NULL
528c2ecf20Sopenharmony_ci#define p4d_free(mm, x)				do { } while (0)
538c2ecf20Sopenharmony_ci#define p4d_free_tlb(tlb, x, a)			do { } while (0)
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#undef  p4d_addr_end
568c2ecf20Sopenharmony_ci#define p4d_addr_end(addr, end)			(end)
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
598c2ecf20Sopenharmony_ci#endif /* _PGTABLE_NOP4D_H */
60