]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blame - arch/powerpc/include/asm/pgtable-types.h
Merge tag 'firewire-update' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[mirror_ubuntu-focal-kernel.git] / arch / powerpc / include / asm / pgtable-types.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
2bf59916
AK
2#ifndef _ASM_POWERPC_PGTABLE_TYPES_H
3#define _ASM_POWERPC_PGTABLE_TYPES_H
4
2bf59916 5/* PTE level */
55c8fc3f
CL
6#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES)
7typedef struct { pte_basic_t pte, pte1, pte2, pte3; } pte_t;
8#else
2bf59916 9typedef struct { pte_basic_t pte; } pte_t;
55c8fc3f 10#endif
2bf59916
AK
11#define __pte(x) ((pte_t) { (x) })
12static inline pte_basic_t pte_val(pte_t x)
13{
14 return x.pte;
15}
16
2bf59916
AK
17/* PMD level */
18#ifdef CONFIG_PPC64
19typedef struct { unsigned long pmd; } pmd_t;
20#define __pmd(x) ((pmd_t) { (x) })
21static inline unsigned long pmd_val(pmd_t x)
22{
23 return x.pmd;
24}
25
368ced78
AK
26/*
27 * 64 bit hash always use 4 level table. Everybody else use 4 level
28 * only for 4K page size.
29 */
30#if defined(CONFIG_PPC_BOOK3S_64) || !defined(CONFIG_PPC_64K_PAGES)
2bf59916
AK
31typedef struct { unsigned long pud; } pud_t;
32#define __pud(x) ((pud_t) { (x) })
33static inline unsigned long pud_val(pud_t x)
34{
35 return x.pud;
36}
368ced78 37#endif /* CONFIG_PPC_BOOK3S_64 || !CONFIG_PPC_64K_PAGES */
2bf59916
AK
38#endif /* CONFIG_PPC64 */
39
40/* PGD level */
41typedef struct { unsigned long pgd; } pgd_t;
42#define __pgd(x) ((pgd_t) { (x) })
43static inline unsigned long pgd_val(pgd_t x)
44{
45 return x.pgd;
46}
47
48/* Page protection bits */
49typedef struct { unsigned long pgprot; } pgprot_t;
50#define pgprot_val(x) ((x).pgprot)
51#define __pgprot(x) ((pgprot_t) { (x) })
52
ae9a71af
AK
53/*
54 * With hash config 64k pages additionally define a bigger "real PTE" type that
55 * gathers the "second half" part of the PTE for pseudo 64k pages
56 */
4e003747 57#if defined(CONFIG_PPC_64K_PAGES) && defined(CONFIG_PPC_BOOK3S_64)
ae9a71af
AK
58typedef struct { pte_t pte; unsigned long hidx; } real_pte_t;
59#else
60typedef struct { pte_t pte; } real_pte_t;
2bf59916 61#endif
3910a7f4 62
4e003747 63#ifdef CONFIG_PPC_BOOK3S_64
3910a7f4
ME
64#include <asm/cmpxchg.h>
65
66static inline bool pte_xchg(pte_t *ptep, pte_t old, pte_t new)
67{
68 unsigned long *p = (unsigned long *)ptep;
69
1a92a80a 70 /* See comment in switch_mm_irqs_off() */
3910a7f4
ME
71 return pte_val(old) == __cmpxchg_u64(p, pte_val(old), pte_val(new));
72}
73#endif
74
20717e1f
AK
75typedef struct { unsigned long pd; } hugepd_t;
76#define __hugepd(x) ((hugepd_t) { (x) })
77static inline unsigned long hpd_val(hugepd_t x)
78{
79 return x.pd;
80}
81
2bf59916 82#endif /* _ASM_POWERPC_PGTABLE_TYPES_H */