pgtable-nop4d.h 1.7 KB

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