Blame view

arch/sparc/kernel/sun4v_tlb_miss.S 10.5 KB
d257d5da3   David S. Miller   [SPARC64]: Initia...
1
2
3
4
5
6
7
  /* sun4v_tlb_miss.S: Sun4v TLB miss handlers.
   *
   * Copyright (C) 2006 <davem@davemloft.net>
   */
  
  	.text
  	.align	32
36a68e77c   David S. Miller   [SPARC64]: Simpli...
8
9
10
11
12
13
14
15
16
  	/* Load ITLB fault information into VADDR and CTX, using BASE.  */
  #define LOAD_ITLB_INFO(BASE, VADDR, CTX) \
  	ldx	[BASE + HV_FAULT_I_ADDR_OFFSET], VADDR; \
  	ldx	[BASE + HV_FAULT_I_CTX_OFFSET], CTX;
  
  	/* Load DTLB fault information into VADDR and CTX, using BASE.  */
  #define LOAD_DTLB_INFO(BASE, VADDR, CTX) \
  	ldx	[BASE + HV_FAULT_D_ADDR_OFFSET], VADDR; \
  	ldx	[BASE + HV_FAULT_D_CTX_OFFSET], CTX;
d257d5da3   David S. Miller   [SPARC64]: Initia...
17

8b2342744   David S. Miller   [SPARC64]: More T...
18
  	/* DEST = (VADDR >> 22)
36a68e77c   David S. Miller   [SPARC64]: Simpli...
19
  	 *
bcc28ee0b   David S. Miller   [SPARC64]: Fix su...
20
  	 * Branch to ZERO_CTX_LABEL if context is zero.
d257d5da3   David S. Miller   [SPARC64]: Initia...
21
  	 */
8b2342744   David S. Miller   [SPARC64]: More T...
22
23
  #define	COMPUTE_TAG_TARGET(DEST, VADDR, CTX, ZERO_CTX_LABEL) \
  	srlx	VADDR, 22, DEST; \
36a68e77c   David S. Miller   [SPARC64]: Simpli...
24
  	brz,pn	CTX, ZERO_CTX_LABEL; \
8b2342744   David S. Miller   [SPARC64]: More T...
25
  	 nop;
d257d5da3   David S. Miller   [SPARC64]: Initia...
26
27
28
29
30
  
  	/* Create TSB pointer.  This is something like:
  	 *
  	 * index_mask = (512 << (tsb_reg & 0x7UL)) - 1UL;
  	 * tsb_base = tsb_reg & ~0x7UL;
dcc1e8dd8   David S. Miller   [SPARC64]: Add a ...
31
  	 * tsb_index = ((vaddr >> HASH_SHIFT) & tsb_mask);
d257d5da3   David S. Miller   [SPARC64]: Initia...
32
33
  	 * tsb_ptr = tsb_base + (tsb_index * 16);
  	 */
dcc1e8dd8   David S. Miller   [SPARC64]: Add a ...
34
  #define COMPUTE_TSB_PTR(TSB_PTR, VADDR, HASH_SHIFT, TMP1, TMP2) \
36a68e77c   David S. Miller   [SPARC64]: Simpli...
35
36
37
38
  	and	TSB_PTR, 0x7, TMP1;			\
  	mov	512, TMP2;				\
  	andn	TSB_PTR, 0x7, TSB_PTR;			\
  	sllx	TMP2, TMP1, TMP2;			\
dcc1e8dd8   David S. Miller   [SPARC64]: Add a ...
39
  	srlx	VADDR, HASH_SHIFT, TMP1;		\
36a68e77c   David S. Miller   [SPARC64]: Simpli...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  	sub	TMP2, 1, TMP2;				\
  	and	TMP1, TMP2, TMP1;			\
  	sllx	TMP1, 4, TMP1;				\
  	add	TSB_PTR, TMP1, TSB_PTR;
  
  sun4v_itlb_miss:
  	/* Load MMU Miss base into %g2.  */
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
  	
  	/* Load UTSB reg into %g1.  */
  	mov	SCRATCHPAD_UTSBREG1, %g1
  	ldxa	[%g1] ASI_SCRATCHPAD, %g1
  
  	LOAD_ITLB_INFO(%g2, %g4, %g5)
