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