Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Kirill A. Shutemov | 048456d | 2017-03-09 17:24:06 +0300 | [diff] [blame] | 2 | #ifndef _PGTABLE_NOP4D_H |
| 3 | #define _PGTABLE_NOP4D_H |
| 4 | |
| 5 | #ifndef __ASSEMBLY__ |
| 6 | |
Martin Schwidefsky | a8874e7 | 2018-10-31 12:11:48 +0100 | [diff] [blame] | 7 | #define __PAGETABLE_P4D_FOLDED 1 |
Kirill A. Shutemov | 048456d | 2017-03-09 17:24:06 +0300 | [diff] [blame] | 8 | |
| 9 | typedef struct { pgd_t pgd; } p4d_t; |
| 10 | |
Kirill A. Shutemov | c65e774 | 2018-02-14 14:16:53 +0300 | [diff] [blame] | 11 | #define P4D_SHIFT PGDIR_SHIFT |
| 12 | #define MAX_PTRS_PER_P4D 1 |
| 13 | #define PTRS_PER_P4D 1 |
| 14 | #define P4D_SIZE (1UL << P4D_SHIFT) |
| 15 | #define P4D_MASK (~(P4D_SIZE-1)) |
Kirill A. Shutemov | 048456d | 2017-03-09 17:24:06 +0300 | [diff] [blame] | 16 | |
| 17 | /* |
| 18 | * The "pgd_xxx()" functions here are trivial for a folded two-level |
| 19 | * setup: the p4d is never bad, and a p4d always exists (as it's folded |
| 20 | * into the pgd entry) |
| 21 | */ |
| 22 | static inline int pgd_none(pgd_t pgd) { return 0; } |
| 23 | static inline int pgd_bad(pgd_t pgd) { return 0; } |
| 24 | static inline int pgd_present(pgd_t pgd) { return 1; } |
| 25 | static inline void pgd_clear(pgd_t *pgd) { } |
| 26 | #define p4d_ERROR(p4d) (pgd_ERROR((p4d).pgd)) |
| 27 | |
| 28 | #define pgd_populate(mm, pgd, p4d) do { } while (0) |
Dan Williams | 0a9fe8c | 2018-12-04 13:37:21 -0800 | [diff] [blame] | 29 | #define pgd_populate_safe(mm, pgd, p4d) do { } while (0) |
Kirill A. Shutemov | 048456d | 2017-03-09 17:24:06 +0300 | [diff] [blame] | 30 | /* |
| 31 | * (p4ds are folded into pgds so this doesn't get actually called, |
| 32 | * but the define is needed for a generic inline function.) |
| 33 | */ |
| 34 | #define set_pgd(pgdptr, pgdval) set_p4d((p4d_t *)(pgdptr), (p4d_t) { pgdval }) |
| 35 | |
| 36 | static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address) |
| 37 | { |
| 38 | return (p4d_t *)pgd; |
| 39 | } |
| 40 | |
| 41 | #define p4d_val(x) (pgd_val((x).pgd)) |
| 42 | #define __p4d(x) ((p4d_t) { __pgd(x) }) |
| 43 | |
| 44 | #define pgd_page(pgd) (p4d_page((p4d_t){ pgd })) |
| 45 | #define pgd_page_vaddr(pgd) (p4d_page_vaddr((p4d_t){ pgd })) |
| 46 | |
| 47 | /* |
| 48 | * allocating and freeing a p4d is trivial: the 1-entry p4d is |
| 49 | * inside the pgd, so has no extra memory associated with it. |
| 50 | */ |
| 51 | #define p4d_alloc_one(mm, address) NULL |
| 52 | #define p4d_free(mm, x) do { } while (0) |
| 53 | #define __p4d_free_tlb(tlb, x, a) do { } while (0) |
| 54 | |
| 55 | #undef p4d_addr_end |
| 56 | #define p4d_addr_end(addr, end) (end) |
| 57 | |
| 58 | #endif /* __ASSEMBLY__ */ |
| 59 | #endif /* _PGTABLE_NOP4D_H */ |