8b2342744   David S. Miller   [SPARC64]: More T...
54
  	COMPUTE_TAG_TARGET(%g6, %g4, %g5, kvmap_itlb_4v)
dcc1e8dd8   David S. Miller   [SPARC64]: Add a ...
55
  	COMPUTE_TSB_PTR(%g1, %g4, PAGE_SHIFT, %g3, %g7)
d257d5da3   David S. Miller   [SPARC64]: Initia...
56
57
  
  	/* Load TSB tag/pte into %g2/%g3 and compare the tag.  */
c7f81d42d   David S. Miller   [SPARC64]: Don't ...
58
  	ldda	[%g1] ASI_QUAD_LDD_PHYS_4V, %g2
d257d5da3   David S. Miller   [SPARC64]: Initia...
59
  	cmp	%g2, %g6
d257d5da3   David S. Miller   [SPARC64]: Initia...
60
61
  	bne,a,pn %xcc, tsb_miss_page_table_walk
  	 mov	FAULT_CODE_ITLB, %g3
45f791eb0   David S. Miller   [SPARC64]: Fix _P...
62
  	andcc	%g3, _PAGE_EXEC_4V, %g0
d257d5da3   David S. Miller   [SPARC64]: Initia...
63
64
65
66
67
68
69
70
  	be,a,pn	%xcc, tsb_do_fault
  	 mov	FAULT_CODE_ITLB, %g3
  
  	/* We have a valid entry, make hypervisor call to load
  	 * I-TLB and return from trap.
  	 *
  	 * %g3:	PTE
  	 * %g4:	vaddr
d257d5da3   David S. Miller   [SPARC64]: Initia...
71
72
  	 */
  sun4v_itlb_load:
8b2342744   David S. Miller   [SPARC64]: More T...
73
  	ldxa	[%g0] ASI_SCRATCHPAD, %g6
d257d5da3   David S. Miller   [SPARC64]: Initia...
74
75
76
77
78
  	mov	%o0, %g1		! save %o0
  	mov	%o1, %g2		! save %o1
  	mov	%o2, %g5		! save %o2
  	mov	%o3, %g7		! save %o3
  	mov	%g4, %o0		! vaddr
8b2342744   David S. Miller   [SPARC64]: More T...
79
  	ldx	[%g6 + HV_FAULT_I_CTX_OFFSET], %o1	! ctx
d257d5da3   David S. Miller   [SPARC64]: Initia...
80
81
82
  	mov	%g3, %o2		! PTE
  	mov	HV_MMU_IMMU, %o3	! flags
  	ta	HV_MMU_MAP_ADDR_TRAP
6c8927c96   David S. Miller   [SPARC64]: Fix so...
83
84
  	brnz,pn	%o0, sun4v_itlb_error
  	 mov	%g2, %o1		! restore %o1
d257d5da3   David S. Miller   [SPARC64]: Initia...
85
  	mov	%g1, %o0		! restore %o0
d257d5da3   David S. Miller   [SPARC64]: Initia...
86
87
88
89
90
91
  	mov	%g5, %o2		! restore %o2
  	mov	%g7, %o3		! restore %o3
  
  	retry
  
  sun4v_dtlb_miss:
12eaa328f   David S. Miller   [SPARC64]: Use AS...
92
93
  	/* Load MMU Miss base into %g2.  */
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
d257d5da3   David S. Miller   [SPARC64]: Initia...
94
95
  	
  	/* Load UTSB reg into %g1.  */
12eaa328f   David S. Miller   [SPARC64]: Use AS...
96
  	mov	SCRATCHPAD_UTSBREG1, %g1
459b6e621   David S. Miller   [SPARC64]: Fix so...
97
  	ldxa	[%g1] ASI_SCRATCHPAD, %g1
d257d5da3   David S. Miller   [SPARC64]: Initia...
98

