pgtable-nopmd.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 1
  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 int pud_user(pud_t pud) { return 0; }
  27. static inline int pud_leaf(pud_t pud) { return 0; }
  28. static inline void pud_clear(pud_t *pud) { }
  29. #define pmd_ERROR(pmd) (pud_ERROR((pmd).pud))
  30. #define pud_populate(mm, pmd, pte) do { } while (0)
  31. /*
  32. * (pmds are folded into puds so this doesn't get actually called,
  33. * but the define is needed for a generic inline function.)
  34. */
  35. #define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
  36. static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
  37. {
  38. return (pmd_t *)pud;
  39. }
  40. #define pmd_offset pmd_offset
  41. #define pmd_val(x) (pud_val((x).pud))
  42. #define __pmd(x) ((pmd_t) { __pud(x) } )
  43. #define pud_page(pud) (pmd_page((pmd_t){ pud }))
  44. #define pud_pgtable(pud) ((pmd_t *)(pmd_page_vaddr((pmd_t){ pud })))
  45. /*
  46. * allocating and freeing a pmd is trivial: the 1-entry pmd is
  47. * inside the pud, so has no extra memory associated with it.
  48. */
  49. #define pmd_alloc_one(mm, address) NULL
  50. static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
  51. {
  52. }
  53. #define pmd_free_tlb(tlb, x, a) do { } while (0)
  54. #undef pmd_addr_end
  55. #define pmd_addr_end(addr, end) (end)
  56. #endif /* __ASSEMBLY__ */
  57. #endif /* _PGTABLE_NOPMD_H */