blob: 3e13acd019aefc2fdbc9f2aede12a31e52c83b77 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _PGTABLE_NOPMD_H
3#define _PGTABLE_NOPMD_H
4
5#ifndef __ASSEMBLY__
6
7#include <asm-generic/pgtable-nopud.h>
8
Andrew Morton34ee55012008-07-28 15:46:40 -07009struct mm_struct;
10
Martin Schwidefskya8874e72018-10-31 12:11:48 +010011#define __PAGETABLE_PMD_FOLDED 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13/*
14 * Having the pmd type consist of a pud gets the size right, and allows
15 * us to conceptually access the pud entry that this pmd is folded into
16 * without casting.
17 */
18typedef struct { pud_t pud; } pmd_t;
19
20#define PMD_SHIFT PUD_SHIFT
21#define PTRS_PER_PMD 1
22#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-level
27 * setup: the pmd is never bad, and a pmd always exists (as it's folded
28 * 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 void pud_clear(pud_t *pud) { }
34#define pmd_ERROR(pmd) (pud_ERROR((pmd).pud))
35
36#define pud_populate(mm, pmd, pte) do { } while (0)
37
38/*
39 * (pmds are folded into puds so this doesn't get actually called,
40 * but the define is needed for a generic inline function.)
41 */
42#define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
43
44static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
45{
46 return (pmd_t *)pud;
47}
Mike Rapoport974b9b22020-06-08 21:33:10 -070048#define pmd_offset pmd_offset
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#define pmd_val(x) (pud_val((x).pud))
51#define __pmd(x) ((pmd_t) { __pud(x) } )
52
53#define pud_page(pud) (pmd_page((pmd_t){ pud }))
Dave McCracken46a82b22006-09-25 23:31:48 -070054#define pud_page_vaddr(pud) (pmd_page_vaddr((pmd_t){ pud }))
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56/*
57 * allocating and freeing a pmd is trivial: the 1-entry pmd is
58 * inside the pud, so has no extra memory associated with it.
59 */
60#define pmd_alloc_one(mm, address) NULL
Andrew Morton34ee55012008-07-28 15:46:40 -070061static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
62{
63}
Vineet Gupta3d14f112019-11-30 17:51:16 -080064#define pmd_free_tlb(tlb, x, a) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66#undef pmd_addr_end
67#define pmd_addr_end(addr, end) (end)
68
69#endif /* __ASSEMBLY__ */
70
71#endif /* _PGTABLE_NOPMD_H */