36a68e77c   David S. Miller   [SPARC64]: Simpli...
99
  	LOAD_DTLB_INFO(%g2, %g4, %g5)
8b2342744   David S. Miller   [SPARC64]: More T...
100
  	COMPUTE_TAG_TARGET(%g6, %g4, %g5, kvmap_dtlb_4v)
dcc1e8dd8   David S. Miller   [SPARC64]: Add a ...
101
  	COMPUTE_TSB_PTR(%g1, %g4, PAGE_SHIFT, %g3, %g7)
d257d5da3   David S. Miller   [SPARC64]: Initia...
102
103
  
  	/* Load TSB tag/pte into %g2/%g3 and compare the tag.  */
c7f81d42d   David S. Miller   [SPARC64]: Don't ...
104
  	ldda	[%g1] ASI_QUAD_LDD_PHYS_4V, %g2
d257d5da3   David S. Miller   [SPARC64]: Initia...
105
106
  	cmp	%g2, %g6
  	bne,a,pn %xcc, tsb_miss_page_table_walk
92daa77e9   David S. Miller   [SPARC64]: Fix ty...
107
  	 mov	FAULT_CODE_DTLB, %g3
d257d5da3   David S. Miller   [SPARC64]: Initia...
108
109
110
111
112
113
  
  	/* We have a valid entry, make hypervisor call to load
  	 * D-TLB and return from trap.
  	 *
  	 * %g3:	PTE
  	 * %g4:	vaddr
d257d5da3   David S. Miller   [SPARC64]: Initia...
114
115
  	 */
  sun4v_dtlb_load:
8b2342744   David S. Miller   [SPARC64]: More T...
116
  	ldxa	[%g0] ASI_SCRATCHPAD, %g6
d257d5da3   David S. Miller   [SPARC64]: Initia...
117
118
119
120
121
  	mov	%o0, %g1		! save %o0
  	mov	%o1, %g2		! save %o1
  	mov	%o2, %g5		! save %o2
  	mov	%o3, %g7		! save %o3
  	mov	%g4, %o0		! vaddr
8b2342744   David S. Miller   [SPARC64]: More T...
122
  	ldx	[%g6 + HV_FAULT_D_CTX_OFFSET], %o1	! ctx
d257d5da3   David S. Miller   [SPARC64]: Initia...
123
124
125
  	mov	%g3, %o2		! PTE
  	mov	HV_MMU_DMMU, %o3	! flags
  	ta	HV_MMU_MAP_ADDR_TRAP
6c8927c96   David S. Miller   [SPARC64]: Fix so...
126
127
  	brnz,pn	%o0, sun4v_dtlb_error
  	 mov	%g2, %o1		! restore %o1
d257d5da3   David S. Miller   [SPARC64]: Initia...
128
  	mov	%g1, %o0		! restore %o0
d257d5da3   David S. Miller   [SPARC64]: Initia...
129
130
131
132
133
134
  	mov	%g5, %o2		! restore %o2
  	mov	%g7, %o3		! restore %o3
  
  	retry
  
  sun4v_dtlb_prot:
8b2342744   David S. Miller   [SPARC64]: More T...
135
  	SET_GL(1)
24c523ecc   David S. Miller   [SPARC64]: Fix un...
136
  	/* Load MMU Miss base into %g5.  */
8b2342744   David S. Miller   [SPARC64]: More T...
137
  	ldxa	[%g0] ASI_SCRATCHPAD, %g5
d257d5da3   David S. Miller   [SPARC64]: Initia...
138
  	
8b2342744   David S. Miller   [SPARC64]: More T...
139
  	ldx	[%g5 + HV_FAULT_D_ADDR_OFFSET], %g5
d257d5da3   David S. Miller   [SPARC64]: Initia...
140
141
  	rdpr	%tl, %g1
  	cmp	%g1, 1
8b2342744   David S. Miller   [SPARC64]: More T...
142
  	bgu,pn	%xcc, winfix_trampoline
8b2342744   David S. Miller   [SPARC64]: More T...
143
  	 mov	FAULT_CODE_DTLB | FAULT_CODE_WRITE, %g4
