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. /*
  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) (p4d_page_vaddr((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 */