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