pgtable.h 3.6 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
2 3 4
#ifndef _ASM_POWERPC_PGTABLE_H
#define _ASM_POWERPC_PGTABLE_H

5
#ifndef __ASSEMBLY__
6
#include <linux/mmdebug.h>
S
Scott Wood 已提交
7
#include <linux/mmzone.h>
8 9 10
#include <asm/processor.h>		/* For TASK_SIZE */
#include <asm/mmu.h>
#include <asm/page.h>
11
#include <asm/tlbflush.h>
12

13
struct mm_struct;
14

15 16
#endif /* !__ASSEMBLY__ */

17 18 19
#ifdef CONFIG_PPC_BOOK3S
#include <asm/book3s/pgtable.h>
#else
20
#include <asm/nohash/pgtable.h>
21
#endif /* !CONFIG_PPC_BOOK3S */
L
Linus Torvalds 已提交
22

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/* Note due to the way vm flags are laid out, the bits are XWR */
#define __P000	PAGE_NONE
#define __P001	PAGE_READONLY
#define __P010	PAGE_COPY
#define __P011	PAGE_COPY
#define __P100	PAGE_READONLY_X
#define __P101	PAGE_READONLY_X
#define __P110	PAGE_COPY_X
#define __P111	PAGE_COPY_X

#define __S000	PAGE_NONE
#define __S001	PAGE_READONLY
#define __S010	PAGE_SHARED
#define __S011	PAGE_SHARED
#define __S100	PAGE_READONLY_X
#define __S101	PAGE_READONLY_X
#define __S110	PAGE_SHARED_X
#define __S111	PAGE_SHARED_X

L
Linus Torvalds 已提交
42
#ifndef __ASSEMBLY__
43

44 45
#include <asm/tlbflush.h>

46 47 48
/* Keep these as a macros to avoid include dependency mess */
#define pte_page(x)		pfn_to_page(pte_pfn(x))
#define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
49 50 51 52 53 54 55 56 57 58
/*
 * Select all bits except the pfn
 */
static inline pgprot_t pte_pgprot(pte_t pte)
{
	unsigned long pte_flags;

	pte_flags = pte_val(pte) & ~PTE_RPN_MASK;
	return __pgprot(pte_flags);
}
59

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
/*
 * ZERO_PAGE is a global shared page that is always zero: used
 * for zero-mapped memory areas etc..
 */
extern unsigned long empty_zero_page[];
#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))

extern pgd_t swapper_pg_dir[];

extern void paging_init(void);

/*
 * kern_addr_valid is intended to indicate whether an address is a valid
 * kernel address.  Most 32-bit archs define it as always true (like this)
 * but most 64-bit archs actually perform a test.  What should we do here?
 */
#define kern_addr_valid(addr)	(1)

L
Linus Torvalds 已提交
78
#include <asm-generic/pgtable.h>
79

80 81 82
#ifndef CONFIG_TRANSPARENT_HUGEPAGE
#define pmd_large(pmd)		0
#endif
83

84
/* can we use this in kvm */
85 86
unsigned long vmalloc_to_phys(void *vmalloc_addr);

87
void pgtable_cache_add(unsigned int shift);
88
void pgtable_cache_init(void);
89

90
#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32)
91 92 93 94 95
void mark_initmem_nx(void);
#else
static inline void mark_initmem_nx(void) { }
#endif

96 97 98 99 100 101
#ifdef CONFIG_PPC_DEBUG_WX
void ptdump_check_wx(void);
#else
static inline void ptdump_check_wx(void) { }
#endif

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
/*
 * When used, PTE_FRAG_NR is defined in subarch pgtable.h
 * so we are sure it is included when arriving here.
 */
#ifdef PTE_FRAG_NR
static inline void *pte_frag_get(mm_context_t *ctx)
{
	return ctx->pte_frag;
}

static inline void pte_frag_set(mm_context_t *ctx, void *p)
{
	ctx->pte_frag = p;
}
#else
117 118 119 120
#define PTE_FRAG_NR		1
#define PTE_FRAG_SIZE_SHIFT	PAGE_SHIFT
#define PTE_FRAG_SIZE		(1UL << PTE_FRAG_SIZE_SHIFT)

121 122 123 124 125 126 127 128 129 130
static inline void *pte_frag_get(mm_context_t *ctx)
{
	return NULL;
}

static inline void pte_frag_set(mm_context_t *ctx, void *p)
{
}
#endif

131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
#ifndef pmd_is_leaf
#define pmd_is_leaf pmd_is_leaf
static inline bool pmd_is_leaf(pmd_t pmd)
{
	return false;
}
#endif

#ifndef pud_is_leaf
#define pud_is_leaf pud_is_leaf
static inline bool pud_is_leaf(pud_t pud)
{
	return false;
}
#endif

#ifndef pgd_is_leaf
#define pgd_is_leaf pgd_is_leaf
static inline bool pgd_is_leaf(pgd_t pgd)
{
	return false;
}
#endif

155 156 157 158 159 160 161 162 163 164 165 166 167 168
#ifdef CONFIG_PPC64
#define is_ioremap_addr is_ioremap_addr
static inline bool is_ioremap_addr(const void *x)
{
#ifdef CONFIG_MMU
	unsigned long addr = (unsigned long)x;

	return addr >= IOREMAP_BASE && addr < IOREMAP_END;
#else
	return false;
#endif
}
#endif /* CONFIG_PPC64 */

L
Linus Torvalds 已提交
169 170
#endif /* __ASSEMBLY__ */

171
#endif /* _ASM_POWERPC_PGTABLE_H */