18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _PGTABLE_NOPUD_H
38c2ecf20Sopenharmony_ci#define _PGTABLE_NOPUD_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <asm-generic/pgtable-nop4d.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define __PAGETABLE_PUD_FOLDED 1
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/*
128c2ecf20Sopenharmony_ci * Having the pud type consist of a p4d gets the size right, and allows
138c2ecf20Sopenharmony_ci * us to conceptually access the p4d entry that this pud is folded into
148c2ecf20Sopenharmony_ci * without casting.
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_citypedef struct { p4d_t p4d; } pud_t;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define PUD_SHIFT	P4D_SHIFT
198c2ecf20Sopenharmony_ci#define PTRS_PER_PUD	1
208c2ecf20Sopenharmony_ci#define PUD_SIZE  	(1UL << PUD_SHIFT)
218c2ecf20Sopenharmony_ci#define PUD_MASK  	(~(PUD_SIZE-1))
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/*
248c2ecf20Sopenharmony_ci * The "p4d_xxx()" functions here are trivial for a folded two-level
258c2ecf20Sopenharmony_ci * setup: the pud is never bad, and a pud always exists (as it's folded
268c2ecf20Sopenharmony_ci * into the p4d entry)
278c2ecf20Sopenharmony_ci */
288c2ecf20Sopenharmony_cistatic inline int p4d_none(p4d_t p4d)		{ return 0; }
298c2ecf20Sopenharmony_cistatic inline int p4d_bad(p4d_t p4d)		{ return 0; }
308c2ecf20Sopenharmony_cistatic inline int p4d_present(p4d_t p4d)	{ return 1; }
318c2ecf20Sopenharmony_cistatic inline void p4d_clear(p4d_t *p4d)	{ }
328c2ecf20Sopenharmony_ci#define pud_ERROR(pud)				(p4d_ERROR((pud).p4d))
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define p4d_populate(mm, p4d, pud)		do { } while (0)
358c2ecf20Sopenharmony_ci#define p4d_populate_safe(mm, p4d, pud)		do { } while (0)
368c2ecf20Sopenharmony_ci/*
378c2ecf20Sopenharmony_ci * (puds are folded into p4ds so this doesn't get actually called,
388c2ecf20Sopenharmony_ci * but the define is needed for a generic inline function.)
398c2ecf20Sopenharmony_ci */
408c2ecf20Sopenharmony_ci#define set_p4d(p4dptr, p4dval)	set_pud((pud_t *)(p4dptr), (pud_t) { p4dval })
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistatic inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
438c2ecf20Sopenharmony_ci{
448c2ecf20Sopenharmony_ci	return (pud_t *)p4d;
458c2ecf20Sopenharmony_ci}
468c2ecf20Sopenharmony_ci#define pud_offset pud_offset
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define pud_val(x)				(p4d_val((x).p4d))
498c2ecf20Sopenharmony_ci#define __pud(x)				((pud_t) { __p4d(x) })
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define p4d_page(p4d)				(pud_page((pud_t){ p4d }))
528c2ecf20Sopenharmony_ci#define p4d_pgtable(p4d)			((pud_t *)(pud_pgtable((pud_t){ p4d })))
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/*
558c2ecf20Sopenharmony_ci * allocating and freeing a pud is trivial: the 1-entry pud is
568c2ecf20Sopenharmony_ci * inside the p4d, so has no extra memory associated with it.
578c2ecf20Sopenharmony_ci */
588c2ecf20Sopenharmony_ci#define pud_alloc_one(mm, address)		NULL
598c2ecf20Sopenharmony_ci#define pud_free(mm, x)				do { } while (0)
608c2ecf20Sopenharmony_ci#define pud_free_tlb(tlb, x, a)		        do { } while (0)
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#undef  pud_addr_end
638c2ecf20Sopenharmony_ci#define pud_addr_end(addr, end)			(end)
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
668c2ecf20Sopenharmony_ci#endif /* _PGTABLE_NOPUD_H */
67