]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/powerpc/include/asm/book3s/64/mmu.h
Merge tag 'for-linus-20170825' of git://git.infradead.org/linux-mtd
[mirror_ubuntu-artful-kernel.git] / arch / powerpc / include / asm / book3s / 64 / mmu.h
CommitLineData
11a6f6ab
AK
1#ifndef _ASM_POWERPC_BOOK3S_64_MMU_H_
2#define _ASM_POWERPC_BOOK3S_64_MMU_H_
3
4#ifndef __ASSEMBLY__
5/*
6 * Page size definition
7 *
8 * shift : is the "PAGE_SHIFT" value for that page size
9 * sllp : is a bit mask with the value of SLB L || LP to be or'ed
10 * directly to a slbmte "vsid" value
11 * penc : is the HPTE encoding mask for the "LP" field:
12 *
13 */
14struct mmu_psize_def {
15 unsigned int shift; /* number of bits */
16 int penc[MMU_PAGE_COUNT]; /* HPTE encoding */
17 unsigned int tlbiel; /* tlbiel supported for that page size */
18 unsigned long avpnm; /* bits to mask out in AVPN in the HPTE */
2bfd65e4
AK
19 union {
20 unsigned long sllp; /* SLB L||LP (exact mask to use in slbmte) */
21 unsigned long ap; /* Ap encoding used by PowerISA 3.0 */
22 };
11a6f6ab
AK
23};
24extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
566ca99a 25
11a6f6ab
AK
26#endif /* __ASSEMBLY__ */
27
11a6f6ab
AK
28/* 64-bit classic hash table MMU */
29#include <asm/book3s/64/mmu-hash.h>
11a6f6ab
AK
30
31#ifndef __ASSEMBLY__
e9983344 32/*
8ab102d6 33 * ISA 3.0 partition and process table entry format
e9983344
AK
34 */
35struct prtb_entry {
36 __be64 prtb0;
37 __be64 prtb1;
38};
39extern struct prtb_entry *process_tb;
40
41struct patb_entry {
42 __be64 patb0;
43 __be64 patb1;
44};
45extern struct patb_entry *partition_tb;
46
dbcbfee0 47/* Bits in patb0 field */
e9983344 48#define PATB_HR (1UL << 63)
70cd4c10 49#define RPDB_MASK 0x0fffffffffffff00UL
e9983344 50#define RPDB_SHIFT (1UL << 8)
dbcbfee0
PM
51#define RTS1_SHIFT 61 /* top 2 bits of radix tree size */
52#define RTS1_MASK (3UL << RTS1_SHIFT)
53#define RTS2_SHIFT 5 /* bottom 3 bits of radix tree size */
54#define RTS2_MASK (7UL << RTS2_SHIFT)
55#define RPDS_MASK 0x1f /* root page dir. size field */
56
57/* Bits in patb1 field */
58#define PATB_GR (1UL << 63) /* guest uses radix; must match HR */
59#define PRTS_MASK 0x1f /* process table size field */
70cd4c10 60#define PRTB_MASK 0x0ffffffffffff000UL
dbcbfee0 61
a25bd72b
BH
62/* Number of supported PID bits */
63extern unsigned int mmu_pid_bits;
64
65/* Base PID to allocate from */
66extern unsigned int mmu_base_pid;
67
68#define PRTB_SIZE_SHIFT (mmu_pid_bits + 4)
69#define PRTB_ENTRIES (1ul << mmu_pid_bits)
760573c1 70
e9983344
AK
71/*
72 * Power9 currently only support 64K partition table size.
73 */
74#define PATB_SIZE_SHIFT 16
11a6f6ab
AK
75
76typedef unsigned long mm_context_id_t;
77struct spinlock;
78
1ab66d1f
AP
79/* Maximum possible number of NPUs in a system. */
80#define NV_MAX_NPUS 8
81
11a6f6ab
AK
82typedef struct {
83 mm_context_id_t id;
84 u16 user_psize; /* page size index */
85
1ab66d1f
AP
86 /* NPU NMMU context */
87 struct npu_context *npu_context;
88
11a6f6ab
AK
89#ifdef CONFIG_PPC_MM_SLICES
90 u64 low_slices_psize; /* SLB page size encodings */
91 unsigned char high_slices_psize[SLICE_ARRAY_SIZE];
957b778a 92 unsigned long addr_limit;
11a6f6ab
AK
93#else
94 u16 sllp; /* SLB page size encoding */
95#endif
96 unsigned long vdso_base;
97#ifdef CONFIG_PPC_SUBPAGE_PROT
98 struct subpage_prot_table spt;
99#endif /* CONFIG_PPC_SUBPAGE_PROT */
100#ifdef CONFIG_PPC_ICSWX
101 struct spinlock *cop_lockp; /* guard acop and cop_pid */
102 unsigned long acop; /* mask of enabled coprocessor types */
103 unsigned int cop_pid; /* pid value used with coprocessors */
104#endif /* CONFIG_PPC_ICSWX */
105#ifdef CONFIG_PPC_64K_PAGES
106 /* for 4K PTE fragment support */
107 void *pte_frag;
108#endif
109#ifdef CONFIG_SPAPR_TCE_IOMMU
110 struct list_head iommu_group_mem_list;
111#endif
112} mm_context_t;
113
114/*
115 * The current system page and segment sizes
116 */
117extern int mmu_linear_psize;
118extern int mmu_virtual_psize;
119extern int mmu_vmalloc_psize;
120extern int mmu_vmemmap_psize;
121extern int mmu_io_psize;
122
756d08d1 123/* MMU initialization */
1a01dc87 124void mmu_early_init_devtree(void);
bacf9cf8 125void hash__early_init_devtree(void);
2537b09c 126void radix__early_init_devtree(void);
2bfd65e4 127extern void radix_init_native(void);
756d08d1 128extern void hash__early_init_mmu(void);
2bfd65e4 129extern void radix__early_init_mmu(void);
756d08d1
AK
130static inline void early_init_mmu(void)
131{
2bfd65e4
AK
132 if (radix_enabled())
133 return radix__early_init_mmu();
756d08d1
AK
134 return hash__early_init_mmu();
135}
136extern void hash__early_init_mmu_secondary(void);
2bfd65e4 137extern void radix__early_init_mmu_secondary(void);
756d08d1
AK
138static inline void early_init_mmu_secondary(void)
139{
2bfd65e4
AK
140 if (radix_enabled())
141 return radix__early_init_mmu_secondary();
756d08d1
AK
142 return hash__early_init_mmu_secondary();
143}
144
145extern void hash__setup_initial_memory_limit(phys_addr_t first_memblock_base,
146 phys_addr_t first_memblock_size);
2bfd65e4
AK
147extern void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base,
148 phys_addr_t first_memblock_size);
756d08d1
AK
149static inline void setup_initial_memory_limit(phys_addr_t first_memblock_base,
150 phys_addr_t first_memblock_size)
151{
b8f1b4f8 152 if (early_radix_enabled())
2bfd65e4
AK
153 return radix__setup_initial_memory_limit(first_memblock_base,
154 first_memblock_size);
756d08d1
AK
155 return hash__setup_initial_memory_limit(first_memblock_base,
156 first_memblock_size);
157}
eea8148c
ME
158
159extern int (*register_process_table)(unsigned long base, unsigned long page_size,
160 unsigned long tbl_size);
161
cc3d2940
PM
162#ifdef CONFIG_PPC_PSERIES
163extern void radix_init_pseries(void);
164#else
165static inline void radix_init_pseries(void) { };
166#endif
167
11a6f6ab
AK
168#endif /* __ASSEMBLY__ */
169#endif /* _ASM_POWERPC_BOOK3S_64_MMU_H_ */