86d43258b   David S. Miller   [SPARC64]: Set g4...
144
145
  	ba,pt	%xcc, sparc64_realfault_common
  	 nop
d257d5da3   David S. Miller   [SPARC64]: Initia...
146

24c523ecc   David S. Miller   [SPARC64]: Fix un...
147
148
149
150
  	/* Called from trap table:
  	 * %g4:	vaddr
  	 * %g5:	context
  	 * %g6: TAG TARGET
aa9143b97   David S. Miller   [SPARC64]: Implem...
151
152
  	 */
  sun4v_itsb_miss:
459b6e621   David S. Miller   [SPARC64]: Fix so...
153
154
155
  	mov	SCRATCHPAD_UTSBREG1, %g1
  	ldxa	[%g1] ASI_SCRATCHPAD, %g1
  	brz,pn	%g5, kvmap_itlb_4v
aa9143b97   David S. Miller   [SPARC64]: Implem...
156
  	 mov	FAULT_CODE_ITLB, %g3
6c8927c96   David S. Miller   [SPARC64]: Fix so...
157
  	ba,a,pt	%xcc, sun4v_tsb_miss_common
aa9143b97   David S. Miller   [SPARC64]: Implem...
158

24c523ecc   David S. Miller   [SPARC64]: Fix un...
159
160
161
162
  	/* Called from trap table:
  	 * %g4:	vaddr
  	 * %g5:	context
  	 * %g6: TAG TARGET
aa9143b97   David S. Miller   [SPARC64]: Implem...
163
164
  	 */
  sun4v_dtsb_miss:
459b6e621   David S. Miller   [SPARC64]: Fix so...
165
166
167
168
  	mov	SCRATCHPAD_UTSBREG1, %g1
  	ldxa	[%g1] ASI_SCRATCHPAD, %g1
  	brz,pn	%g5, kvmap_dtlb_4v
  	 mov	FAULT_CODE_DTLB, %g3
aa9143b97   David S. Miller   [SPARC64]: Implem...
169

24c523ecc   David S. Miller   [SPARC64]: Fix un...
170
  	/* fallthrough */
aa9143b97   David S. Miller   [SPARC64]: Implem...
171
  sun4v_tsb_miss_common:
dcc1e8dd8   David S. Miller   [SPARC64]: Add a ...
172
  	COMPUTE_TSB_PTR(%g1, %g4, PAGE_SHIFT, %g5, %g7)
36a68e77c   David S. Miller   [SPARC64]: Simpli...
173

36a68e77c   David S. Miller   [SPARC64]: Simpli...
174
  	sub	%g2, TRAP_PER_CPU_FAULT_INFO, %g2
dcc1e8dd8   David S. Miller   [SPARC64]: Add a ...
175

9e695d2ec   David Miller   sparc64: Support ...
176
  #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
dcc1e8dd8   David S. Miller   [SPARC64]: Add a ...
177
178
179
180
181
  	mov	SCRATCHPAD_UTSBREG2, %g5
  	ldxa	[%g5] ASI_SCRATCHPAD, %g5
  	cmp	%g5, -1
  	be,pt	%xcc, 80f
  	 nop
37b3a8ff3   David S. Miller   sparc64: Move fro...
182
  	COMPUTE_TSB_PTR(%g5, %g4, REAL_HPAGE_SHIFT, %g2, %g7)
dcc1e8dd8   David S. Miller   [SPARC64]: Add a ...
183
184
185
186
187
188
189
  
  	/* That clobbered %g2, reload it.  */
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
  	sub	%g2, TRAP_PER_CPU_FAULT_INFO, %g2
  
  80:	stx	%g5, [%g2 + TRAP_PER_CPU_TSB_HUGE_TEMP]
  #endif
36a68e77c   David S. Miller   [SPARC64]: Simpli...
190
191
  	ba,pt	%xcc, tsb_miss_page_table_walk_sun4v_fastpath
  	 ldx	[%g2 + TRAP_PER_CPU_PGD_PADDR], %g7
aa9143b97   David S. Miller   [SPARC64]: Implem...
192

