pgtable-nopmd.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _PGTABLE_NOPMD_H
  3. #define _PGTABLE_NOPMD_H
  4. #ifndef __ASSEMBLY__
  5. #include <asm-generic/pgtable-nopud.h>
  6. struct mm_struct;
  7. #define __PAGETABLE_PMD_FOLDED
  8. /*
  9. * Having the pmd type consist of a pud gets the size right, and allows
  10. * us to conceptually access the pud entry that this pmd is folded into
  11. * without casting.
  12. */
  13. typedef struct { pud_t pud; } pmd_t;
  14. #define PMD_SHIFT PUD_SHIFT
  15. #define PTRS_PER_PMD 1
  16. #define PMD_SIZE (1UL << PMD_SHIFT)
  17. #define PMD_MASK (~(PMD_SIZE-1))
  18. /*
  19. * The "pud_xxx()" functions here are trivial for a folded two-level
  20. * setup: the pmd is never bad, and a pmd always exists (as it's folded
  21. * into the pud entry)
  22. */
  23. static inline int pud_none(pud_t pud) { return 0; }
  24. static inline int pud_bad(pud_t pud) { return 0; }
  25. static inline int pud_present(pud_t pud) { return 1; }
  26. static inline void pud_clear(pud_t *pud) { }
  27. #define pmd_ERROR(pmd) (pud_ERROR((pmd).pud))
  28. #define pud_populate(mm, pmd, pte) do { } while (0)
  29. /*
  30. * (pmds are folded into puds so this doesn't get actually called,
  31. * but the define is needed for a generic inline function.)
  32. */
  33. #define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
  34. static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
  35. {
  36. return (pmd_t *)pud;
  37. }
  38. #define pmd_val(x) (pud_val((x).pud))
  39. #define __pmd(x) ((pmd_t) { __pud(x) } )
  40. #define pud_page(pud) (pmd_page((pmd_t){ pud }))
  41. #define pud_page_vaddr(pud) (pmd_page_vaddr((pmd_t){ pud }))
  42. /*
  43. * allocating and freeing a pmd is trivial: the 1-entry pmd is
  44. * inside the pud, so has no extra memory associated with it.
  45. */
  46. #define pmd_alloc_one(mm, address) NULL
  47. static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
  48. {
  49. }
  50. #define __pmd_free_tlb(tlb, x, a) do { } while (0)
  51. #undef pmd_addr_end
  52. #define pmd_addr_end(addr, end) (end)
  53. #endif /* __ASSEMBLY__ */
  54. #endif /* _PGTABLE_NOPMD_H */