blob: f6947da70d715fc7fdd6d67fd7845ac0d1d4b23f [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Kirill A. Shutemov505a60e2017-03-09 17:24:03 +03002#ifndef _5LEVEL_FIXUP_H
3#define _5LEVEL_FIXUP_H
4
5#define __ARCH_HAS_5LEVEL_HACK
Martin Schwidefskya8874e72018-10-31 12:11:48 +01006#define __PAGETABLE_P4D_FOLDED 1
Kirill A. Shutemov505a60e2017-03-09 17:24:03 +03007
8#define P4D_SHIFT PGDIR_SHIFT
9#define P4D_SIZE PGDIR_SIZE
10#define P4D_MASK PGDIR_MASK
Kirill A. Shutemovc65e7742018-02-14 14:16:53 +030011#define MAX_PTRS_PER_P4D 1
Kirill A. Shutemov505a60e2017-03-09 17:24:03 +030012#define PTRS_PER_P4D 1
13
14#define p4d_t pgd_t
15
16#define pud_alloc(mm, p4d, address) \
17 ((unlikely(pgd_none(*(p4d))) && __pud_alloc(mm, p4d, address)) ? \
18 NULL : pud_offset(p4d, address))
19
20#define p4d_alloc(mm, pgd, address) (pgd)
21#define p4d_offset(pgd, start) (pgd)
Qian Cai0cfaee22019-08-13 15:37:47 -070022
23#ifndef __ASSEMBLY__
24static inline int p4d_none(p4d_t p4d)
25{
26 return 0;
27}
28
29static inline int p4d_bad(p4d_t p4d)
30{
31 return 0;
32}
33
34static inline int p4d_present(p4d_t p4d)
35{
36 return 1;
37}
38#endif
39
Kirill A. Shutemov505a60e2017-03-09 17:24:03 +030040#define p4d_ERROR(p4d) do { } while (0)
41#define p4d_clear(p4d) pgd_clear(p4d)
42#define p4d_val(p4d) pgd_val(p4d)
43#define p4d_populate(mm, p4d, pud) pgd_populate(mm, p4d, pud)
Dan Williams0a9fe8c2018-12-04 13:37:21 -080044#define p4d_populate_safe(mm, p4d, pud) pgd_populate(mm, p4d, pud)
Kirill A. Shutemov505a60e2017-03-09 17:24:03 +030045#define p4d_page(p4d) pgd_page(p4d)
46#define p4d_page_vaddr(p4d) pgd_page_vaddr(p4d)
47
48#define __p4d(x) __pgd(x)
49#define set_p4d(p4dp, p4d) set_pgd(p4dp, p4d)
50
51#undef p4d_free_tlb
52#define p4d_free_tlb(tlb, x, addr) do { } while (0)
53#define p4d_free(mm, x) do { } while (0)
54#define __p4d_free_tlb(tlb, x, addr) do { } while (0)
55
56#undef p4d_addr_end
57#define p4d_addr_end(addr, end) (end)
58
59#endif