blob: d3776cb494c0b3eb9c82dadf46a8d6e8f8452a0c [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _PGTABLE_NOPUD_H
3#define _PGTABLE_NOPUD_H
4
5#ifndef __ASSEMBLY__
6
Kirill A. Shutemov30ec8422017-03-09 17:24:04 +03007#ifdef __ARCH_USE_5LEVEL_HACK
8#include <asm-generic/pgtable-nop4d-hack.h>
9#else
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030010#include <asm-generic/pgtable-nop4d.h>
Kirill A. Shutemov30ec8422017-03-09 17:24:04 +030011
Martin Schwidefskya8874e72018-10-31 12:11:48 +010012#define __PAGETABLE_PUD_FOLDED 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14/*
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030015 * Having the pud type consist of a p4d gets the size right, and allows
16 * us to conceptually access the p4d entry that this pud is folded into
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 * without casting.
18 */
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030019typedef struct { p4d_t p4d; } pud_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030021#define PUD_SHIFT P4D_SHIFT
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#define PTRS_PER_PUD 1
23#define PUD_SIZE (1UL << PUD_SHIFT)
24#define PUD_MASK (~(PUD_SIZE-1))
25
26/*
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030027 * The "p4d_xxx()" functions here are trivial for a folded two-level
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 * setup: the pud is never bad, and a pud always exists (as it's folded
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030029 * into the p4d entry)
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 */
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030031static inline int p4d_none(p4d_t p4d) { return 0; }
32static inline int p4d_bad(p4d_t p4d) { return 0; }
33static inline int p4d_present(p4d_t p4d) { return 1; }
34static inline void p4d_clear(p4d_t *p4d) { }
35#define pud_ERROR(pud) (p4d_ERROR((pud).p4d))
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030037#define p4d_populate(mm, p4d, pud) do { } while (0)
Dan Williams0a9fe8c2018-12-04 13:37:21 -080038#define p4d_populate_safe(mm, p4d, pud) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039/*
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030040 * (puds are folded into p4ds so this doesn't get actually called,
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 * but the define is needed for a generic inline function.)
42 */
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030043#define set_p4d(p4dptr, p4dval) set_pud((pud_t *)(p4dptr), (pud_t) { p4dval })
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030045static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070046{
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030047 return (pud_t *)p4d;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048}
49
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030050#define pud_val(x) (p4d_val((x).p4d))
51#define __pud(x) ((pud_t) { __p4d(x) })
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030053#define p4d_page(p4d) (pud_page((pud_t){ p4d }))
54#define p4d_page_vaddr(p4d) (pud_page_vaddr((pud_t){ p4d }))
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56/*
57 * allocating and freeing a pud is trivial: the 1-entry pud is
Kirill A. Shutemov048456d2017-03-09 17:24:06 +030058 * inside the p4d, so has no extra memory associated with it.
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 */
60#define pud_alloc_one(mm, address) NULL
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080061#define pud_free(mm, x) do { } while (0)
Vineet Guptab08861d2019-11-30 17:51:10 -080062#define pud_free_tlb(tlb, x, a) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64#undef pud_addr_end
65#define pud_addr_end(addr, end) (end)
66
67#endif /* __ASSEMBLY__ */
Kirill A. Shutemov30ec8422017-03-09 17:24:04 +030068#endif /* !__ARCH_USE_5LEVEL_HACK */
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#endif /* _PGTABLE_NOPUD_H */