1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _SPARC64_TTABLE_H 3 #define _SPARC64_TTABLE_H 4 5 #include <asm/utrap.h> 6 #include <asm/pil.h> 7 8 #ifdef __ASSEMBLY__ 9 #include <asm/thread_info.h> 10 #endif 11 12 #define BOOT_KERNEL b sparc64_boot; nop; nop; nop; nop; nop; nop; nop; 13 14 /* We need a "cleaned" instruction... */ 15 #define CLEAN_WINDOW \ 16 rdpr %cleanwin, %l0; add %l0, 1, %l0; \ 17 wrpr %l0, 0x0, %cleanwin; \ 18 clr %o0; clr %o1; clr %o2; clr %o3; \ 19 clr %o4; clr %o5; clr %o6; clr %o7; \ 20 clr %l0; clr %l1; clr %l2; clr %l3; \ 21 clr %l4; clr %l5; clr %l6; clr %l7; \ 22 retry; \ 23 nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop; 24 25 #define TRAP(routine) \ 26 sethi %hi(109f), %g7; \ 27 ba,pt %xcc, etrap; \ 28 109: or %g7, %lo(109b), %g7; \ 29 call routine; \ 30 add %sp, PTREGS_OFF, %o0; \ 31 ba,pt %xcc, rtrap; \ 32 nop; \ 33 nop; 34 35 #define TRAP_7INSNS(routine) \ 36 sethi %hi(109f), %g7; \ 37 ba,pt %xcc, etrap; \ 38 109: or %g7, %lo(109b), %g7; \ 39 call routine; \ 40 add %sp, PTREGS_OFF, %o0; \ 41 ba,pt %xcc, rtrap; \ 42 nop; 43 44 #define TRAP_SAVEFPU(routine) \ 45 sethi %hi(109f), %g7; \ 46 ba,pt %xcc, do_fptrap; \ 47 109: or %g7, %lo(109b), %g7; \ 48 call routine; \ 49 add %sp, PTREGS_OFF, %o0; \ 50 ba,pt %xcc, rtrap; \ 51 nop; \ 52 nop; 53 54 #define TRAP_NOSAVE(routine) \ 55 ba,pt %xcc, routine; \ 56 nop; \ 57 nop; nop; nop; nop; nop; nop; 58 59 #define TRAP_NOSAVE_7INSNS(routine) \ 60 ba,pt %xcc, routine; \ 61 nop; \ 62 nop; nop; nop; nop; nop; 63 64 #define TRAPTL1(routine) \ 65 sethi %hi(109f), %g7; \ 66 ba,pt %xcc, etraptl1; \ 67 109: or %g7, %lo(109b), %g7; \ 68 call routine; \ 69 add %sp, PTREGS_OFF, %o0; \ 70 ba,pt %xcc, rtrap; \ 71 nop; \ 72 nop; 73 74 #define TRAP_ARG(routine, arg) \ 75 sethi %hi(109f), %g7; \ 76 ba,pt %xcc, etrap; \ 77 109: or %g7, %lo(109b), %g7; \ 78 add %sp, PTREGS_OFF, %o0; \ 79 call routine; \ 80 mov arg, %o1; \ 81 ba,pt %xcc, rtrap; \ 82 nop; 83 84 #define TRAPTL1_ARG(routine, arg) \ 85 sethi %hi(109f), %g7; \ 86 ba,pt %xcc, etraptl1; \ 87 109: or %g7, %lo(109b), %g7; \ 88 add %sp, PTREGS_OFF, %o0; \ 89 call routine; \ 90 mov arg, %o1; \ 91 ba,pt %xcc, rtrap; \ 92 nop; 93 94 #define SYSCALL_TRAP(routine, systbl) \ 95 rdpr %pil, %g2; \ 96 mov TSTATE_SYSCALL, %g3; \ 97 sethi %hi(109f), %g7; \ 98 ba,pt %xcc, etrap_syscall; \ 99 109: or %g7, %lo(109b), %g7; \ 100 sethi %hi(systbl), %l7; \ 101 ba,pt %xcc, routine; \ 102 or %l7, %lo(systbl), %l7; 103 104 #define TRAP_UTRAP(handler,lvl) \ 105 mov handler, %g3; \ 106 ba,pt %xcc, utrap_trap; \ 107 mov lvl, %g4; \ 108 nop; \ 109 nop; \ 110 nop; \ 111 nop; \ 112 nop; 113 114 #ifdef CONFIG_COMPAT 115 #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32) 116 #else 117 #define LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110) 118 #endif 119 #define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64) 120 #define GETCC_TRAP TRAP(getcc) 121 #define SETCC_TRAP TRAP(setcc) 122 #define BREAKPOINT_TRAP TRAP(breakpoint_trap) 123 124 #ifdef CONFIG_TRACE_IRQFLAGS 125 126 #define TRAP_IRQ(routine, level) \ 127 rdpr %pil, %g2; \ 128 wrpr %g0, PIL_NORMAL_MAX, %pil; \ 129 sethi %hi(1f-4), %g7; \ 130 ba,pt %xcc, etrap_irq; \ 131 or %g7, %lo(1f-4), %g7; \ 132 nop; \ 133 nop; \ 134 nop; \ 135 .subsection 2; \ 136 1: call trace_hardirqs_off; \ 137 nop; \ 138 mov level, %o0; \ 139 call routine; \ 140 add %sp, PTREGS_OFF, %o1; \ 141 ba,a,pt %xcc, rtrap_irq; \ 142 .previous; 143 144 #else 145 146 #define TRAP_IRQ(routine, level) \ 147 rdpr %pil, %g2; \ 148 wrpr %g0, PIL_NORMAL_MAX, %pil; \ 149 ba,pt %xcc, etrap_irq; \ 150 rd %pc, %g7; \ 151 mov level, %o0; \ 152 call routine; \ 153 add %sp, PTREGS_OFF, %o1; \ 154 ba,a,pt %xcc, rtrap_irq; 155 156 #endif 157 158 #define TRAP_NMI_IRQ(routine, level) \ 159 rdpr %pil, %g2; \ 160 wrpr %g0, PIL_NMI, %pil; \ 161 ba,pt %xcc, etrap_irq; \ 162 rd %pc, %g7; \ 163 mov level, %o0; \ 164 call routine; \ 165 add %sp, PTREGS_OFF, %o1; \ 166 ba,a,pt %xcc, rtrap_nmi; 167 168 #define TRAP_IVEC TRAP_NOSAVE(do_ivec) 169 170 #define BTRAP(lvl) TRAP_ARG(bad_trap, lvl) 171 172 #define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl) 173 174 #define FLUSH_WINDOW_TRAP \ 175 ba,pt %xcc, etrap; \ 176 rd %pc, %g7; \ 177 flushw; \ 178 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \ 179 add %l1, 4, %l2; \ 180 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \ 181 ba,pt %xcc, rtrap; \ 182 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]; 183 184 #ifdef CONFIG_KPROBES 185 #define KPROBES_TRAP(lvl) TRAP_IRQ(kprobe_trap, lvl) 186 #else 187 #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl) 188 #endif 189 190 #ifdef CONFIG_UPROBES 191 #define UPROBES_TRAP(lvl) TRAP_ARG(uprobe_trap, lvl) 192 #else 193 #define UPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl) 194 #endif 195 196 #ifdef CONFIG_KGDB 197 #define KGDB_TRAP(lvl) TRAP_IRQ(kgdb_trap, lvl) 198 #else 199 #define KGDB_TRAP(lvl) TRAP_ARG(bad_trap, lvl) 200 #endif 201 202 #define SUN4V_ITSB_MISS \ 203 ldxa [%g0] ASI_SCRATCHPAD, %g2; \ 204 ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4; \ 205 ldx [%g2 + HV_FAULT_I_CTX_OFFSET], %g5; \ 206 srlx %g4, 22, %g6; \ 207 ba,pt %xcc, sun4v_itsb_miss; \ 208 nop; \ 209 nop; \ 210 nop; 211 212 #define SUN4V_DTSB_MISS \ 213 ldxa [%g0] ASI_SCRATCHPAD, %g2; \ 214 ldx [%g2 + HV_FAULT_D_ADDR_OFFSET], %g4; \ 215 ldx [%g2 + HV_FAULT_D_CTX_OFFSET], %g5; \ 216 srlx %g4, 22, %g6; \ 217 ba,pt %xcc, sun4v_dtsb_miss; \ 218 nop; \ 219 nop; \ 220 nop; 221 222 /* Before touching these macros, you owe it to yourself to go and 223 * see how arch/sparc64/kernel/winfixup.S works... -DaveM 224 * 225 * For the user cases we used to use the %asi register, but 226 * it turns out that the "wr xxx, %asi" costs ~5 cycles, so 227 * now we use immediate ASI loads and stores instead. Kudos 228 * to Greg Onufer for pointing out this performance anomaly. 229 * 230 * Further note that we cannot use the g2, g4, g5, and g7 alternate 231 * globals in the spill routines, check out the save instruction in 232 * arch/sparc64/kernel/etrap.S to see what I mean about g2, and 233 * g4/g5 are the globals which are preserved by etrap processing 234 * for the caller of it. The g7 register is the return pc for 235 * etrap. Finally, g6 is the current thread register so we cannot 236 * us it in the spill handlers either. Most of these rules do not 237 * apply to fill processing, only g6 is not usable. 238 */ 239 240 /* Normal kernel spill */ 241 #define SPILL_0_NORMAL \ 242 stx %l0, [%sp + STACK_BIAS + 0x00]; \ 243 stx %l1, [%sp + STACK_BIAS + 0x08]; \ 244 stx %l2, [%sp + STACK_BIAS + 0x10]; \ 245 stx %l3, [%sp + STACK_BIAS + 0x18]; \ 246 stx %l4, [%sp + STACK_BIAS + 0x20]; \ 247 stx %l5, [%sp + STACK_BIAS + 0x28]; \ 248 stx %l6, [%sp + STACK_BIAS + 0x30]; \ 249 stx %l7, [%sp + STACK_BIAS + 0x38]; \ 250 stx %i0, [%sp + STACK_BIAS + 0x40]; \ 251 stx %i1, [%sp + STACK_BIAS + 0x48]; \ 252 stx %i2, [%sp + STACK_BIAS + 0x50]; \ 253 stx %i3, [%sp + STACK_BIAS + 0x58]; \ 254 stx %i4, [%sp + STACK_BIAS + 0x60]; \ 255 stx %i5, [%sp + STACK_BIAS + 0x68]; \ 256 stx %i6, [%sp + STACK_BIAS + 0x70]; \ 257 stx %i7, [%sp + STACK_BIAS + 0x78]; \ 258 saved; retry; nop; nop; nop; nop; nop; nop; \ 259 nop; nop; nop; nop; nop; nop; nop; nop; 260 261 #define SPILL_0_NORMAL_ETRAP \ 262 etrap_kernel_spill: \ 263 stx %l0, [%sp + STACK_BIAS + 0x00]; \ 264 stx %l1, [%sp + STACK_BIAS + 0x08]; \ 265 stx %l2, [%sp + STACK_BIAS + 0x10]; \ 266 stx %l3, [%sp + STACK_BIAS + 0x18]; \ 267 stx %l4, [%sp + STACK_BIAS + 0x20]; \ 268 stx %l5, [%sp + STACK_BIAS + 0x28]; \ 269 stx %l6, [%sp + STACK_BIAS + 0x30]; \ 270 stx %l7, [%sp + STACK_BIAS + 0x38]; \ 271 stx %i0, [%sp + STACK_BIAS + 0x40]; \ 272 stx %i1, [%sp + STACK_BIAS + 0x48]; \ 273 stx %i2, [%sp + STACK_BIAS + 0x50]; \ 274 stx %i3, [%sp + STACK_BIAS + 0x58]; \ 275 stx %i4, [%sp + STACK_BIAS + 0x60]; \ 276 stx %i5, [%sp + STACK_BIAS + 0x68]; \ 277 stx %i6, [%sp + STACK_BIAS + 0x70]; \ 278 stx %i7, [%sp + STACK_BIAS + 0x78]; \ 279 saved; \ 280 sub %g1, 2, %g1; \ 281 ba,pt %xcc, etrap_save; \ 282 wrpr %g1, %cwp; \ 283 nop; nop; nop; nop; nop; nop; nop; nop; \ 284 nop; nop; nop; nop; 285 286 /* Normal 64bit spill */ 287 #define SPILL_1_GENERIC(ASI) \ 288 add %sp, STACK_BIAS + 0x00, %g1; \ 289 stxa %l0, [%g1 + %g0] ASI; \ 290 mov 0x08, %g3; \ 291 stxa %l1, [%g1 + %g3] ASI; \ 292 add %g1, 0x10, %g1; \ 293 stxa %l2, [%g1 + %g0] ASI; \ 294 stxa %l3, [%g1 + %g3] ASI; \ 295 add %g1, 0x10, %g1; \ 296 stxa %l4, [%g1 + %g0] ASI; \ 297 stxa %l5, [%g1 + %g3] ASI; \ 298 add %g1, 0x10, %g1; \ 299 stxa %l6, [%g1 + %g0] ASI; \ 300 stxa %l7, [%g1 + %g3] ASI; \ 301 add %g1, 0x10, %g1; \ 302 stxa %i0, [%g1 + %g0] ASI; \ 303 stxa %i1, [%g1 + %g3] ASI; \ 304 add %g1, 0x10, %g1; \ 305 stxa %i2, [%g1 + %g0] ASI; \ 306 stxa %i3, [%g1 + %g3] ASI; \ 307 add %g1, 0x10, %g1; \ 308 stxa %i4, [%g1 + %g0] ASI; \ 309 stxa %i5, [%g1 + %g3] ASI; \ 310 add %g1, 0x10, %g1; \ 311 stxa %i6, [%g1 + %g0] ASI; \ 312 stxa %i7, [%g1 + %g3] ASI; \ 313 saved; \ 314 retry; nop; nop; \ 315 b,a,pt %xcc, spill_fixup_dax; \ 316 b,a,pt %xcc, spill_fixup_mna; \ 317 b,a,pt %xcc, spill_fixup; 318 319 #define SPILL_1_GENERIC_ETRAP \ 320 etrap_user_spill_64bit: \ 321 stxa %l0, [%sp + STACK_BIAS + 0x00] %asi; \ 322 stxa %l1, [%sp + STACK_BIAS + 0x08] %asi; \ 323 stxa %l2, [%sp + STACK_BIAS + 0x10] %asi; \ 324 stxa %l3, [%sp + STACK_BIAS + 0x18] %asi; \ 325 stxa %l4, [%sp + STACK_BIAS + 0x20] %asi; \ 326 stxa %l5, [%sp + STACK_BIAS + 0x28] %asi; \ 327 stxa %l6, [%sp + STACK_BIAS + 0x30] %asi; \ 328 stxa %l7, [%sp + STACK_BIAS + 0x38] %asi; \ 329 stxa %i0, [%sp + STACK_BIAS + 0x40] %asi; \ 330 stxa %i1, [%sp + STACK_BIAS + 0x48] %asi; \ 331 stxa %i2, [%sp + STACK_BIAS + 0x50] %asi; \ 332 stxa %i3, [%sp + STACK_BIAS + 0x58] %asi; \ 333 stxa %i4, [%sp + STACK_BIAS + 0x60] %asi; \ 334 stxa %i5, [%sp + STACK_BIAS + 0x68] %asi; \ 335 stxa %i6, [%sp + STACK_BIAS + 0x70] %asi; \ 336 stxa %i7, [%sp + STACK_BIAS + 0x78] %asi; \ 337 saved; \ 338 sub %g1, 2, %g1; \ 339 ba,pt %xcc, etrap_save; \ 340 wrpr %g1, %cwp; \ 341 nop; nop; nop; nop; nop; \ 342 nop; nop; nop; nop; \ 343 ba,a,pt %xcc, etrap_spill_fixup_64bit; \ 344 ba,a,pt %xcc, etrap_spill_fixup_64bit; \ 345 ba,a,pt %xcc, etrap_spill_fixup_64bit; 346 347 #define SPILL_1_GENERIC_ETRAP_FIXUP \ 348 etrap_spill_fixup_64bit: \ 349 ldub [%g6 + TI_WSAVED], %g1; \ 350 sll %g1, 3, %g3; \ 351 add %g6, %g3, %g3; \ 352 stx %sp, [%g3 + TI_RWIN_SPTRS]; \ 353 sll %g1, 7, %g3; \ 354 add %g6, %g3, %g3; \ 355 stx %l0, [%g3 + TI_REG_WINDOW + 0x00]; \ 356 stx %l1, [%g3 + TI_REG_WINDOW + 0x08]; \ 357 stx %l2, [%g3 + TI_REG_WINDOW + 0x10]; \ 358 stx %l3, [%g3 + TI_REG_WINDOW + 0x18]; \ 359 stx %l4, [%g3 + TI_REG_WINDOW + 0x20]; \ 360 stx %l5, [%g3 + TI_REG_WINDOW + 0x28]; \ 361 stx %l6, [%g3 + TI_REG_WINDOW + 0x30]; \ 362 stx %l7, [%g3 + TI_REG_WINDOW + 0x38]; \ 363 stx %i0, [%g3 + TI_REG_WINDOW + 0x40]; \ 364 stx %i1, [%g3 + TI_REG_WINDOW + 0x48]; \ 365 stx %i2, [%g3 + TI_REG_WINDOW + 0x50]; \ 366 stx %i3, [%g3 + TI_REG_WINDOW + 0x58]; \ 367 stx %i4, [%g3 + TI_REG_WINDOW + 0x60]; \ 368 stx %i5, [%g3 + TI_REG_WINDOW + 0x68]; \ 369 stx %i6, [%g3 + TI_REG_WINDOW + 0x70]; \ 370 stx %i7, [%g3 + TI_REG_WINDOW + 0x78]; \ 371 add %g1, 1, %g1; \ 372 stb %g1, [%g6 + TI_WSAVED]; \ 373 saved; \ 374 rdpr %cwp, %g1; \ 375 sub %g1, 2, %g1; \ 376 ba,pt %xcc, etrap_save; \ 377 wrpr %g1, %cwp; \ 378 nop; nop; nop 379 380 /* Normal 32bit spill */ 381 #define SPILL_2_GENERIC(ASI) \ 382 and %sp, 1, %g3; \ 383 brnz,pn %g3, (. - (128 + 4)); \ 384 srl %sp, 0, %sp; \ 385 stwa %l0, [%sp + %g0] ASI; \ 386 mov 0x04, %g3; \ 387 stwa %l1, [%sp + %g3] ASI; \ 388 add %sp, 0x08, %g1; \ 389 stwa %l2, [%g1 + %g0] ASI; \ 390 stwa %l3, [%g1 + %g3] ASI; \ 391 add %g1, 0x08, %g1; \ 392 stwa %l4, [%g1 + %g0] ASI; \ 393 stwa %l5, [%g1 + %g3] ASI; \ 394 add %g1, 0x08, %g1; \ 395 stwa %l6, [%g1 + %g0] ASI; \ 396 stwa %l7, [%g1 + %g3] ASI; \ 397 add %g1, 0x08, %g1; \ 398 stwa %i0, [%g1 + %g0] ASI; \ 399 stwa %i1, [%g1 + %g3] ASI; \ 400 add %g1, 0x08, %g1; \ 401 stwa %i2, [%g1 + %g0] ASI; \ 402 stwa %i3, [%g1 + %g3] ASI; \ 403 add %g1, 0x08, %g1; \ 404 stwa %i4, [%g1 + %g0] ASI; \ 405 stwa %i5, [%g1 + %g3] ASI; \ 406 add %g1, 0x08, %g1; \ 407 stwa %i6, [%g1 + %g0] ASI; \ 408 stwa %i7, [%g1 + %g3] ASI; \ 409 saved; \ 410 retry; \ 411 b,a,pt %xcc, spill_fixup_dax; \ 412 b,a,pt %xcc, spill_fixup_mna; \ 413 b,a,pt %xcc, spill_fixup; 414 415 #define SPILL_2_GENERIC_ETRAP \ 416 etrap_user_spill_32bit: \ 417 and %sp, 1, %g3; \ 418 brnz,pn %g3, etrap_user_spill_64bit; \ 419 srl %sp, 0, %sp; \ 420 stwa %l0, [%sp + 0x00] %asi; \ 421 stwa %l1, [%sp + 0x04] %asi; \ 422 stwa %l2, [%sp + 0x08] %asi; \ 423 stwa %l3, [%sp + 0x0c] %asi; \ 424 stwa %l4, [%sp + 0x10] %asi; \ 425 stwa %l5, [%sp + 0x14] %asi; \ 426 stwa %l6, [%sp + 0x18] %asi; \ 427 stwa %l7, [%sp + 0x1c] %asi; \ 428 stwa %i0, [%sp + 0x20] %asi; \ 429 stwa %i1, [%sp + 0x24] %asi; \ 430 stwa %i2, [%sp + 0x28] %asi; \ 431 stwa %i3, [%sp + 0x2c] %asi; \ 432 stwa %i4, [%sp + 0x30] %asi; \ 433 stwa %i5, [%sp + 0x34] %asi; \ 434 stwa %i6, [%sp + 0x38] %asi; \ 435 stwa %i7, [%sp + 0x3c] %asi; \ 436 saved; \ 437 sub %g1, 2, %g1; \ 438 ba,pt %xcc, etrap_save; \ 439 wrpr %g1, %cwp; \ 440 nop; nop; nop; nop; \ 441 nop; nop; \ 442 ba,a,pt %xcc, etrap_spill_fixup_32bit; \ 443 ba,a,pt %xcc, etrap_spill_fixup_32bit; \ 444 ba,a,pt %xcc, etrap_spill_fixup_32bit; 445 446 #define SPILL_2_GENERIC_ETRAP_FIXUP \ 447 etrap_spill_fixup_32bit: \ 448 ldub [%g6 + TI_WSAVED], %g1; \ 449 sll %g1, 3, %g3; \ 450 add %g6, %g3, %g3; \ 451 stx %sp, [%g3 + TI_RWIN_SPTRS]; \ 452 sll %g1, 7, %g3; \ 453 add %g6, %g3, %g3; \ 454 stw %l0, [%g3 + TI_REG_WINDOW + 0x00]; \ 455 stw %l1, [%g3 + TI_REG_WINDOW + 0x04]; \ 456 stw %l2, [%g3 + TI_REG_WINDOW + 0x08]; \ 457 stw %l3, [%g3 + TI_REG_WINDOW + 0x0c]; \ 458 stw %l4, [%g3 + TI_REG_WINDOW + 0x10]; \ 459 stw %l5, [%g3 + TI_REG_WINDOW + 0x14]; \ 460 stw %l6, [%g3 + TI_REG_WINDOW + 0x18]; \ 461 stw %l7, [%g3 + TI_REG_WINDOW + 0x1c]; \ 462 stw %i0, [%g3 + TI_REG_WINDOW + 0x20]; \ 463 stw %i1, [%g3 + TI_REG_WINDOW + 0x24]; \ 464 stw %i2, [%g3 + TI_REG_WINDOW + 0x28]; \ 465 stw %i3, [%g3 + TI_REG_WINDOW + 0x2c]; \ 466 stw %i4, [%g3 + TI_REG_WINDOW + 0x30]; \ 467 stw %i5, [%g3 + TI_REG_WINDOW + 0x34]; \ 468 stw %i6, [%g3 + TI_REG_WINDOW + 0x38]; \ 469 stw %i7, [%g3 + TI_REG_WINDOW + 0x3c]; \ 470 add %g1, 1, %g1; \ 471 stb %g1, [%g6 + TI_WSAVED]; \ 472 saved; \ 473 rdpr %cwp, %g1; \ 474 sub %g1, 2, %g1; \ 475 ba,pt %xcc, etrap_save; \ 476 wrpr %g1, %cwp; \ 477 nop; nop; nop 478 479 #define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP) 480 #define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP) 481 #define SPILL_3_NORMAL SPILL_0_NORMAL 482 #define SPILL_4_NORMAL SPILL_0_NORMAL 483 #define SPILL_5_NORMAL SPILL_0_NORMAL 484 #define SPILL_6_NORMAL SPILL_0_NORMAL 485 #define SPILL_7_NORMAL SPILL_0_NORMAL 486 487 #define SPILL_0_OTHER SPILL_0_NORMAL 488 #define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS) 489 #define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS) 490 #define SPILL_3_OTHER SPILL_3_NORMAL 491 #define SPILL_4_OTHER SPILL_4_NORMAL 492 #define SPILL_5_OTHER SPILL_5_NORMAL 493 #define SPILL_6_OTHER SPILL_6_NORMAL 494 #define SPILL_7_OTHER SPILL_7_NORMAL 495 496 /* Normal kernel fill */ 497 #define FILL_0_NORMAL \ 498 ldx [%sp + STACK_BIAS + 0x00], %l0; \ 499 ldx [%sp + STACK_BIAS + 0x08], %l1; \ 500 ldx [%sp + STACK_BIAS + 0x10], %l2; \ 501 ldx [%sp + STACK_BIAS + 0x18], %l3; \ 502 ldx [%sp + STACK_BIAS + 0x20], %l4; \ 503 ldx [%sp + STACK_BIAS + 0x28], %l5; \ 504 ldx [%sp + STACK_BIAS + 0x30], %l6; \ 505 ldx [%sp + STACK_BIAS + 0x38], %l7; \ 506 ldx [%sp + STACK_BIAS + 0x40], %i0; \ 507 ldx [%sp + STACK_BIAS + 0x48], %i1; \ 508 ldx [%sp + STACK_BIAS + 0x50], %i2; \ 509 ldx [%sp + STACK_BIAS + 0x58], %i3; \ 510 ldx [%sp + STACK_BIAS + 0x60], %i4; \ 511 ldx [%sp + STACK_BIAS + 0x68], %i5; \ 512 ldx [%sp + STACK_BIAS + 0x70], %i6; \ 513 ldx [%sp + STACK_BIAS + 0x78], %i7; \ 514 restored; retry; nop; nop; nop; nop; nop; nop; \ 515 nop; nop; nop; nop; nop; nop; nop; nop; 516 517 #define FILL_0_NORMAL_RTRAP \ 518 kern_rtt_fill: \ 519 rdpr %cwp, %g1; \ 520 sub %g1, 1, %g1; \ 521 wrpr %g1, %cwp; \ 522 ldx [%sp + STACK_BIAS + 0x00], %l0; \ 523 ldx [%sp + STACK_BIAS + 0x08], %l1; \ 524 ldx [%sp + STACK_BIAS + 0x10], %l2; \ 525 ldx [%sp + STACK_BIAS + 0x18], %l3; \ 526 ldx [%sp + STACK_BIAS + 0x20], %l4; \ 527 ldx [%sp + STACK_BIAS + 0x28], %l5; \ 528 ldx [%sp + STACK_BIAS + 0x30], %l6; \ 529 ldx [%sp + STACK_BIAS + 0x38], %l7; \ 530 ldx [%sp + STACK_BIAS + 0x40], %i0; \ 531 ldx [%sp + STACK_BIAS + 0x48], %i1; \ 532 ldx [%sp + STACK_BIAS + 0x50], %i2; \ 533 ldx [%sp + STACK_BIAS + 0x58], %i3; \ 534 ldx [%sp + STACK_BIAS + 0x60], %i4; \ 535 ldx [%sp + STACK_BIAS + 0x68], %i5; \ 536 ldx [%sp + STACK_BIAS + 0x70], %i6; \ 537 ldx [%sp + STACK_BIAS + 0x78], %i7; \ 538 restored; \ 539 add %g1, 1, %g1; \ 540 ba,pt %xcc, kern_rtt_restore; \ 541 wrpr %g1, %cwp; \ 542 nop; nop; nop; nop; nop; \ 543 nop; nop; nop; nop; 544 545 546 /* Normal 64bit fill */ 547 #define FILL_1_GENERIC(ASI) \ 548 add %sp, STACK_BIAS + 0x00, %g1; \ 549 ldxa [%g1 + %g0] ASI, %l0; \ 550 mov 0x08, %g2; \ 551 mov 0x10, %g3; \ 552 ldxa [%g1 + %g2] ASI, %l1; \ 553 mov 0x18, %g5; \ 554 ldxa [%g1 + %g3] ASI, %l2; \ 555 ldxa [%g1 + %g5] ASI, %l3; \ 556 add %g1, 0x20, %g1; \ 557 ldxa [%g1 + %g0] ASI, %l4; \ 558 ldxa [%g1 + %g2] ASI, %l5; \ 559 ldxa [%g1 + %g3] ASI, %l6; \ 560 ldxa [%g1 + %g5] ASI, %l7; \ 561 add %g1, 0x20, %g1; \ 562 ldxa [%g1 + %g0] ASI, %i0; \ 563 ldxa [%g1 + %g2] ASI, %i1; \ 564 ldxa [%g1 + %g3] ASI, %i2; \ 565 ldxa [%g1 + %g5] ASI, %i3; \ 566 add %g1, 0x20, %g1; \ 567 ldxa [%g1 + %g0] ASI, %i4; \ 568 ldxa [%g1 + %g2] ASI, %i5; \ 569 ldxa [%g1 + %g3] ASI, %i6; \ 570 ldxa [%g1 + %g5] ASI, %i7; \ 571 restored; \ 572 retry; nop; nop; nop; nop; \ 573 b,a,pt %xcc, fill_fixup_dax; \ 574 b,a,pt %xcc, fill_fixup_mna; \ 575 b,a,pt %xcc, fill_fixup; 576 577 #define FILL_1_GENERIC_RTRAP \ 578 user_rtt_fill_64bit: \ 579 ldxa [%sp + STACK_BIAS + 0x00] %asi, %l0; \ 580 ldxa [%sp + STACK_BIAS + 0x08] %asi, %l1; \ 581 ldxa [%sp + STACK_BIAS + 0x10] %asi, %l2; \ 582 ldxa [%sp + STACK_BIAS + 0x18] %asi, %l3; \ 583 ldxa [%sp + STACK_BIAS + 0x20] %asi, %l4; \ 584 ldxa [%sp + STACK_BIAS + 0x28] %asi, %l5; \ 585 ldxa [%sp + STACK_BIAS + 0x30] %asi, %l6; \ 586 ldxa [%sp + STACK_BIAS + 0x38] %asi, %l7; \ 587 ldxa [%sp + STACK_BIAS + 0x40] %asi, %i0; \ 588 ldxa [%sp + STACK_BIAS + 0x48] %asi, %i1; \ 589 ldxa [%sp + STACK_BIAS + 0x50] %asi, %i2; \ 590 ldxa [%sp + STACK_BIAS + 0x58] %asi, %i3; \ 591 ldxa [%sp + STACK_BIAS + 0x60] %asi, %i4; \ 592 ldxa [%sp + STACK_BIAS + 0x68] %asi, %i5; \ 593 ldxa [%sp + STACK_BIAS + 0x70] %asi, %i6; \ 594 ldxa [%sp + STACK_BIAS + 0x78] %asi, %i7; \ 595 ba,pt %xcc, user_rtt_pre_restore; \ 596 restored; \ 597 nop; nop; nop; nop; nop; nop; \ 598 nop; nop; nop; nop; nop; \ 599 ba,a,pt %xcc, user_rtt_fill_fixup_dax; \ 600 ba,a,pt %xcc, user_rtt_fill_fixup_mna; \ 601 ba,a,pt %xcc, user_rtt_fill_fixup; 602 603 604 /* Normal 32bit fill */ 605 #define FILL_2_GENERIC(ASI) \ 606 and %sp, 1, %g3; \ 607 brnz,pn %g3, (. - (128 + 4)); \ 608 srl %sp, 0, %sp; \ 609 lduwa [%sp + %g0] ASI, %l0; \ 610 mov 0x04, %g2; \ 611 mov 0x08, %g3; \ 612 lduwa [%sp + %g2] ASI, %l1; \ 613 mov 0x0c, %g5; \ 614 lduwa [%sp + %g3] ASI, %l2; \ 615 lduwa [%sp + %g5] ASI, %l3; \ 616 add %sp, 0x10, %g1; \ 617 lduwa [%g1 + %g0] ASI, %l4; \ 618 lduwa [%g1 + %g2] ASI, %l5; \ 619 lduwa [%g1 + %g3] ASI, %l6; \ 620 lduwa [%g1 + %g5] ASI, %l7; \ 621 add %g1, 0x10, %g1; \ 622 lduwa [%g1 + %g0] ASI, %i0; \ 623 lduwa [%g1 + %g2] ASI, %i1; \ 624 lduwa [%g1 + %g3] ASI, %i2; \ 625 lduwa [%g1 + %g5] ASI, %i3; \ 626 add %g1, 0x10, %g1; \ 627 lduwa [%g1 + %g0] ASI, %i4; \ 628 lduwa [%g1 + %g2] ASI, %i5; \ 629 lduwa [%g1 + %g3] ASI, %i6; \ 630 lduwa [%g1 + %g5] ASI, %i7; \ 631 restored; \ 632 retry; nop; nop; \ 633 b,a,pt %xcc, fill_fixup_dax; \ 634 b,a,pt %xcc, fill_fixup_mna; \ 635 b,a,pt %xcc, fill_fixup; 636 637 #define FILL_2_GENERIC_RTRAP \ 638 user_rtt_fill_32bit: \ 639 and %sp, 1, %g3; \ 640 brnz,pn %g3, user_rtt_fill_64bit; \ 641 srl %sp, 0, %sp; \ 642 lduwa [%sp + 0x00] %asi, %l0; \ 643 lduwa [%sp + 0x04] %asi, %l1; \ 644 lduwa [%sp + 0x08] %asi, %l2; \ 645 lduwa [%sp + 0x0c] %asi, %l3; \ 646 lduwa [%sp + 0x10] %asi, %l4; \ 647 lduwa [%sp + 0x14] %asi, %l5; \ 648 lduwa [%sp + 0x18] %asi, %l6; \ 649 lduwa [%sp + 0x1c] %asi, %l7; \ 650 lduwa [%sp + 0x20] %asi, %i0; \ 651 lduwa [%sp + 0x24] %asi, %i1; \ 652 lduwa [%sp + 0x28] %asi, %i2; \ 653 lduwa [%sp + 0x2c] %asi, %i3; \ 654 lduwa [%sp + 0x30] %asi, %i4; \ 655 lduwa [%sp + 0x34] %asi, %i5; \ 656 lduwa [%sp + 0x38] %asi, %i6; \ 657 lduwa [%sp + 0x3c] %asi, %i7; \ 658 ba,pt %xcc, user_rtt_pre_restore; \ 659 restored; \ 660 nop; nop; nop; nop; nop; \ 661 nop; nop; nop; \ 662 ba,a,pt %xcc, user_rtt_fill_fixup_dax; \ 663 ba,a,pt %xcc, user_rtt_fill_fixup_mna; \ 664 ba,a,pt %xcc, user_rtt_fill_fixup; 665 666 667 #define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP) 668 #define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP) 669 #define FILL_3_NORMAL FILL_0_NORMAL 670 #define FILL_4_NORMAL FILL_0_NORMAL 671 #define FILL_5_NORMAL FILL_0_NORMAL 672 #define FILL_6_NORMAL FILL_0_NORMAL 673 #define FILL_7_NORMAL FILL_0_NORMAL 674 675 #define FILL_0_OTHER FILL_0_NORMAL 676 #define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS) 677 #define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS) 678 #define FILL_3_OTHER FILL_3_NORMAL 679 #define FILL_4_OTHER FILL_4_NORMAL 680 #define FILL_5_OTHER FILL_5_NORMAL 681 #define FILL_6_OTHER FILL_6_NORMAL 682 #define FILL_7_OTHER FILL_7_NORMAL 683 684 #endif /* !(_SPARC64_TTABLE_H) */ 685