Print this page
de-linting of .s files
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/sun4u/ml/wbuf.s
+++ new/usr/src/uts/sun4u/ml/wbuf.s
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 26 #include <sys/asm_linkage.h>
29 27 #include <sys/machthread.h>
30 28 #include <sys/privregs.h>
31 29 #include <sys/machasi.h>
32 30 #include <sys/trap.h>
33 31 #include <sys/mmu.h>
34 32 #include <sys/machparam.h>
35 33 #include <sys/machtrap.h>
36 34 #include <sys/traptrace.h>
37 35
38 -#if !defined(lint)
39 36 #include "assym.h"
40 37
41 38 /*
42 39 * Spill fault handlers
43 40 * sn0 - spill normal tl 0
44 41 * sn1 - spill normal tl >0
45 42 * so0 - spill other tl 0
46 43 * so1 - spill other tl >0
47 44 */
48 45
49 46 ENTRY_NP(fault_32bit_sn0)
50 47 !
51 48 FAULT_WINTRACE(%g1, %g2, %g3, TT_F32_SN0)
52 49 !
53 50 ! Spill normal tl0 fault.
54 51 ! This happens when a user tries to spill to an unmapped or
55 52 ! misaligned stack. We handle an unmapped stack by simulating
56 53 ! a pagefault at the trap pc and a misaligned stack by generating
57 54 ! a user alignment trap.
58 55 !
59 56 ! spill the window into wbuf slot 0
60 57 ! (we know wbuf is empty since we came from user mode)
61 58 !
62 59 ! g5 = mmu trap type, g6 = tag access reg (g5 != T_ALIGNMENT) or
63 60 ! sfar (g5 == T_ALIGNMENT)
64 61 !
65 62 CPU_ADDR(%g4, %g1)
66 63 ldn [%g4 + CPU_MPCB], %g1
67 64 stn %sp, [%g1 + MPCB_SPBUF]
68 65 ldn [%g1 + MPCB_WBUF], %g2
69 66 SAVE_V8WINDOW(%g2)
70 67 mov 1, %g2
71 68 st %g2, [%g1 + MPCB_WBCNT]
72 69 saved
73 70 !
74 71 ! setup user_trap args
75 72 !
76 73 set sfmmu_tsbmiss_exception, %g1
77 74 mov %g6, %g2 ! arg2 = tagaccess
78 75 mov T_WIN_OVERFLOW, %g3 ! arg3 = traptype
79 76 cmp %g5, T_ALIGNMENT
80 77 bne %icc, 1f
81 78 nop
82 79 set trap, %g1
83 80 mov T_ALIGNMENT, %g3
84 81 1:
85 82 sub %g0, 1, %g4
86 83 !
87 84 ! spill traps increment %cwp by 2,
88 85 ! but user_trap wants the trap %cwp
89 86 !
90 87 rdpr %tstate, %g5
91 88 and %g5, TSTATE_CWP, %g5
92 89 ba,pt %xcc, user_trap
93 90 wrpr %g0, %g5, %cwp
94 91 SET_SIZE(fault_32bit_sn0)
95 92
96 93 !
97 94 ! Spill normal tl1 fault.
98 95 ! This happens when sys_trap's save spills to an unmapped stack.
99 96 ! We handle it by spilling the window to the wbuf and trying
100 97 ! sys_trap again.
101 98 !
102 99 ! spill the window into wbuf slot 0
103 100 ! (we know wbuf is empty since we came from user mode)
104 101 !
105 102 ENTRY_NP(fault_32bit_sn1)
106 103 FAULT_WINTRACE(%g5, %g6, %g7, TT_F32_SN1)
107 104 CPU_ADDR(%g5, %g6)
108 105 ldn [%g5 + CPU_MPCB], %g6
109 106 stn %sp, [%g6 + MPCB_SPBUF]
110 107 ldn [%g6 + MPCB_WBUF], %g5
111 108 SAVE_V8WINDOW(%g5)
112 109 mov 1, %g5
113 110 st %g5, [%g6 + MPCB_WBCNT]
114 111 saved
115 112 set sys_trap, %g5
116 113 wrpr %g5, %tnpc
117 114 done
118 115 SET_SIZE(fault_32bit_sn1)
119 116
120 117 ENTRY_NP(fault_32bit_so0)
121 118 !
122 119 FAULT_WINTRACE(%g5, %g6, %g1, TT_F32_SO0)
123 120 !
124 121 ! Spill other tl0 fault.
125 122 ! This happens when the kernel spills a user window and that
126 123 ! user's stack has been unmapped.
127 124 ! We handle it by spilling the window into the user's wbuf.
128 125 !
129 126 ! find lwp & increment wbcnt
130 127 !
131 128 CPU_ADDR(%g5, %g6)
132 129 ldn [%g5 + CPU_MPCB], %g1
133 130 ld [%g1 + MPCB_WBCNT], %g2
134 131 add %g2, 1, %g3
135 132 st %g3, [%g1 + MPCB_WBCNT]
136 133 !
137 134 ! use previous wbcnt to spill new spbuf & wbuf
138 135 !
139 136 sll %g2, CPTRSHIFT, %g4 ! spbuf size is sizeof (caddr_t)
140 137 add %g1, MPCB_SPBUF, %g3
141 138 stn %sp, [%g3 + %g4]
142 139 sll %g2, RWIN32SHIFT, %g4
143 140 ldn [%g1 + MPCB_WBUF], %g3
144 141 add %g3, %g4, %g3
145 142 SAVE_V8WINDOW(%g3)
146 143 saved
147 144 retry
148 145 SET_SIZE(fault_32bit_so0)
149 146
150 147 !
151 148 ! Spill other tl1 fault.
152 149 ! This happens when priv_trap spills a user window and that
153 150 ! user's stack has been unmapped.
154 151 ! We handle it by spilling the window to the wbuf and retrying
155 152 ! the save.
156 153 !
157 154 ENTRY_NP(fault_32bit_so1)
158 155 FAULT_WINTRACE(%g5, %g6, %g7, TT_F32_SO1)
159 156 CPU_ADDR(%g5, %g6)
160 157 !
161 158 ! find lwp & increment wbcnt
162 159 !
163 160 ldn [%g5 + CPU_MPCB], %g6
164 161 ld [%g6 + MPCB_WBCNT], %g5
165 162 add %g5, 1, %g7
166 163 st %g7, [%g6 + MPCB_WBCNT]
167 164 !
168 165 ! use previous wbcnt to spill new spbuf & wbuf
169 166 !
170 167 sll %g5, CPTRSHIFT, %g7 ! spbuf size is sizeof (caddr_t)
171 168 add %g6, %g7, %g7
172 169 stn %sp, [%g7 + MPCB_SPBUF]
173 170 sll %g5, RWIN32SHIFT, %g7
174 171 ldn [%g6 + MPCB_WBUF], %g5
175 172 add %g5, %g7, %g7
176 173 SAVE_V8WINDOW(%g7)
177 174 saved
178 175 set sys_trap, %g5
179 176 wrpr %g5, %tnpc
180 177 done
181 178 SET_SIZE(fault_32bit_so1)
182 179
183 180 ENTRY_NP(fault_64bit_sn0)
184 181 !
185 182 FAULT_WINTRACE(%g1, %g2, %g3, TT_F64_SN0)
186 183 !
187 184 ! Spill normal tl0 fault.
188 185 ! This happens when a user tries to spill to an unmapped or
189 186 ! misaligned stack. We handle an unmapped stack by simulating
190 187 ! a pagefault at the trap pc and a misaligned stack by generating
191 188 ! a user alignment trap.
192 189 !
193 190 ! spill the window into wbuf slot 0
194 191 ! (we know wbuf is empty since we came from user mode)
195 192 !
196 193 ! g5 = mmu trap type, g6 = tag access reg (g5 != T_ALIGNMENT) or
197 194 ! sfar (g5 == T_ALIGNMENT)
198 195 !
199 196 CPU_ADDR(%g4, %g1)
200 197 ldn [%g4 + CPU_MPCB], %g1
201 198 stn %sp, [%g1 + MPCB_SPBUF]
202 199 ldn [%g1 + MPCB_WBUF], %g2
203 200 SAVE_V9WINDOW(%g2)
204 201 mov 1, %g2
205 202 st %g2, [%g1 + MPCB_WBCNT]
206 203 saved
207 204 !
208 205 ! setup user_trap args
209 206 !
210 207 set sfmmu_tsbmiss_exception, %g1
211 208 mov %g6, %g2 ! arg2 = tagaccess
212 209 mov %g5, %g3 ! arg3 = traptype
213 210 cmp %g5, T_ALIGNMENT
214 211 bne %icc, 1f
215 212 nop
216 213 set trap, %g1
217 214 mov T_ALIGNMENT, %g3
218 215 1:
219 216 sub %g0, 1, %g4
220 217 !
221 218 ! spill traps increment %cwp by 2,
222 219 ! but user_trap wants the trap %cwp
223 220 !
224 221 rdpr %tstate, %g5
225 222 and %g5, TSTATE_CWP, %g5
226 223 ba,pt %xcc, user_trap
227 224 wrpr %g0, %g5, %cwp
228 225 SET_SIZE(fault_64bit_sn0)
229 226
230 227 !
231 228 ! Spill normal tl1 fault.
232 229 ! This happens when sys_trap's save spills to an unmapped stack.
233 230 ! We handle it by spilling the window to the wbuf and trying
234 231 ! sys_trap again.
235 232 !
236 233 ! spill the window into wbuf slot 0
237 234 ! (we know wbuf is empty since we came from user mode)
238 235 !
239 236 ENTRY_NP(fault_64bit_sn1)
240 237 FAULT_WINTRACE(%g5, %g6, %g7, TT_F64_SN1)
241 238 CPU_ADDR(%g5, %g6)
242 239 ldn [%g5 + CPU_MPCB], %g6
243 240 stn %sp, [%g6 + MPCB_SPBUF]
244 241 ldn [%g6 + MPCB_WBUF], %g5
245 242 SAVE_V9WINDOW(%g5)
246 243 mov 1, %g5
247 244 st %g5, [%g6 + MPCB_WBCNT]
248 245 saved
249 246 set sys_trap, %g5
250 247 wrpr %g5, %tnpc
251 248 done
252 249 SET_SIZE(fault_64bit_sn1)
253 250
254 251 ENTRY_NP(fault_64bit_so0)
255 252 !
256 253 FAULT_WINTRACE(%g5, %g6, %g1, TT_F64_SO0)
257 254 !
258 255 ! Spill other tl0 fault.
259 256 ! This happens when the kernel spills a user window and that
260 257 ! user's stack has been unmapped.
261 258 ! We handle it by spilling the window into the user's wbuf.
262 259 !
263 260 ! find lwp & increment wbcnt
264 261 !
265 262 CPU_ADDR(%g5, %g6)
266 263 ldn [%g5 + CPU_MPCB], %g1
267 264 ld [%g1 + MPCB_WBCNT], %g2
268 265 add %g2, 1, %g3
269 266 st %g3, [%g1 + MPCB_WBCNT]
270 267 !
271 268 ! use previous wbcnt to spill new spbuf & wbuf
272 269 !
273 270 sll %g2, CPTRSHIFT, %g4 ! spbuf size is sizeof (caddr_t)
274 271 add %g1, MPCB_SPBUF, %g3
275 272 stn %sp, [%g3 + %g4]
276 273 sll %g2, RWIN64SHIFT, %g4
277 274 ldn [%g1 + MPCB_WBUF], %g3
278 275 add %g3, %g4, %g3
279 276 SAVE_V9WINDOW(%g3)
280 277 saved
281 278 retry
282 279 SET_SIZE(fault_64bit_so0)
283 280
284 281 !
285 282 ! Spill other tl1 fault.
286 283 ! This happens when priv_trap spills a user window and that
287 284 ! user's stack has been unmapped.
288 285 ! We handle it by spilling the window to the wbuf and retrying
289 286 ! the save.
290 287 !
291 288 ENTRY_NP(fault_64bit_so1)
292 289 FAULT_WINTRACE(%g5, %g6, %g7, TT_F64_SO1)
293 290 CPU_ADDR(%g5, %g6)
294 291 !
295 292 ! find lwp & increment wbcnt
296 293 !
297 294 ldn [%g5 + CPU_MPCB], %g6
298 295 ld [%g6 + MPCB_WBCNT], %g5
299 296 add %g5, 1, %g7
300 297 st %g7, [%g6 + MPCB_WBCNT]
301 298 !
302 299 ! use previous wbcnt to spill new spbuf & wbuf
303 300 !
304 301 sll %g5, CPTRSHIFT, %g7 ! spbuf size is sizeof (caddr_t)
305 302 add %g6, %g7, %g7
306 303 stn %sp, [%g7 + MPCB_SPBUF]
307 304 sll %g5, RWIN64SHIFT, %g7
308 305 ldn [%g6 + MPCB_WBUF], %g5
309 306 add %g5, %g7, %g7
310 307 SAVE_V9WINDOW(%g7)
311 308 saved
312 309 set sys_trap, %g5
313 310 wrpr %g5, %tnpc
314 311 done
315 312 SET_SIZE(fault_64bit_so1)
316 313
317 314 /*
318 315 * Fill fault handlers
319 316 * fn0 - fill normal tl 0
320 317 * fn1 - fill normal tl 1
321 318 */
322 319
323 320 ENTRY_NP(fault_32bit_fn0)
324 321 !
325 322 FAULT_WINTRACE(%g1, %g2, %g3, TT_F32_FN0)
326 323 !
327 324 .fault_fn0_common:
328 325 !
329 326 ! Fill normal tl0 fault.
330 327 ! This happens when a user tries to fill to an unmapped or
331 328 ! misaligned stack. We handle an unmapped stack by simulating
332 329 ! a pagefault at the trap pc and a misaligned stack by generating
333 330 ! a user alignment trap.
334 331 !
335 332 ! setup user_trap args
336 333 !
337 334 ! g5 = mmu trap type, g6 = tag access reg (g5 != T_ALIGNMENT) or
338 335 ! sfar (g5 == T_ALIGNMENT)
339 336 !
340 337 set sfmmu_tsbmiss_exception, %g1
341 338 mov %g6, %g2 ! arg2 = tagaccess
342 339 mov T_WIN_UNDERFLOW, %g3
343 340 cmp %g5, T_ALIGNMENT
344 341 bne %icc, 1f
345 342 nop
346 343 set trap, %g1
347 344 mov T_ALIGNMENT, %g3
348 345 1:
349 346 sub %g0, 1, %g4
350 347 !
351 348 ! sys_trap wants %cwp to be the same as when the trap occured,
352 349 ! so set it from %tstate
353 350 !
354 351 rdpr %tstate, %g5
355 352 and %g5, TSTATE_CWP, %g5
356 353 ba,pt %xcc, user_trap
357 354 wrpr %g0, %g5, %cwp
358 355 SET_SIZE(fault_32bit_fn0)
359 356
360 357 ENTRY_NP(fault_32bit_fn1)
361 358 !
362 359 FAULT_WINTRACE(%g1, %g2, %g3, TT_F32_FN1)
363 360 !
364 361 .fault_fn1_common:
365 362 !
366 363 ! Fill normal tl1 fault.
367 364 ! This happens when user_rtt's restore fills from an unmapped or
368 365 ! misaligned stack. We handle an unmapped stack by simulating
369 366 ! a pagefault at user_rtt and a misaligned stack by generating
370 367 ! a RTT alignment trap.
371 368 !
372 369 ! save fault addr & fix %cwp
373 370 !
374 371 rdpr %tstate, %g1
375 372 and %g1, TSTATE_CWP, %g1
376 373 wrpr %g0, %g1, %cwp
377 374 !
378 375 ! fake tl1 traps regs so that after pagefault runs, we
379 376 ! re-execute at user_rtt.
380 377 !
381 378 wrpr %g0, 1, %tl
382 379 set TSTATE_KERN | TSTATE_IE, %g1
383 380 wrpr %g0, %g1, %tstate
384 381 set user_rtt, %g1
385 382 wrpr %g0, %g1, %tpc
386 383 add %g1, 4, %g1
387 384 wrpr %g0, %g1, %tnpc
388 385 !
389 386 ! setup sys_trap args
390 387 !
391 388 ! g5 = mmu trap type, g6 = tag access reg (g5 != T_ALIGNMENT) or
392 389 ! sfar (g5 == T_ALIGNMENT)
393 390 !
394 391 set sfmmu_tsbmiss_exception, %g1
395 392 mov %g6, %g2 ! arg2 = tagaccess
396 393 set T_USER | T_SYS_RTT_PAGE, %g3 ! arg3 = traptype
397 394 cmp %g5, T_ALIGNMENT
398 395 bne %icc, 1f
399 396 nop
400 397 set trap, %g1
401 398 set T_USER | T_SYS_RTT_ALIGN, %g3
402 399 1:
403 400 sub %g0, 1, %g4
404 401 !
405 402 ! setup to run kernel again by setting THREAD_REG, %wstate
406 403 ! and the mmu to their kernel values.
407 404 !
408 405 rdpr %pstate, %l1
409 406 wrpr %l1, PSTATE_AG, %pstate
410 407 mov %l6, THREAD_REG ! %l6 is user_rtt's thread
411 408 wrpr %g0, %l1, %pstate
412 409 rdpr %wstate, %l1
413 410 sllx %l1, WSTATE_SHIFT, %l1
414 411 wrpr %l1, WSTATE_K64, %wstate
415 412 sethi %hi(kcontextreg), %g5 ! mov KCONTEXT, %g5
416 413 ldx [%g5 + %lo(kcontextreg)], %g5
417 414 mov MMU_PCONTEXT, %g6
418 415 ldxa [%g6]ASI_MMU_CTX, %g7
419 416 xor %g5, %g7, %g7
420 417 srlx %g7, CTXREG_NEXT_SHIFT, %g7
421 418 brz %g7, 1f ! if N_pgsz0/1 changed, need demap
422 419 nop
423 420 mov DEMAP_ALL_TYPE, %g7
424 421 stxa %g0, [%g7]ASI_DTLB_DEMAP
425 422 stxa %g0, [%g7]ASI_ITLB_DEMAP
426 423 1:
427 424 stxa %g5, [%g6]ASI_MMU_CTX
428 425 sethi %hi(FLUSH_ADDR), %g5
429 426 flush %g5
430 427
431 428 ba,pt %xcc, priv_trap
432 429 nop
433 430 SET_SIZE(fault_32bit_fn1)
434 431
435 432 ENTRY_NP(fault_64bit_fn0)
436 433 FAULT_WINTRACE(%g1, %g2, %g3, TT_F64_FN0)
437 434 b .fault_fn0_common
438 435 nop
439 436 SET_SIZE(fault_64bit_fn0)
440 437
441 438 ENTRY_NP(fault_64bit_fn1)
442 439 FAULT_WINTRACE(%g1, %g2, %g3, TT_F64_FN1)
443 440 b .fault_fn1_common
444 441 nop
445 442 SET_SIZE(fault_64bit_fn1)
↓ open down ↓ |
397 lines elided |
↑ open up ↑ |
446 443
447 444 /*
448 445 * Kernel fault handlers
449 446 */
450 447 ENTRY_NP(fault_32bit_not)
451 448 ENTRY_NP(fault_64bit_not)
452 449 ba,pt %xcc, ptl1_panic
453 450 mov PTL1_BAD_WTRAP, %g1
454 451 SET_SIZE(fault_32bit_not)
455 452 SET_SIZE(fault_64bit_not)
456 -#endif /* !lint */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX