pgtable-nop4d.h 1.7 KB

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