xref: /linux/include/asm-generic/pgtable-nop4d.h (revision fcc8487d477a3452a1d0ccbdd4c5e0e1e3cb8bed)
1 #ifndef _PGTABLE_NOP4D_H
2 #define _PGTABLE_NOP4D_H
3 
4 #ifndef __ASSEMBLY__
5 
6 #define __PAGETABLE_P4D_FOLDED
7 
8 typedef struct { pgd_t pgd; } p4d_t;
9 
10 #define P4D_SHIFT	PGDIR_SHIFT
11 #define PTRS_PER_P4D	1
12 #define P4D_SIZE	(1UL << P4D_SHIFT)
13 #define P4D_MASK	(~(P4D_SIZE-1))
14 
15 /*
16  * The "pgd_xxx()" functions here are trivial for a folded two-level
17  * setup: the p4d is never bad, and a p4d always exists (as it's folded
18  * into the pgd entry)
19  */
20 static inline int pgd_none(pgd_t pgd)		{ return 0; }
21 static inline int pgd_bad(pgd_t pgd)		{ return 0; }
22 static inline int pgd_present(pgd_t pgd)	{ return 1; }
23 static inline void pgd_clear(pgd_t *pgd)	{ }
24 #define p4d_ERROR(p4d)				(pgd_ERROR((p4d).pgd))
25 
26 #define pgd_populate(mm, pgd, p4d)		do { } while (0)
27 /*
28  * (p4ds are folded into pgds so this doesn't get actually called,
29  * but the define is needed for a generic inline function.)
30  */
31 #define set_pgd(pgdptr, pgdval)	set_p4d((p4d_t *)(pgdptr), (p4d_t) { pgdval })
32 
33 static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)
34 {
35 	return (p4d_t *)pgd;
36 }
37 
38 #define p4d_val(x)				(pgd_val((x).pgd))
39 #define __p4d(x)				((p4d_t) { __pgd(x) })
40 
41 #define pgd_page(pgd)				(p4d_page((p4d_t){ pgd }))
42 #define pgd_page_vaddr(pgd)			(p4d_page_vaddr((p4d_t){ pgd }))
43 
44 /*
45  * allocating and freeing a p4d is trivial: the 1-entry p4d is
46  * inside the pgd, so has no extra memory associated with it.
47  */
48 #define p4d_alloc_one(mm, address)		NULL
49 #define p4d_free(mm, x)				do { } while (0)
50 #define __p4d_free_tlb(tlb, x, a)		do { } while (0)
51 
52 #undef  p4d_addr_end
53 #define p4d_addr_end(addr, end)			(end)
54 
55 #endif /* __ASSEMBLY__ */
56 #endif /* _PGTABLE_NOP4D_H */
57