Aneesh Kumar K.V | 11a6f6a | 2016-04-29 23:25:41 +1000 | [diff] [blame] | 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 | */ |
| 14 | struct 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 */ |
Aneesh Kumar K.V | 2bfd65e | 2016-04-29 23:25:58 +1000 | [diff] [blame] | 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 | }; |
Aneesh Kumar K.V | 11a6f6a | 2016-04-29 23:25:41 +1000 | [diff] [blame] | 23 | }; |
| 24 | extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT]; |
Aneesh Kumar K.V | 566ca99 | 2016-04-29 23:25:53 +1000 | [diff] [blame] | 25 | |
Aneesh Kumar K.V | e21fc93 | 2016-07-13 15:05:23 +0530 | [diff] [blame] | 26 | #ifdef CONFIG_PPC_RADIX_MMU |
Aneesh Kumar K.V | a8ed87c | 2016-04-29 23:26:06 +1000 | [diff] [blame] | 27 | #define radix_enabled() mmu_has_feature(MMU_FTR_RADIX) |
Aneesh Kumar K.V | e21fc93 | 2016-07-13 15:05:23 +0530 | [diff] [blame] | 28 | #else |
| 29 | #define radix_enabled() (0) |
| 30 | #endif |
| 31 | |
Aneesh Kumar K.V | a8ed87c | 2016-04-29 23:26:06 +1000 | [diff] [blame] | 32 | |
Aneesh Kumar K.V | 11a6f6a | 2016-04-29 23:25:41 +1000 | [diff] [blame] | 33 | #endif /* __ASSEMBLY__ */ |
| 34 | |
Aneesh Kumar K.V | 11a6f6a | 2016-04-29 23:25:41 +1000 | [diff] [blame] | 35 | /* 64-bit classic hash table MMU */ |
| 36 | #include <asm/book3s/64/mmu-hash.h> |
Aneesh Kumar K.V | 11a6f6a | 2016-04-29 23:25:41 +1000 | [diff] [blame] | 37 | |
| 38 | #ifndef __ASSEMBLY__ |
Aneesh Kumar K.V | e998334 | 2016-04-29 23:25:42 +1000 | [diff] [blame] | 39 | /* |
| 40 | * ISA 3.0 partiton and process table entry format |
| 41 | */ |
| 42 | struct prtb_entry { |
| 43 | __be64 prtb0; |
| 44 | __be64 prtb1; |
| 45 | }; |
| 46 | extern struct prtb_entry *process_tb; |
| 47 | |
| 48 | struct patb_entry { |
| 49 | __be64 patb0; |
| 50 | __be64 patb1; |
| 51 | }; |
| 52 | extern struct patb_entry *partition_tb; |
| 53 | |
| 54 | #define PATB_HR (1UL << 63) |
| 55 | #define PATB_GR (1UL << 63) |
| 56 | #define RPDB_MASK 0x0ffffffffffff00fUL |
| 57 | #define RPDB_SHIFT (1UL << 8) |
| 58 | /* |
| 59 | * Limit process table to PAGE_SIZE table. This |
| 60 | * also limit the max pid we can support. |
| 61 | * MAX_USER_CONTEXT * 16 bytes of space. |
| 62 | */ |
| 63 | #define PRTB_SIZE_SHIFT (CONTEXT_BITS + 4) |
| 64 | /* |
| 65 | * Power9 currently only support 64K partition table size. |
| 66 | */ |
| 67 | #define PATB_SIZE_SHIFT 16 |
Aneesh Kumar K.V | 11a6f6a | 2016-04-29 23:25:41 +1000 | [diff] [blame] | 68 | |
| 69 | typedef unsigned long mm_context_id_t; |
| 70 | struct spinlock; |
| 71 | |
| 72 | typedef struct { |
| 73 | mm_context_id_t id; |
| 74 | u16 user_psize; /* page size index */ |
| 75 | |
| 76 | #ifdef CONFIG_PPC_MM_SLICES |
| 77 | u64 low_slices_psize; /* SLB page size encodings */ |
| 78 | unsigned char high_slices_psize[SLICE_ARRAY_SIZE]; |
| 79 | #else |
| 80 | u16 sllp; /* SLB page size encoding */ |
| 81 | #endif |
| 82 | unsigned long vdso_base; |
| 83 | #ifdef CONFIG_PPC_SUBPAGE_PROT |
| 84 | struct subpage_prot_table spt; |
| 85 | #endif /* CONFIG_PPC_SUBPAGE_PROT */ |
| 86 | #ifdef CONFIG_PPC_ICSWX |
| 87 | struct spinlock *cop_lockp; /* guard acop and cop_pid */ |
| 88 | unsigned long acop; /* mask of enabled coprocessor types */ |
| 89 | unsigned int cop_pid; /* pid value used with coprocessors */ |
| 90 | #endif /* CONFIG_PPC_ICSWX */ |
| 91 | #ifdef CONFIG_PPC_64K_PAGES |
| 92 | /* for 4K PTE fragment support */ |
| 93 | void *pte_frag; |
| 94 | #endif |
| 95 | #ifdef CONFIG_SPAPR_TCE_IOMMU |
| 96 | struct list_head iommu_group_mem_list; |
| 97 | #endif |
| 98 | } mm_context_t; |
| 99 | |
| 100 | /* |
| 101 | * The current system page and segment sizes |
| 102 | */ |
| 103 | extern int mmu_linear_psize; |
| 104 | extern int mmu_virtual_psize; |
| 105 | extern int mmu_vmalloc_psize; |
| 106 | extern int mmu_vmemmap_psize; |
| 107 | extern int mmu_io_psize; |
| 108 | |
Aneesh Kumar K.V | 756d08d | 2016-04-29 23:25:57 +1000 | [diff] [blame] | 109 | /* MMU initialization */ |
Michael Ellerman | 1a01dc8 | 2016-07-26 20:09:30 +1000 | [diff] [blame] | 110 | void mmu_early_init_devtree(void); |
Michael Ellerman | bacf9cf | 2016-07-26 21:31:59 +1000 | [diff] [blame] | 111 | void hash__early_init_devtree(void); |
Michael Ellerman | 2537b09 | 2016-07-26 21:55:27 +1000 | [diff] [blame^] | 112 | void radix__early_init_devtree(void); |
Aneesh Kumar K.V | 2bfd65e | 2016-04-29 23:25:58 +1000 | [diff] [blame] | 113 | extern void radix_init_native(void); |
Aneesh Kumar K.V | 756d08d | 2016-04-29 23:25:57 +1000 | [diff] [blame] | 114 | extern void hash__early_init_mmu(void); |
Aneesh Kumar K.V | 2bfd65e | 2016-04-29 23:25:58 +1000 | [diff] [blame] | 115 | extern void radix__early_init_mmu(void); |
Aneesh Kumar K.V | 756d08d | 2016-04-29 23:25:57 +1000 | [diff] [blame] | 116 | static inline void early_init_mmu(void) |
| 117 | { |
Aneesh Kumar K.V | 2bfd65e | 2016-04-29 23:25:58 +1000 | [diff] [blame] | 118 | if (radix_enabled()) |
| 119 | return radix__early_init_mmu(); |
Aneesh Kumar K.V | 756d08d | 2016-04-29 23:25:57 +1000 | [diff] [blame] | 120 | return hash__early_init_mmu(); |
| 121 | } |
| 122 | extern void hash__early_init_mmu_secondary(void); |
Aneesh Kumar K.V | 2bfd65e | 2016-04-29 23:25:58 +1000 | [diff] [blame] | 123 | extern void radix__early_init_mmu_secondary(void); |
Aneesh Kumar K.V | 756d08d | 2016-04-29 23:25:57 +1000 | [diff] [blame] | 124 | static inline void early_init_mmu_secondary(void) |
| 125 | { |
Aneesh Kumar K.V | 2bfd65e | 2016-04-29 23:25:58 +1000 | [diff] [blame] | 126 | if (radix_enabled()) |
| 127 | return radix__early_init_mmu_secondary(); |
Aneesh Kumar K.V | 756d08d | 2016-04-29 23:25:57 +1000 | [diff] [blame] | 128 | return hash__early_init_mmu_secondary(); |
| 129 | } |
| 130 | |
| 131 | extern void hash__setup_initial_memory_limit(phys_addr_t first_memblock_base, |
| 132 | phys_addr_t first_memblock_size); |
Aneesh Kumar K.V | 2bfd65e | 2016-04-29 23:25:58 +1000 | [diff] [blame] | 133 | extern void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base, |
| 134 | phys_addr_t first_memblock_size); |
Aneesh Kumar K.V | 756d08d | 2016-04-29 23:25:57 +1000 | [diff] [blame] | 135 | static inline void setup_initial_memory_limit(phys_addr_t first_memblock_base, |
| 136 | phys_addr_t first_memblock_size) |
| 137 | { |
Aneesh Kumar K.V | 2bfd65e | 2016-04-29 23:25:58 +1000 | [diff] [blame] | 138 | if (radix_enabled()) |
| 139 | return radix__setup_initial_memory_limit(first_memblock_base, |
| 140 | first_memblock_size); |
Aneesh Kumar K.V | 756d08d | 2016-04-29 23:25:57 +1000 | [diff] [blame] | 141 | return hash__setup_initial_memory_limit(first_memblock_base, |
| 142 | first_memblock_size); |
| 143 | } |
Aneesh Kumar K.V | 11a6f6a | 2016-04-29 23:25:41 +1000 | [diff] [blame] | 144 | #endif /* __ASSEMBLY__ */ |
| 145 | #endif /* _ASM_POWERPC_BOOK3S_64_MMU_H_ */ |