blob: e1fbf8c75787ce02ee840177d4556c4eeaf7d4c8 [file] [log] [blame]
David S. Millerd257d5d2006-02-06 23:44:37 -08001/* sun4v_tlb_miss.S: Sun4v TLB miss handlers.
2 *
3 * Copyright (C) 2006 <davem@davemloft.net>
4 */
5
6 .text
7 .align 32
8
David S. Miller36a68e72006-02-11 00:29:34 -08009 /* Load ITLB fault information into VADDR and CTX, using BASE. */
10#define LOAD_ITLB_INFO(BASE, VADDR, CTX) \
11 ldx [BASE + HV_FAULT_I_ADDR_OFFSET], VADDR; \
12 ldx [BASE + HV_FAULT_I_CTX_OFFSET], CTX;
David S. Millerd257d5d2006-02-06 23:44:37 -080013
David S. Miller36a68e72006-02-11 00:29:34 -080014 /* Load DTLB fault information into VADDR and CTX, using BASE. */
15#define LOAD_DTLB_INFO(BASE, VADDR, CTX) \
16 ldx [BASE + HV_FAULT_D_ADDR_OFFSET], VADDR; \
17 ldx [BASE + HV_FAULT_D_CTX_OFFSET], CTX;
18
David S. Miller8b234272006-02-17 18:01:02 -080019 /* DEST = (VADDR >> 22)
David S. Miller36a68e72006-02-11 00:29:34 -080020 *
David S. Millerbcc28ee2006-03-02 20:42:53 -080021 * Branch to ZERO_CTX_LABEL if context is zero.
David S. Millerd257d5d2006-02-06 23:44:37 -080022 */
David S. Miller8b234272006-02-17 18:01:02 -080023#define COMPUTE_TAG_TARGET(DEST, VADDR, CTX, ZERO_CTX_LABEL) \
24 srlx VADDR, 22, DEST; \
David S. Miller36a68e72006-02-11 00:29:34 -080025 brz,pn CTX, ZERO_CTX_LABEL; \
David S. Miller8b234272006-02-17 18:01:02 -080026 nop;
David S. Millerd257d5d2006-02-06 23:44:37 -080027
28 /* Create TSB pointer. This is something like:
29 *
30 * index_mask = (512 << (tsb_reg & 0x7UL)) - 1UL;
31 * tsb_base = tsb_reg & ~0x7UL;
David S. Millerdcc1e8d2006-03-22 00:49:59 -080032 * tsb_index = ((vaddr >> HASH_SHIFT) & tsb_mask);
David S. Millerd257d5d2006-02-06 23:44:37 -080033 * tsb_ptr = tsb_base + (tsb_index * 16);
34 */
David S. Millerdcc1e8d2006-03-22 00:49:59 -080035#define COMPUTE_TSB_PTR(TSB_PTR, VADDR, HASH_SHIFT, TMP1, TMP2) \
David S. Miller36a68e72006-02-11 00:29:34 -080036 and TSB_PTR, 0x7, TMP1; \
37 mov 512, TMP2; \
38 andn TSB_PTR, 0x7, TSB_PTR; \
39 sllx TMP2, TMP1, TMP2; \
David S. Millerdcc1e8d2006-03-22 00:49:59 -080040 srlx VADDR, HASH_SHIFT, TMP1; \
David S. Miller36a68e72006-02-11 00:29:34 -080041 sub TMP2, 1, TMP2; \
42 and TMP1, TMP2, TMP1; \
43 sllx TMP1, 4, TMP1; \
44 add TSB_PTR, TMP1, TSB_PTR;
45
46sun4v_itlb_miss:
47 /* Load MMU Miss base into %g2. */
48 ldxa [%g0] ASI_SCRATCHPAD, %g2
49
50 /* Load UTSB reg into %g1. */
51 mov SCRATCHPAD_UTSBREG1, %g1
52 ldxa [%g1] ASI_SCRATCHPAD, %g1
53
54 LOAD_ITLB_INFO(%g2, %g4, %g5)
David S. Miller8b234272006-02-17 18:01:02 -080055 COMPUTE_TAG_TARGET(%g6, %g4, %g5, kvmap_itlb_4v)
David S. Millerdcc1e8d2006-03-22 00:49:59 -080056 COMPUTE_TSB_PTR(%g1, %g4, PAGE_SHIFT, %g3, %g7)
David S. Millerd257d5d2006-02-06 23:44:37 -080057
58 /* Load TSB tag/pte into %g2/%g3 and compare the tag. */
David S. Millerc7f81d42006-02-15 21:21:17 -080059 ldda [%g1] ASI_QUAD_LDD_PHYS_4V, %g2
David S. Millerd257d5d2006-02-06 23:44:37 -080060 cmp %g2, %g6
David S. Millerd257d5d2006-02-06 23:44:37 -080061 bne,a,pn %xcc, tsb_miss_page_table_walk
62 mov FAULT_CODE_ITLB, %g3
David S. Miller45f791e2006-03-01 22:42:18 -080063 andcc %g3, _PAGE_EXEC_4V, %g0
David S. Millerd257d5d2006-02-06 23:44:37 -080064 be,a,pn %xcc, tsb_do_fault
65 mov FAULT_CODE_ITLB, %g3
66
67 /* We have a valid entry, make hypervisor call to load
68 * I-TLB and return from trap.
69 *
70 * %g3: PTE
71 * %g4: vaddr
David S. Millerd257d5d2006-02-06 23:44:37 -080072 */
73sun4v_itlb_load:
David S. Miller8b234272006-02-17 18:01:02 -080074 ldxa [%g0] ASI_SCRATCHPAD, %g6
David S. Millerd257d5d2006-02-06 23:44:37 -080075 mov %o0, %g1 ! save %o0
76 mov %o1, %g2 ! save %o1
77 mov %o2, %g5 ! save %o2
78 mov %o3, %g7 ! save %o3
79 mov %g4, %o0 ! vaddr
David S. Miller8b234272006-02-17 18:01:02 -080080 ldx [%g6 + HV_FAULT_I_CTX_OFFSET], %o1 ! ctx
David S. Millerd257d5d2006-02-06 23:44:37 -080081 mov %g3, %o2 ! PTE
82 mov HV_MMU_IMMU, %o3 ! flags
83 ta HV_MMU_MAP_ADDR_TRAP
David S. Miller6c8927c2006-02-17 14:58:02 -080084 brnz,pn %o0, sun4v_itlb_error
85 mov %g2, %o1 ! restore %o1
David S. Millerd257d5d2006-02-06 23:44:37 -080086 mov %g1, %o0 ! restore %o0
David S. Millerd257d5d2006-02-06 23:44:37 -080087 mov %g5, %o2 ! restore %o2
88 mov %g7, %o3 ! restore %o3
89
90 retry
91
92sun4v_dtlb_miss:
David S. Miller12eaa322006-02-10 15:39:51 -080093 /* Load MMU Miss base into %g2. */
94 ldxa [%g0] ASI_SCRATCHPAD, %g2
David S. Millerd257d5d2006-02-06 23:44:37 -080095
96 /* Load UTSB reg into %g1. */
David S. Miller12eaa322006-02-10 15:39:51 -080097 mov SCRATCHPAD_UTSBREG1, %g1
David S. Miller459b6e62006-02-11 12:21:20 -080098 ldxa [%g1] ASI_SCRATCHPAD, %g1
David S. Millerd257d5d2006-02-06 23:44:37 -080099
David S. Miller36a68e72006-02-11 00:29:34 -0800100 LOAD_DTLB_INFO(%g2, %g4, %g5)
David S. Miller8b234272006-02-17 18:01:02 -0800101 COMPUTE_TAG_TARGET(%g6, %g4, %g5, kvmap_dtlb_4v)
David S. Millerdcc1e8d2006-03-22 00:49:59 -0800102 COMPUTE_TSB_PTR(%g1, %g4, PAGE_SHIFT, %g3, %g7)
David S. Millerd257d5d2006-02-06 23:44:37 -0800103
104 /* Load TSB tag/pte into %g2/%g3 and compare the tag. */
David S. Millerc7f81d42006-02-15 21:21:17 -0800105 ldda [%g1] ASI_QUAD_LDD_PHYS_4V, %g2
David S. Millerd257d5d2006-02-06 23:44:37 -0800106 cmp %g2, %g6
107 bne,a,pn %xcc, tsb_miss_page_table_walk
David S. Miller92daa772006-03-01 22:27:09 -0800108 mov FAULT_CODE_DTLB, %g3
David S. Millerd257d5d2006-02-06 23:44:37 -0800109
110 /* We have a valid entry, make hypervisor call to load
111 * D-TLB and return from trap.
112 *
113 * %g3: PTE
114 * %g4: vaddr
David S. Millerd257d5d2006-02-06 23:44:37 -0800115 */
116sun4v_dtlb_load:
David S. Miller8b234272006-02-17 18:01:02 -0800117 ldxa [%g0] ASI_SCRATCHPAD, %g6
David S. Millerd257d5d2006-02-06 23:44:37 -0800118 mov %o0, %g1 ! save %o0
119 mov %o1, %g2 ! save %o1
120 mov %o2, %g5 ! save %o2
121 mov %o3, %g7 ! save %o3
122 mov %g4, %o0 ! vaddr
David S. Miller8b234272006-02-17 18:01:02 -0800123 ldx [%g6 + HV_FAULT_D_CTX_OFFSET], %o1 ! ctx
David S. Millerd257d5d2006-02-06 23:44:37 -0800124 mov %g3, %o2 ! PTE
125 mov HV_MMU_DMMU, %o3 ! flags
126 ta HV_MMU_MAP_ADDR_TRAP
David S. Miller6c8927c2006-02-17 14:58:02 -0800127 brnz,pn %o0, sun4v_dtlb_error
128 mov %g2, %o1 ! restore %o1
David S. Millerd257d5d2006-02-06 23:44:37 -0800129 mov %g1, %o0 ! restore %o0
David S. Millerd257d5d2006-02-06 23:44:37 -0800130 mov %g5, %o2 ! restore %o2
131 mov %g7, %o3 ! restore %o3
132
133 retry
134
135sun4v_dtlb_prot:
David S. Miller8b234272006-02-17 18:01:02 -0800136 SET_GL(1)
137
David S. Miller24c523e2006-02-18 16:39:39 -0800138 /* Load MMU Miss base into %g5. */
David S. Miller8b234272006-02-17 18:01:02 -0800139 ldxa [%g0] ASI_SCRATCHPAD, %g5
David S. Millerd257d5d2006-02-06 23:44:37 -0800140
David S. Miller8b234272006-02-17 18:01:02 -0800141 ldx [%g5 + HV_FAULT_D_ADDR_OFFSET], %g5
David S. Millerd257d5d2006-02-06 23:44:37 -0800142 rdpr %tl, %g1
143 cmp %g1, 1
David S. Miller8b234272006-02-17 18:01:02 -0800144 bgu,pn %xcc, winfix_trampoline
David S. Miller8b234272006-02-17 18:01:02 -0800145 mov FAULT_CODE_DTLB | FAULT_CODE_WRITE, %g4
David S. Miller86d43252007-01-26 18:48:16 -0800146 ba,pt %xcc, sparc64_realfault_common
147 nop
David S. Millerd257d5d2006-02-06 23:44:37 -0800148
David S. Miller24c523e2006-02-18 16:39:39 -0800149 /* Called from trap table:
150 * %g4: vaddr
151 * %g5: context
152 * %g6: TAG TARGET
David S. Milleraa9143b2006-02-09 16:12:22 -0800153 */
154sun4v_itsb_miss:
David S. Miller459b6e62006-02-11 12:21:20 -0800155 mov SCRATCHPAD_UTSBREG1, %g1
156 ldxa [%g1] ASI_SCRATCHPAD, %g1
157 brz,pn %g5, kvmap_itlb_4v
David S. Milleraa9143b2006-02-09 16:12:22 -0800158 mov FAULT_CODE_ITLB, %g3
David S. Miller6c8927c2006-02-17 14:58:02 -0800159 ba,a,pt %xcc, sun4v_tsb_miss_common
David S. Milleraa9143b2006-02-09 16:12:22 -0800160
David S. Miller24c523e2006-02-18 16:39:39 -0800161 /* Called from trap table:
162 * %g4: vaddr
163 * %g5: context
164 * %g6: TAG TARGET
David S. Milleraa9143b2006-02-09 16:12:22 -0800165 */
166sun4v_dtsb_miss:
David S. Miller459b6e62006-02-11 12:21:20 -0800167 mov SCRATCHPAD_UTSBREG1, %g1
168 ldxa [%g1] ASI_SCRATCHPAD, %g1
169 brz,pn %g5, kvmap_dtlb_4v
170 mov FAULT_CODE_DTLB, %g3
David S. Milleraa9143b2006-02-09 16:12:22 -0800171
David S. Miller24c523e2006-02-18 16:39:39 -0800172 /* fallthrough */
173
David S. Milleraa9143b2006-02-09 16:12:22 -0800174sun4v_tsb_miss_common:
David S. Millerdcc1e8d2006-03-22 00:49:59 -0800175 COMPUTE_TSB_PTR(%g1, %g4, PAGE_SHIFT, %g5, %g7)
David S. Miller36a68e72006-02-11 00:29:34 -0800176
David S. Miller36a68e72006-02-11 00:29:34 -0800177 sub %g2, TRAP_PER_CPU_FAULT_INFO, %g2
David S. Millerdcc1e8d2006-03-22 00:49:59 -0800178
179#ifdef CONFIG_HUGETLB_PAGE
180 mov SCRATCHPAD_UTSBREG2, %g5
181 ldxa [%g5] ASI_SCRATCHPAD, %g5
182 cmp %g5, -1
183 be,pt %xcc, 80f
184 nop
185 COMPUTE_TSB_PTR(%g5, %g4, HPAGE_SHIFT, %g2, %g7)
186
187 /* That clobbered %g2, reload it. */
188 ldxa [%g0] ASI_SCRATCHPAD, %g2
189 sub %g2, TRAP_PER_CPU_FAULT_INFO, %g2
190
19180: stx %g5, [%g2 + TRAP_PER_CPU_TSB_HUGE_TEMP]
192#endif
193
David S. Miller36a68e72006-02-11 00:29:34 -0800194 ba,pt %xcc, tsb_miss_page_table_walk_sun4v_fastpath
195 ldx [%g2 + TRAP_PER_CPU_PGD_PADDR], %g7
David S. Milleraa9143b2006-02-09 16:12:22 -0800196
David S. Miller6c8927c2006-02-17 14:58:02 -0800197sun4v_itlb_error:
198 sethi %hi(sun4v_err_itlb_vaddr), %g1
199 stx %g4, [%g1 + %lo(sun4v_err_itlb_vaddr)]
200 sethi %hi(sun4v_err_itlb_ctx), %g1
David S. Miller8b234272006-02-17 18:01:02 -0800201 ldxa [%g0] ASI_SCRATCHPAD, %g6
202 ldx [%g6 + HV_FAULT_I_CTX_OFFSET], %o1
David S. Miller6c8927c2006-02-17 14:58:02 -0800203 stx %o1, [%g1 + %lo(sun4v_err_itlb_ctx)]
204 sethi %hi(sun4v_err_itlb_pte), %g1
205 stx %g3, [%g1 + %lo(sun4v_err_itlb_pte)]
206 sethi %hi(sun4v_err_itlb_error), %g1
207 stx %o0, [%g1 + %lo(sun4v_err_itlb_error)]
208
209 rdpr %tl, %g4
210 cmp %g4, 1
211 ble,pt %icc, 1f
212 sethi %hi(2f), %g7
213 ba,pt %xcc, etraptl1
214 or %g7, %lo(2f), %g7
215
2161: ba,pt %xcc, etrap
2172: or %g7, %lo(2b), %g7
David S. Miller6320bce2008-01-17 01:32:09 -0800218 mov %l4, %o1
David S. Miller6c8927c2006-02-17 14:58:02 -0800219 call sun4v_itlb_error_report
220 add %sp, PTREGS_OFF, %o0
221
222 /* NOTREACHED */
223
224sun4v_dtlb_error:
225 sethi %hi(sun4v_err_dtlb_vaddr), %g1
226 stx %g4, [%g1 + %lo(sun4v_err_dtlb_vaddr)]
227 sethi %hi(sun4v_err_dtlb_ctx), %g1
David S. Miller8b234272006-02-17 18:01:02 -0800228 ldxa [%g0] ASI_SCRATCHPAD, %g6
229 ldx [%g6 + HV_FAULT_D_CTX_OFFSET], %o1
David S. Miller6c8927c2006-02-17 14:58:02 -0800230 stx %o1, [%g1 + %lo(sun4v_err_dtlb_ctx)]
231 sethi %hi(sun4v_err_dtlb_pte), %g1
232 stx %g3, [%g1 + %lo(sun4v_err_dtlb_pte)]
233 sethi %hi(sun4v_err_dtlb_error), %g1
234 stx %o0, [%g1 + %lo(sun4v_err_dtlb_error)]
235
236 rdpr %tl, %g4
237 cmp %g4, 1
238 ble,pt %icc, 1f
239 sethi %hi(2f), %g7
240 ba,pt %xcc, etraptl1
241 or %g7, %lo(2f), %g7
242
2431: ba,pt %xcc, etrap
2442: or %g7, %lo(2b), %g7
David S. Miller6320bce2008-01-17 01:32:09 -0800245 mov %l4, %o1
David S. Miller6c8927c2006-02-17 14:58:02 -0800246 call sun4v_dtlb_error_report
247 add %sp, PTREGS_OFF, %o0
248
249 /* NOTREACHED */
250
David S. Millered6b0b42006-02-09 20:20:34 -0800251 /* Instruction Access Exception, tl0. */
252sun4v_iacc:
David S. Miller12eaa322006-02-10 15:39:51 -0800253 ldxa [%g0] ASI_SCRATCHPAD, %g2
254 ldx [%g2 + HV_FAULT_I_TYPE_OFFSET], %g3
255 ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4
256 ldx [%g2 + HV_FAULT_I_CTX_OFFSET], %g5
David S. Millered6b0b42006-02-09 20:20:34 -0800257 sllx %g3, 16, %g3
258 or %g5, %g3, %g5
259 ba,pt %xcc, etrap
260 rd %pc, %g7
261 mov %l4, %o1
262 mov %l5, %o2
263 call sun4v_insn_access_exception
264 add %sp, PTREGS_OFF, %o0
David S. Miller7697daa2008-04-24 03:15:22 -0700265 ba,a,pt %xcc, rtrap
David S. Millered6b0b42006-02-09 20:20:34 -0800266
267 /* Instruction Access Exception, tl1. */
268sun4v_iacc_tl1:
David S. Miller12eaa322006-02-10 15:39:51 -0800269 ldxa [%g0] ASI_SCRATCHPAD, %g2
270 ldx [%g2 + HV_FAULT_I_TYPE_OFFSET], %g3
271 ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4
272 ldx [%g2 + HV_FAULT_I_CTX_OFFSET], %g5
David S. Millered6b0b42006-02-09 20:20:34 -0800273 sllx %g3, 16, %g3
274 or %g5, %g3, %g5
275 ba,pt %xcc, etraptl1
276 rd %pc, %g7
277 mov %l4, %o1
278 mov %l5, %o2
279 call sun4v_insn_access_exception_tl1
280 add %sp, PTREGS_OFF, %o0
David S. Miller7697daa2008-04-24 03:15:22 -0700281 ba,a,pt %xcc, rtrap
David S. Millered6b0b42006-02-09 20:20:34 -0800282
283 /* Data Access Exception, tl0. */
284sun4v_dacc:
David S. Miller12eaa322006-02-10 15:39:51 -0800285 ldxa [%g0] ASI_SCRATCHPAD, %g2
286 ldx [%g2 + HV_FAULT_D_TYPE_OFFSET], %g3
287 ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
288 ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g5
David S. Millered6b0b42006-02-09 20:20:34 -0800289 sllx %g3, 16, %g3
290 or %g5, %g3, %g5
291 ba,pt %xcc, etrap
292 rd %pc, %g7
293 mov %l4, %o1
294 mov %l5, %o2
295 call sun4v_data_access_exception
296 add %sp, PTREGS_OFF, %o0
David S. Miller7697daa2008-04-24 03:15:22 -0700297 ba,a,pt %xcc, rtrap
David S. Millered6b0b42006-02-09 20:20:34 -0800298
299 /* Data Access Exception, tl1. */
300sun4v_dacc_tl1:
David S. Miller12eaa322006-02-10 15:39:51 -0800301 ldxa [%g0] ASI_SCRATCHPAD, %g2
302 ldx [%g2 + HV_FAULT_D_TYPE_OFFSET], %g3
303 ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
304 ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g5
David S. Millered6b0b42006-02-09 20:20:34 -0800305 sllx %g3, 16, %g3
306 or %g5, %g3, %g5
307 ba,pt %xcc, etraptl1
308 rd %pc, %g7
309 mov %l4, %o1
310 mov %l5, %o2
311 call sun4v_data_access_exception_tl1
312 add %sp, PTREGS_OFF, %o0
David S. Miller7697daa2008-04-24 03:15:22 -0700313 ba,a,pt %xcc, rtrap
David S. Millered6b0b42006-02-09 20:20:34 -0800314
315 /* Memory Address Unaligned. */
316sun4v_mna:
David S. Miller24c523e2006-02-18 16:39:39 -0800317 /* Window fixup? */
318 rdpr %tl, %g2
319 cmp %g2, 1
320 ble,pt %icc, 1f
321 nop
322
323 SET_GL(1)
David S. Millerbcc28ee2006-03-02 20:42:53 -0800324 ldxa [%g0] ASI_SCRATCHPAD, %g2
325 ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g5
David S. Miller24c523e2006-02-18 16:39:39 -0800326 mov HV_FAULT_TYPE_UNALIGNED, %g3
David S. Millerbcc28ee2006-03-02 20:42:53 -0800327 ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g4
David S. Miller24c523e2006-02-18 16:39:39 -0800328 sllx %g3, 16, %g3
329 or %g4, %g3, %g4
330 ba,pt %xcc, winfix_mna
331 rdpr %tpc, %g3
332 /* not reached */
333
3341: ldxa [%g0] ASI_SCRATCHPAD, %g2
David S. Millered6b0b42006-02-09 20:20:34 -0800335 mov HV_FAULT_TYPE_UNALIGNED, %g3
David S. Miller12eaa322006-02-10 15:39:51 -0800336 ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
337 ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g5
David S. Millered6b0b42006-02-09 20:20:34 -0800338 sllx %g3, 16, %g3
339 or %g5, %g3, %g5
340
David S. Millered6b0b42006-02-09 20:20:34 -0800341 ba,pt %xcc, etrap
342 rd %pc, %g7
343 mov %l4, %o1
344 mov %l5, %o2
David S. Miller9f8a5b82006-02-14 16:39:22 -0800345 call sun4v_do_mna
David S. Millered6b0b42006-02-09 20:20:34 -0800346 add %sp, PTREGS_OFF, %o0
David S. Miller7697daa2008-04-24 03:15:22 -0700347 ba,a,pt %xcc, rtrap
David S. Millered6b0b42006-02-09 20:20:34 -0800348
349 /* Privileged Action. */
350sun4v_privact:
351 ba,pt %xcc, etrap
352 rd %pc, %g7
353 call do_privact
354 add %sp, PTREGS_OFF, %o0
David S. Miller7697daa2008-04-24 03:15:22 -0700355 ba,a,pt %xcc, rtrap
David S. Millered6b0b42006-02-09 20:20:34 -0800356
357 /* Unaligned ldd float, tl0. */
358sun4v_lddfmna:
David S. Miller12eaa322006-02-10 15:39:51 -0800359 ldxa [%g0] ASI_SCRATCHPAD, %g2
360 ldx [%g2 + HV_FAULT_D_TYPE_OFFSET], %g3
361 ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
362 ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g5
David S. Millered6b0b42006-02-09 20:20:34 -0800363 sllx %g3, 16, %g3
364 or %g5, %g3, %g5
365 ba,pt %xcc, etrap
366 rd %pc, %g7
367 mov %l4, %o1
368 mov %l5, %o2
369 call handle_lddfmna
370 add %sp, PTREGS_OFF, %o0
David S. Miller7697daa2008-04-24 03:15:22 -0700371 ba,a,pt %xcc, rtrap
David S. Millered6b0b42006-02-09 20:20:34 -0800372
373 /* Unaligned std float, tl0. */
374sun4v_stdfmna:
David S. Miller12eaa322006-02-10 15:39:51 -0800375 ldxa [%g0] ASI_SCRATCHPAD, %g2
376 ldx [%g2 + HV_FAULT_D_TYPE_OFFSET], %g3
377 ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g4
378 ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g5
David S. Millered6b0b42006-02-09 20:20:34 -0800379 sllx %g3, 16, %g3
380 or %g5, %g3, %g5
381 ba,pt %xcc, etrap
382 rd %pc, %g7
383 mov %l4, %o1
384 mov %l5, %o2
385 call handle_stdfmna
386 add %sp, PTREGS_OFF, %o0
David S. Miller7697daa2008-04-24 03:15:22 -0700387 ba,a,pt %xcc, rtrap
David S. Milleraa9143b2006-02-09 16:12:22 -0800388
David S. Millerd257d5d2006-02-06 23:44:37 -0800389#define BRANCH_ALWAYS 0x10680000
390#define NOP 0x01000000
391#define SUN4V_DO_PATCH(OLD, NEW) \
392 sethi %hi(NEW), %g1; \
393 or %g1, %lo(NEW), %g1; \
394 sethi %hi(OLD), %g2; \
395 or %g2, %lo(OLD), %g2; \
396 sub %g1, %g2, %g1; \
397 sethi %hi(BRANCH_ALWAYS), %g3; \
David S. Miller459b6e62006-02-11 12:21:20 -0800398 sll %g1, 11, %g1; \
399 srl %g1, 11 + 2, %g1; \
David S. Millerd257d5d2006-02-06 23:44:37 -0800400 or %g3, %lo(BRANCH_ALWAYS), %g3; \
401 or %g3, %g1, %g3; \
402 stw %g3, [%g2]; \
403 sethi %hi(NOP), %g3; \
404 or %g3, %lo(NOP), %g3; \
405 stw %g3, [%g2 + 0x4]; \
406 flush %g2;
407
408 .globl sun4v_patch_tlb_handlers
409 .type sun4v_patch_tlb_handlers,#function
410sun4v_patch_tlb_handlers:
411 SUN4V_DO_PATCH(tl0_iamiss, sun4v_itlb_miss)
412 SUN4V_DO_PATCH(tl1_iamiss, sun4v_itlb_miss)
413 SUN4V_DO_PATCH(tl0_damiss, sun4v_dtlb_miss)
414 SUN4V_DO_PATCH(tl1_damiss, sun4v_dtlb_miss)
415 SUN4V_DO_PATCH(tl0_daprot, sun4v_dtlb_prot)
416 SUN4V_DO_PATCH(tl1_daprot, sun4v_dtlb_prot)
David S. Millered6b0b42006-02-09 20:20:34 -0800417 SUN4V_DO_PATCH(tl0_iax, sun4v_iacc)
418 SUN4V_DO_PATCH(tl1_iax, sun4v_iacc_tl1)
419 SUN4V_DO_PATCH(tl0_dax, sun4v_dacc)
420 SUN4V_DO_PATCH(tl1_dax, sun4v_dacc_tl1)
421 SUN4V_DO_PATCH(tl0_mna, sun4v_mna)
422 SUN4V_DO_PATCH(tl1_mna, sun4v_mna)
423 SUN4V_DO_PATCH(tl0_lddfmna, sun4v_lddfmna)
424 SUN4V_DO_PATCH(tl0_stdfmna, sun4v_stdfmna)
425 SUN4V_DO_PATCH(tl0_privact, sun4v_privact)
David S. Millerd257d5d2006-02-06 23:44:37 -0800426 retl
427 nop
428 .size sun4v_patch_tlb_handlers,.-sun4v_patch_tlb_handlers