blob: 5e49430a30a404bbdb09f87a863065b836f2fe6b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _PGTABLE_NOPUD_H
2#define _PGTABLE_NOPUD_H
3
4#ifndef __ASSEMBLY__
5
Kirill A. Shutemov30ec8422017-03-09 17:24:04 +03006#ifdef __ARCH_USE_5LEVEL_HACK
7#include <asm-generic/pgtable-nop4d-hack.h>
8#else
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#define __PAGETABLE_PUD_FOLDED
11
12/*
13 * Having the pud type consist of a pgd gets the size right, and allows
14 * us to conceptually access the pgd entry that this pud is folded into
15 * without casting.
16 */
17typedef struct { pgd_t pgd; } pud_t;
18
19#define PUD_SHIFT PGDIR_SHIFT
20#define PTRS_PER_PUD 1
21#define PUD_SIZE (1UL << PUD_SHIFT)
22#define PUD_MASK (~(PUD_SIZE-1))
23
24/*
25 * The "pgd_xxx()" functions here are trivial for a folded two-level
26 * setup: the pud is never bad, and a pud always exists (as it's folded
27 * into the pgd entry)
28 */
29static inline int pgd_none(pgd_t pgd) { return 0; }
30static inline int pgd_bad(pgd_t pgd) { return 0; }
31static inline int pgd_present(pgd_t pgd) { return 1; }
32static inline void pgd_clear(pgd_t *pgd) { }
33#define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
34
35#define pgd_populate(mm, pgd, pud) do { } while (0)
36/*
37 * (puds are folded into pgds so this doesn't get actually called,
38 * but the define is needed for a generic inline function.)
39 */
40#define set_pgd(pgdptr, pgdval) set_pud((pud_t *)(pgdptr), (pud_t) { pgdval })
41
42static inline pud_t * pud_offset(pgd_t * pgd, unsigned long address)
43{
44 return (pud_t *)pgd;
45}
46
47#define pud_val(x) (pgd_val((x).pgd))
48#define __pud(x) ((pud_t) { __pgd(x) } )
49
50#define pgd_page(pgd) (pud_page((pud_t){ pgd }))
Dave McCracken46a82b22006-09-25 23:31:48 -070051#define pgd_page_vaddr(pgd) (pud_page_vaddr((pud_t){ pgd }))
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53/*
54 * allocating and freeing a pud is trivial: the 1-entry pud is
55 * inside the pgd, so has no extra memory associated with it.
56 */
57#define pud_alloc_one(mm, address) NULL
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080058#define pud_free(mm, x) do { } while (0)
Benjamin Herrenschmidt9e1b32c2009-07-22 15:44:28 +100059#define __pud_free_tlb(tlb, x, a) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61#undef pud_addr_end
62#define pud_addr_end(addr, end) (end)
63
64#endif /* __ASSEMBLY__ */
Kirill A. Shutemov30ec8422017-03-09 17:24:04 +030065#endif /* !__ARCH_USE_5LEVEL_HACK */
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#endif /* _PGTABLE_NOPUD_H */