6c8927c96   David S. Miller   [SPARC64]: Fix so...
193
  sun4v_itlb_error:
4ccb92728   bob picco   sparc64: sun4v TL...
194
195
196
197
  	rdpr	%tl, %g1
  	cmp	%g1, 1
  	ble,pt	%icc, sun4v_bad_ra
  	 or	%g0, FAULT_CODE_BAD_RA | FAULT_CODE_ITLB, %g1
6c8927c96   David S. Miller   [SPARC64]: Fix so...
198
199
200
  	sethi	%hi(sun4v_err_itlb_vaddr), %g1
  	stx	%g4, [%g1 + %lo(sun4v_err_itlb_vaddr)]
  	sethi	%hi(sun4v_err_itlb_ctx), %g1
8b2342744   David S. Miller   [SPARC64]: More T...
201
202
  	ldxa	[%g0] ASI_SCRATCHPAD, %g6
  	ldx	[%g6 + HV_FAULT_I_CTX_OFFSET], %o1
6c8927c96   David S. Miller   [SPARC64]: Fix so...
203
204
205
206
207
  	stx	%o1, [%g1 + %lo(sun4v_err_itlb_ctx)]
  	sethi	%hi(sun4v_err_itlb_pte), %g1
  	stx	%g3, [%g1 + %lo(sun4v_err_itlb_pte)]
  	sethi	%hi(sun4v_err_itlb_error), %g1
  	stx	%o0, [%g1 + %lo(sun4v_err_itlb_error)]
4ccb92728   bob picco   sparc64: sun4v TL...
208
  	sethi	%hi(1f), %g7
6c8927c96   David S. Miller   [SPARC64]: Fix so...
209
  	rdpr	%tl, %g4
6c8927c96   David S. Miller   [SPARC64]: Fix so...
210
  	ba,pt	%xcc, etraptl1
4ccb92728   bob picco   sparc64: sun4v TL...
211
  1:	 or	%g7, %lo(1f), %g7
6320bcebc   David S. Miller   [SPARC64]: Fix hy...
212
  	mov	%l4, %o1
6c8927c96   David S. Miller   [SPARC64]: Fix so...
213
214
215
216
217
218
  	call	sun4v_itlb_error_report
  	 add	%sp, PTREGS_OFF, %o0
  
  	/* NOTREACHED */
  
  sun4v_dtlb_error:
4ccb92728   bob picco   sparc64: sun4v TL...
219
220
221
222
  	rdpr	%tl, %g1
  	cmp	%g1, 1
  	ble,pt	%icc, sun4v_bad_ra
  	 or	%g0, FAULT_CODE_BAD_RA | FAULT_CODE_DTLB, %g1
6c8927c96   David S. Miller   [SPARC64]: Fix so...
223
224
225
  	sethi	%hi(sun4v_err_dtlb_vaddr), %g1
  	stx	%g4, [%g1 + %lo(sun4v_err_dtlb_vaddr)]
  	sethi	%hi(sun4v_err_dtlb_ctx), %g1
8b2342744   David S. Miller   [SPARC64]: More T...
226
227
  	ldxa	[%g0] ASI_SCRATCHPAD, %g6
  	ldx	[%g6 + HV_FAULT_D_CTX_OFFSET], %o1
6c8927c96   David S. Miller   [SPARC64]: Fix so...
228
229
230
231
232
  	stx	%o1, [%g1 + %lo(sun4v_err_dtlb_ctx)]
  	sethi	%hi(sun4v_err_dtlb_pte), %g1
  	stx	%g3, [%g1 + %lo(sun4v_err_dtlb_pte)]
  	sethi	%hi(sun4v_err_dtlb_error), %g1
  	stx	%o0, [%g1 + %lo(sun4v_err_dtlb_error)]
4ccb92728   bob picco   sparc64: sun4v TL...
233
  	sethi	%hi(1f), %g7
6c8927c96   David S. Miller   [SPARC64]: Fix so...
234
  	rdpr	%tl, %g4
6c8927c96   David S. Miller   [SPARC64]: Fix so...
235
  	ba,pt	%xcc, etraptl1
