brintos

brintos / linux-shallow public Read only

0
0
Text · 2.0 KiB · 8ffd64e Raw
74 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef _PGTABLE_NOPMD_H3#define _PGTABLE_NOPMD_H4 5#ifndef __ASSEMBLY__6 7#include <asm-generic/pgtable-nopud.h>8 9struct mm_struct;10 11#define __PAGETABLE_PMD_FOLDED 112 13/*14 * Having the pmd type consist of a pud gets the size right, and allows15 * us to conceptually access the pud entry that this pmd is folded into16 * without casting.17 */18typedef struct { pud_t pud; } pmd_t;19 20#define PMD_SHIFT	PUD_SHIFT21#define PTRS_PER_PMD	122#define PMD_SIZE  	(1UL << PMD_SHIFT)23#define PMD_MASK  	(~(PMD_SIZE-1))24 25/*26 * The "pud_xxx()" functions here are trivial for a folded two-level27 * setup: the pmd is never bad, and a pmd always exists (as it's folded28 * into the pud entry)29 */30static inline int pud_none(pud_t pud)		{ return 0; }31static inline int pud_bad(pud_t pud)		{ return 0; }32static inline int pud_present(pud_t pud)	{ return 1; }33static inline int pud_user(pud_t pud)		{ return 0; }34static inline int pud_leaf(pud_t pud)		{ return 0; }35static inline void pud_clear(pud_t *pud)	{ }36#define pmd_ERROR(pmd)				(pud_ERROR((pmd).pud))37 38#define pud_populate(mm, pmd, pte)		do { } while (0)39 40/*41 * (pmds are folded into puds so this doesn't get actually called,42 * but the define is needed for a generic inline function.)43 */44#define set_pud(pudptr, pudval)			set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })45 46static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)47{48	return (pmd_t *)pud;49}50#define pmd_offset pmd_offset51 52#define pmd_val(x)				(pud_val((x).pud))53#define __pmd(x)				((pmd_t) { __pud(x) } )54 55#define pud_page(pud)				(pmd_page((pmd_t){ pud }))56#define pud_pgtable(pud)			((pmd_t *)(pmd_page_vaddr((pmd_t){ pud })))57 58/*59 * allocating and freeing a pmd is trivial: the 1-entry pmd is60 * inside the pud, so has no extra memory associated with it.61 */62#define pmd_alloc_one(mm, address)		NULL63static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)64{65}66#define pmd_free_tlb(tlb, x, a)		do { } while (0)67 68#undef  pmd_addr_end69#define pmd_addr_end(addr, end)			(end)70 71#endif /* __ASSEMBLY__ */72 73#endif /* _PGTABLE_NOPMD_H */74