1 #ifndef _ASM_POWERPC_MMU_HASH64_H_
2 #define _ASM_POWERPC_MMU_HASH64_H_
15 #include <asm/asm-compat.h>
29 #define STE_ESID_V 0x80
30 #define STE_ESID_KS 0x20
31 #define STE_ESID_KP 0x10
32 #define STE_ESID_N 0x08
34 #define STE_VSID_SHIFT 12
37 #define STAB0_PAGE 0x8
38 #define STAB0_OFFSET (STAB0_PAGE << 12)
39 #define STAB0_PHYS_ADDR (STAB0_OFFSET + PHYSICAL_START)
49 #define SLB_NUM_BOLTED 3
50 #define SLB_CACHE_ENTRIES 8
51 #define SLB_MIN_SIZE 32
54 #define SLB_ESID_V ASM_CONST(0x0000000008000000)
57 #define SLB_VSID_SHIFT 12
58 #define SLB_VSID_SHIFT_1T 24
59 #define SLB_VSID_SSIZE_SHIFT 62
60 #define SLB_VSID_B ASM_CONST(0xc000000000000000)
61 #define SLB_VSID_B_256M ASM_CONST(0x0000000000000000)
62 #define SLB_VSID_B_1T ASM_CONST(0x4000000000000000)
63 #define SLB_VSID_KS ASM_CONST(0x0000000000000800)
64 #define SLB_VSID_KP ASM_CONST(0x0000000000000400)
65 #define SLB_VSID_N ASM_CONST(0x0000000000000200)
66 #define SLB_VSID_L ASM_CONST(0x0000000000000100)
67 #define SLB_VSID_C ASM_CONST(0x0000000000000080)
68 #define SLB_VSID_LP ASM_CONST(0x0000000000000030)
69 #define SLB_VSID_LP_00 ASM_CONST(0x0000000000000000)
70 #define SLB_VSID_LP_01 ASM_CONST(0x0000000000000010)
71 #define SLB_VSID_LP_10 ASM_CONST(0x0000000000000020)
72 #define SLB_VSID_LP_11 ASM_CONST(0x0000000000000030)
73 #define SLB_VSID_LLP (SLB_VSID_L|SLB_VSID_LP)
75 #define SLB_VSID_KERNEL (SLB_VSID_KP)
76 #define SLB_VSID_USER (SLB_VSID_KP|SLB_VSID_KS|SLB_VSID_C)
78 #define SLBIE_C (0x08000000)
79 #define SLBIE_SSIZE_SHIFT 25
85 #define HPTES_PER_GROUP 8
87 #define HPTE_V_SSIZE_SHIFT 62
88 #define HPTE_V_AVPN_SHIFT 7
89 #define HPTE_V_AVPN ASM_CONST(0x3fffffffffffff80)
90 #define HPTE_V_AVPN_VAL(x) (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT)
91 #define HPTE_V_COMPARE(x,y) (!(((x) ^ (y)) & 0xffffffffffffff80UL))
92 #define HPTE_V_BOLTED ASM_CONST(0x0000000000000010)
93 #define HPTE_V_LOCK ASM_CONST(0x0000000000000008)
94 #define HPTE_V_LARGE ASM_CONST(0x0000000000000004)
95 #define HPTE_V_SECONDARY ASM_CONST(0x0000000000000002)
96 #define HPTE_V_VALID ASM_CONST(0x0000000000000001)
98 #define HPTE_R_PP0 ASM_CONST(0x8000000000000000)
99 #define HPTE_R_TS ASM_CONST(0x4000000000000000)
100 #define HPTE_R_KEY_HI ASM_CONST(0x3000000000000000)
101 #define HPTE_R_RPN_SHIFT 12
102 #define HPTE_R_RPN ASM_CONST(0x0ffffffffffff000)
103 #define HPTE_R_PP ASM_CONST(0x0000000000000003)
104 #define HPTE_R_N ASM_CONST(0x0000000000000004)
105 #define HPTE_R_G ASM_CONST(0x0000000000000008)
106 #define HPTE_R_M ASM_CONST(0x0000000000000010)
107 #define HPTE_R_I ASM_CONST(0x0000000000000020)
108 #define HPTE_R_W ASM_CONST(0x0000000000000040)
109 #define HPTE_R_WIMG ASM_CONST(0x0000000000000078)
110 #define HPTE_R_C ASM_CONST(0x0000000000000080)
111 #define HPTE_R_R ASM_CONST(0x0000000000000100)
112 #define HPTE_R_KEY_LO ASM_CONST(0x0000000000000e00)
114 #define HPTE_V_1TB_SEG ASM_CONST(0x4000000000000000)
115 #define HPTE_V_VRMA_MASK ASM_CONST(0x4001ffffff000000)
122 #define PP_RXXX (HPTE_R_PP0 | 2)
161 #define MMU_SEGSIZE_256M 0
162 #define MMU_SEGSIZE_1T 1
176 static inline int segment_shift(
int ssize)
210 static inline unsigned long hpte_encode_avpn(
unsigned long vpn,
int psize,
232 static inline unsigned long hpte_encode_v(
unsigned long vpn,
233 int psize,
int ssize)
236 v = hpte_encode_avpn(vpn, psize, ssize);
237 if (psize != MMU_PAGE_4K)
247 static inline unsigned long hpte_encode_r(
unsigned long pa,
int psize)
252 if (psize == MMU_PAGE_4K)
257 return (pa & ~((1ul << shift) - 1)) | (penc << 12);
265 static inline unsigned long hpt_vpn(
unsigned long ea,
266 unsigned long vsid,
int ssize)
269 int s_shift = segment_shift(ssize);
271 mask = (1ul << (s_shift -
VPN_SHIFT)) - 1;
278 static inline unsigned long hpt_hash(
unsigned long vpn,
279 unsigned int shift,
int ssize)
282 unsigned long hash, vsid;
292 hash = vsid ^ (vsid << 25) ^
295 return hash & 0x7fffffffff
UL;
299 unsigned long vsid,
pte_t *ptep,
unsigned long trap,
300 unsigned int local,
int ssize,
int subpage_prot);
302 unsigned long vsid,
pte_t *ptep,
unsigned long trap,
303 unsigned int local,
int ssize);
308 pte_t *ptep,
unsigned long trap,
int local,
int ssize,
309 unsigned int shift,
unsigned int mmu_psize);
311 unsigned long vsid,
unsigned long trap,
312 int ssize,
int psize,
unsigned long pte);
314 unsigned long pstart,
unsigned long prot,
315 int psize,
int ssize);
378 #define VSID_MULTIPLIER_256M ASM_CONST(12538073)
379 #define VSID_BITS_256M 38
380 #define VSID_MODULUS_256M ((1UL<<VSID_BITS_256M)-1)
382 #define VSID_MULTIPLIER_1T ASM_CONST(12538073)
383 #define VSID_BITS_1T 26
384 #define VSID_MODULUS_1T ((1UL<<VSID_BITS_1T)-1)
386 #define CONTEXT_BITS 19
387 #define USER_ESID_BITS 18
388 #define USER_ESID_BITS_1T 6
390 #define USER_VSID_RANGE (1UL << (USER_ESID_BITS + SID_SHIFT))
406 #define ASM_VSID_SCRAMBLE(rt, rx, size) \
407 lis rx,VSID_MULTIPLIER_##size@h; \
408 ori rx,rx,VSID_MULTIPLIER_##size@l; \
411 srdi rx,rt,VSID_BITS_##size; \
412 clrldi rt,rt,(64-VSID_BITS_##size); \
421 srdi rx,rx,VSID_BITS_##size; \
425 #define SLICE_ARRAY_SIZE (PGTABLE_RANGE >> 41)
429 #ifdef CONFIG_PPC_SUBPAGE_PROT
441 struct subpage_prot_table {
442 unsigned long maxaddr;
443 unsigned int **protptrs[2];
444 unsigned int *low_prot[4];
447 #define SBP_L1_BITS (PAGE_SHIFT - 2)
448 #define SBP_L2_BITS (PAGE_SHIFT - 3)
449 #define SBP_L1_COUNT (1 << SBP_L1_BITS)
450 #define SBP_L2_COUNT (1 << SBP_L2_BITS)
451 #define SBP_L2_SHIFT (PAGE_SHIFT + SBP_L1_BITS)
452 #define SBP_L3_SHIFT (SBP_L2_SHIFT + SBP_L2_BITS)
468 #ifdef CONFIG_PPC_MM_SLICES
469 u64 low_slices_psize;
474 unsigned long vdso_base;
475 #ifdef CONFIG_PPC_SUBPAGE_PROT
476 struct subpage_prot_table spt;
478 #ifdef CONFIG_PPC_ICSWX
481 unsigned int cop_pid;
493 #define vsid_scramble(protovsid, size) \
494 ((((protovsid) * VSID_MULTIPLIER_##size) % VSID_MODULUS_##size))
497 #define vsid_scramble(protovsid, size) \
500 x = (protovsid) * VSID_MULTIPLIER_##size; \
501 x = (x >> VSID_BITS_##size) + (x & VSID_MODULUS_##size); \
502 (x + ((x+1) >> VSID_BITS_##size)) & VSID_MODULUS_##size; \
517 static inline unsigned long get_kernel_vsid(
unsigned long ea,
int ssize)
519 unsigned long proto_vsid;
535 static inline int user_segment_size(
unsigned long addr)
544 static inline unsigned long get_vsid(
unsigned long context,
unsigned long ea,