4ccb92728   bob picco   sparc64: sun4v TL...
236
  1:	 or	%g7, %lo(1f), %g7
6320bcebc   David S. Miller   [SPARC64]: Fix hy...
237
  	mov	%l4, %o1
6c8927c96   David S. Miller   [SPARC64]: Fix so...
238
239
240
241
  	call	sun4v_dtlb_error_report
  	 add	%sp, PTREGS_OFF, %o0
  
  	/* NOTREACHED */
4ccb92728   bob picco   sparc64: sun4v TL...
242
243
244
245
246
247
  sun4v_bad_ra:
  	or	%g0, %g4, %g5
  	ba,pt	%xcc, sparc64_realfault_common
  	 or	%g1, %g0, %g4
  
  	/* NOTREACHED */
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
248
249
  	/* Instruction Access Exception, tl0. */
  sun4v_iacc:
12eaa328f   David S. Miller   [SPARC64]: Use AS...
250
251
252
253
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
  	ldx	[%g2 + HV_FAULT_I_TYPE_OFFSET], %g3
  	ldx	[%g2 + HV_FAULT_I_ADDR_OFFSET], %g4
  	ldx	[%g2 + HV_FAULT_I_CTX_OFFSET], %g5
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
254
255
256
257
258
259
260
261
  	sllx	%g3, 16, %g3
  	or	%g5, %g3, %g5
  	ba,pt	%xcc, etrap
  	 rd	%pc, %g7
  	mov	%l4, %o1
  	mov	%l5, %o2
  	call	sun4v_insn_access_exception
  	 add	%sp, PTREGS_OFF, %o0
7697daaa8   David S. Miller   [SPARC64]: %l6 tr...
262
  	ba,a,pt	%xcc, rtrap
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
263
264
265
  
  	/* Instruction Access Exception, tl1. */
  sun4v_iacc_tl1:
12eaa328f   David S. Miller   [SPARC64]: Use AS...
266
267
268
269
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
  	ldx	[%g2 + HV_FAULT_I_TYPE_OFFSET], %g3
  	ldx	[%g2 + HV_FAULT_I_ADDR_OFFSET], %g4
  	ldx	[%g2 + HV_FAULT_I_CTX_OFFSET], %g5
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
270
271
272
273
274
275
276
277
  	sllx	%g3, 16, %g3
  	or	%g5, %g3, %g5
  	ba,pt	%xcc, etraptl1
  	 rd	%pc, %g7
  	mov	%l4, %o1
  	mov	%l5, %o2
  	call	sun4v_insn_access_exception_tl1
  	 add	%sp, PTREGS_OFF, %o0
7697daaa8   David S. Miller   [SPARC64]: %l6 tr...
278
  	ba,a,pt	%xcc, rtrap
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
279
280
281
  
  	/* Data Access Exception, tl0. */
  sun4v_dacc:
