1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_PGTABLE_TYPES_H
3 #define _ASM_POWERPC_PGTABLE_TYPES_H
5 #if defined(__CHECKER__) || !defined(CONFIG_PPC32)
6 #define STRICT_MM_TYPECHECKS
10 #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES)
11 typedef struct { pte_basic_t pte, pte1, pte2, pte3; } pte_t;
12 #elif defined(STRICT_MM_TYPECHECKS)
13 typedef struct { pte_basic_t pte; } pte_t;
15 typedef pte_basic_t pte_t;
18 #if defined(STRICT_MM_TYPECHECKS) || \
19 (defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES))
20 #define __pte(x) ((pte_t) { (x) })
21 static inline pte_basic_t pte_val(pte_t x)
26 #define __pte(x) ((pte_t)(x))
27 static inline pte_basic_t pte_val(pte_t x)
35 typedef struct { unsigned long pmd; } pmd_t;
36 #define __pmd(x) ((pmd_t) { (x) })
37 static inline unsigned long pmd_val(pmd_t x)
42 /* 64 bit always use 4 level table. */
43 typedef struct { unsigned long pud; } pud_t;
44 #define __pud(x) ((pud_t) { (x) })
45 static inline unsigned long pud_val(pud_t x)
49 #endif /* CONFIG_PPC64 */
52 typedef struct { unsigned long pgd; } pgd_t;
53 #define __pgd(x) ((pgd_t) { (x) })
54 static inline unsigned long pgd_val(pgd_t x)
59 /* Page protection bits */
60 typedef struct { unsigned long pgprot; } pgprot_t;
61 #define pgprot_val(x) ((x).pgprot)
62 #define __pgprot(x) ((pgprot_t) { (x) })
65 * With hash config 64k pages additionally define a bigger "real PTE" type that
66 * gathers the "second half" part of the PTE for pseudo 64k pages
68 #ifdef CONFIG_PPC_64K_PAGES
69 typedef struct { pte_t pte; unsigned long hidx; } real_pte_t;
71 typedef struct { pte_t pte; } real_pte_t;
74 #ifdef CONFIG_PPC_BOOK3S_64
75 #include <asm/cmpxchg.h>
77 static inline bool pte_xchg(pte_t *ptep, pte_t old, pte_t new)
79 unsigned long *p = (unsigned long *)ptep;
81 /* See comment in switch_mm_irqs_off() */
82 return pte_val(old) == __cmpxchg_u64(p, pte_val(old), pte_val(new));
86 #ifdef CONFIG_ARCH_HAS_HUGEPD
87 typedef struct { unsigned long pd; } hugepd_t;
88 #define __hugepd(x) ((hugepd_t) { (x) })
89 static inline unsigned long hpd_val(hugepd_t x)
95 #endif /* _ASM_POWERPC_PGTABLE_TYPES_H */