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