12eaa328f   David S. Miller   [SPARC64]: Use AS...
282
283
284
285
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
  	ldx	[%g2 + HV_FAULT_D_TYPE_OFFSET], %g3
  	ldx	[%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
  	ldx	[%g2 + HV_FAULT_D_CTX_OFFSET], %g5
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
286
287
288
289
290
291
292
293
  	sllx	%g3, 16, %g3
  	or	%g5, %g3, %g5
  	ba,pt	%xcc, etrap
  	 rd	%pc, %g7
  	mov	%l4, %o1
  	mov	%l5, %o2
  	call	sun4v_data_access_exception
  	 add	%sp, PTREGS_OFF, %o0
7697daaa8   David S. Miller   [SPARC64]: %l6 tr...
294
  	ba,a,pt	%xcc, rtrap
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
295
296
297
  
  	/* Data Access Exception, tl1. */
  sun4v_dacc_tl1:
12eaa328f   David S. Miller   [SPARC64]: Use AS...
298
299
300
301
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
  	ldx	[%g2 + HV_FAULT_D_TYPE_OFFSET], %g3
  	ldx	[%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
  	ldx	[%g2 + HV_FAULT_D_CTX_OFFSET], %g5
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
302
303
304
305
306
307
308
309
  	sllx	%g3, 16, %g3
  	or	%g5, %g3, %g5
  	ba,pt	%xcc, etraptl1
  	 rd	%pc, %g7
  	mov	%l4, %o1
  	mov	%l5, %o2
  	call	sun4v_data_access_exception_tl1
  	 add	%sp, PTREGS_OFF, %o0
7697daaa8   David S. Miller   [SPARC64]: %l6 tr...
310
  	ba,a,pt	%xcc, rtrap
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
311
312
313
  
  	/* Memory Address Unaligned.  */
  sun4v_mna:
24c523ecc   David S. Miller   [SPARC64]: Fix un...
314
315
316
317
318
319
320
  	/* Window fixup? */
  	rdpr	%tl, %g2
  	cmp	%g2, 1
  	ble,pt	%icc, 1f
  	 nop
  
  	SET_GL(1)
bcc28ee0b   David S. Miller   [SPARC64]: Fix su...
321
322
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
  	ldx	[%g2 + HV_FAULT_D_ADDR_OFFSET], %g5
24c523ecc   David S. Miller   [SPARC64]: Fix un...
323
  	mov	HV_FAULT_TYPE_UNALIGNED, %g3
bcc28ee0b   David S. Miller   [SPARC64]: Fix su...
324
  	ldx	[%g2 + HV_FAULT_D_CTX_OFFSET], %g4
24c523ecc   David S. Miller   [SPARC64]: Fix un...
325
326
327
328
329
330
331
  	sllx	%g3, 16, %g3
  	or	%g4, %g3, %g4
  	ba,pt	%xcc, winfix_mna
  	 rdpr	%tpc, %g3
  	/* not reached */
  
  1:	ldxa	[%g0] ASI_SCRATCHPAD, %g2
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
332
  	mov	HV_FAULT_TYPE_UNALIGNED, %g3
12eaa328f   David S. Miller   [SPARC64]: Use AS...
333
334
  	ldx	[%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
  	ldx	[%g2 + HV_FAULT_D_CTX_OFFSET], %g5
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
335
336
  	sllx	%g3, 16, %g3
  	or	%g5, %g3, %g5
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
337
338
339
340
  	ba,pt	%xcc, etrap
  	 rd	%pc, %g7
  	mov	%l4, %o1
  	mov	%l5, %o2
9f8a5b843   David S. Miller   [SPARC64]: Fix C-...
341
  	call	sun4v_do_mna
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
342
  	 add	%sp, PTREGS_OFF, %o0
7697daaa8   David S. Miller   [SPARC64]: %l6 tr...
343
  	ba,a,pt	%xcc, rtrap
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
344
345
346
347
348
349
350
  
  	/* Privileged Action.  */
  sun4v_privact:
  	ba,pt	%xcc, etrap
  	 rd	%pc, %g7
  	call	do_privact
  	 add	%sp, PTREGS_OFF, %o0
7697daaa8   David S. Miller   [SPARC64]: %l6 tr...
351
  	ba,a,pt	%xcc, rtrap
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
352
353
354
  
  	/* Unaligned ldd float, tl0. */
  sun4v_lddfmna:
12eaa328f   David S. Miller   [SPARC64]: Use AS...
355
356
357
358
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
  	ldx	[%g2 + HV_FAULT_D_TYPE_OFFSET], %g3
  	ldx	[%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
  	ldx	[%g2 + HV_FAULT_D_CTX_OFFSET], %g5
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
359
360
361
362
363
364
365
366
  	sllx	%g3, 16, %g3
  	or	%g5, %g3, %g5
  	ba,pt	%xcc, etrap
  	 rd	%pc, %g7
  	mov	%l4, %o1
  	mov	%l5, %o2
  	call	handle_lddfmna
  	 add	%sp, PTREGS_OFF, %o0
7697daaa8   David S. Miller   [SPARC64]: %l6 tr...
367
  	ba,a,pt	%xcc, rtrap
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
368
369
370
  
  	/* Unaligned std float, tl0. */
  sun4v_stdfmna:
12eaa328f   David S. Miller   [SPARC64]: Use AS...
371
372
373
374
  	ldxa	[%g0] ASI_SCRATCHPAD, %g2
  	ldx	[%g2 + HV_FAULT_D_TYPE_OFFSET], %g3
  	ldx	[%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
  	ldx	[%g2 + HV_FAULT_D_CTX_OFFSET], %g5
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
375
376
377
378
379
380
381
382
  	sllx	%g3, 16, %g3
  	or	%g5, %g3, %g5
  	ba,pt	%xcc, etrap
  	 rd	%pc, %g7
  	mov	%l4, %o1
  	mov	%l5, %o2
  	call	handle_stdfmna
  	 add	%sp, PTREGS_OFF, %o0
7697daaa8   David S. Miller   [SPARC64]: %l6 tr...
383
  	ba,a,pt	%xcc, rtrap
aa9143b97   David S. Miller   [SPARC64]: Implem...
384

d257d5da3   David S. Miller   [SPARC64]: Initia...
385
386
387
388
389
390
391
392
393
  #define BRANCH_ALWAYS	0x10680000
  #define NOP		0x01000000
  #define SUN4V_DO_PATCH(OLD, NEW)	\
  	sethi	%hi(NEW), %g1; \
  	or	%g1, %lo(NEW), %g1; \
  	sethi	%hi(OLD), %g2; \
  	or	%g2, %lo(OLD), %g2; \
  	sub	%g1, %g2, %g1; \
  	sethi	%hi(BRANCH_ALWAYS), %g3; \
459b6e621   David S. Miller   [SPARC64]: Fix so...
394
395
  	sll	%g1, 11, %g1; \
  	srl	%g1, 11 + 2, %g1; \
d257d5da3   David S. Miller   [SPARC64]: Initia...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
  	or	%g3, %lo(BRANCH_ALWAYS), %g3; \
  	or	%g3, %g1, %g3; \
  	stw	%g3, [%g2]; \
  	sethi	%hi(NOP), %g3; \
  	or	%g3, %lo(NOP), %g3; \
  	stw	%g3, [%g2 + 0x4]; \
  	flush	%g2;
  
  	.globl	sun4v_patch_tlb_handlers
  	.type	sun4v_patch_tlb_handlers,#function
  sun4v_patch_tlb_handlers:
  	SUN4V_DO_PATCH(tl0_iamiss, sun4v_itlb_miss)
  	SUN4V_DO_PATCH(tl1_iamiss, sun4v_itlb_miss)
  	SUN4V_DO_PATCH(tl0_damiss, sun4v_dtlb_miss)
  	SUN4V_DO_PATCH(tl1_damiss, sun4v_dtlb_miss)
  	SUN4V_DO_PATCH(tl0_daprot, sun4v_dtlb_prot)
  	SUN4V_DO_PATCH(tl1_daprot, sun4v_dtlb_prot)
ed6b0b454   David S. Miller   [SPARC64]: SUN4V ...
413
414
415
416
417
418
419
420
421
  	SUN4V_DO_PATCH(tl0_iax, sun4v_iacc)
  	SUN4V_DO_PATCH(tl1_iax, sun4v_iacc_tl1)
  	SUN4V_DO_PATCH(tl0_dax, sun4v_dacc)
  	SUN4V_DO_PATCH(tl1_dax, sun4v_dacc_tl1)
  	SUN4V_DO_PATCH(tl0_mna, sun4v_mna)
  	SUN4V_DO_PATCH(tl1_mna, sun4v_mna)
  	SUN4V_DO_PATCH(tl0_lddfmna, sun4v_lddfmna)
  	SUN4V_DO_PATCH(tl0_stdfmna, sun4v_stdfmna)
  	SUN4V_DO_PATCH(tl0_privact, sun4v_privact)
d257d5da3   David S. Miller   [SPARC64]: Initia...
422
423
424
  	retl
  	 nop
  	.size	sun4v_patch_tlb_handlers,.-sun4v_patch_tlb_handlers