1 /* $Id: entry.S,v 1.144 2002/02/09 19:49:30 davem Exp $
2 * arch/sparc64/kernel/entry.S: Sparc64 trap low-level entry points.
4 * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
7 * Copyright (C) 1996,98,99 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
10 #include <linux/config.h>
11 #include <linux/errno.h>
16 #include <asm/ptrace.h>
18 #include <asm/signal.h>
19 #include <asm/pgtable.h>
20 #include <asm/processor.h>
21 #include <asm/visasm.h>
22 #include <asm/estate.h>
23 #include <asm/auxio.h>
27 #define NR_SYSCALLS 284 /* Each OS is different... */
32 .globl sparc64_vpte_patchme1
33 .globl sparc64_vpte_patchme2
35 * On a second level vpte miss, check whether the original fault is to the OBP
36 * range (note that this is only possible for instruction miss, data misses to
37 * obp range do not use vpte). If so, go back directly to the faulting address.
38 * This is because we want to read the tpc, otherwise we have no way of knowing
39 * the 8k aligned faulting address if we are using >8k kernel pagesize. This
40 * also ensures no vpte range addresses are dropped into tlb while obp is
41 * executing (see inherit_locked_prom_mappings() rant).
44 /* Load 0xf0000000, which is LOW_OBP_ADDRESS. */
48 /* Is addr >= LOW_OBP_ADDRESS? */
50 blu,pn %xcc, sparc64_vpte_patchme1
53 /* Load 0x100000000, which is HI_OBP_ADDRESS. */
56 /* Is addr < HI_OBP_ADDRESS? */
58 blu,pn %xcc, obp_iaddr_patch
61 /* These two instructions are patched by paginig_init(). */
62 sparc64_vpte_patchme1:
64 sparc64_vpte_patchme2:
67 /* With kernel PGD in %g5, branch back into dtlb_backend. */
68 ba,pt %xcc, sparc64_kpte_continue
69 andn %g1, 0x3, %g1 /* Finish PMD offset adjustment. */
72 /* Restore previous TAG_ACCESS, %g5 is zero, and we will
73 * skip over the trap instruction so that the top level
74 * TLB miss handler will thing this %g5 value is just an
75 * invalid PTE, thus branching to full fault processing.
78 stxa %g4, [%g1 + %g1] ASI_DMMU
81 .globl obp_iaddr_patch
83 /* These two instructions patched by inherit_prom_mappings(). */
87 /* Behave as if we are at TL0. */
89 rdpr %tpc, %g4 /* Find original faulting iaddr */
90 srlx %g4, 13, %g4 /* Throw out context bits */
91 sllx %g4, 13, %g4 /* g4 has vpn + ctx0 now */
93 /* Restore previous TAG_ACCESS. */
95 stxa %g4, [%g1 + %g1] ASI_IMMU
102 /* Load PMD, is it valid? */
103 lduwa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
107 /* Get PTE offset. */
113 ldxa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
114 brgez,pn %g5, longpath
117 /* TLB load and return from trap. */
118 stxa %g5, [%g0] ASI_ITLB_DATA_IN
121 .globl obp_daddr_patch
123 /* These two instructions patched by inherit_prom_mappings(). */
127 /* Get PMD offset. */
132 /* Load PMD, is it valid? */
133 lduwa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
137 /* Get PTE offset. */
143 ldxa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
144 brgez,pn %g5, longpath
147 /* TLB load and return from trap. */
148 stxa %g5, [%g0] ASI_DTLB_DATA_IN
152 * On a first level data miss, check whether this is to the OBP range (note
153 * that such accesses can be made by prom, as well as by kernel using
154 * prom_getproperty on "address"), and if so, do not use vpte access ...
155 * rather, use information saved during inherit_prom_mappings() using 8k
159 /* Load 0xf0000000, which is LOW_OBP_ADDRESS. */
163 /* Is addr >= LOW_OBP_ADDRESS? */
165 blu,pn %xcc, vmalloc_addr
168 /* Load 0x100000000, which is HI_OBP_ADDRESS. */
171 /* Is addr < HI_OBP_ADDRESS? */
173 blu,pn %xcc, obp_daddr_patch
177 /* If we get here, a vmalloc addr accessed, load kernel VPTE. */
178 ldxa [%g3 + %g6] ASI_N, %g5
179 brgez,pn %g5, longpath
182 /* PTE is valid, load into TLB and return from trap. */
183 stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Reload TLB
186 /* This is trivial with the new code... */
189 sethi %hi(TSTATE_PEF), %g4 ! IEU0
195 andcc %g5, FPRS_FEF, %g0
199 /* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
202 109: or %g7, %lo(109b), %g7
204 ba,a,pt %xcc, rtrap_clr_l6
206 1: ldub [%g6 + TI_FPSAVED], %g5 ! Load Group
207 wr %g0, FPRS_FEF, %fprs ! LSU Group+4bubbles
208 andcc %g5, FPRS_FEF, %g0 ! IEU1 Group
209 be,a,pt %icc, 1f ! CTI
211 ldx [%g6 + TI_GSR], %g7 ! Load Group
212 1: andcc %g5, FPRS_DL, %g0 ! IEU1
213 bne,pn %icc, 2f ! CTI
215 andcc %g5, FPRS_DU, %g0 ! IEU1 Group
216 bne,pn %icc, 1f ! CTI
246 b,pt %xcc, fpdis_exit2
248 1: mov SECONDARY_CONTEXT, %g3
249 add %g6, TI_FPREGS + 0x80, %g1
252 ldxa [%g3] ASI_DMMU, %g5
255 stxa %g2, [%g3] ASI_DMMU
257 add %g6, TI_FPREGS + 0xc0, %g2
260 ldda [%g1] ASI_BLK_S, %f32 ! grrr, where is ASI_BLK_NUCLEUS 8-(
261 ldda [%g2] ASI_BLK_S, %f48
273 b,pt %xcc, fpdis_exit
275 2: andcc %g5, FPRS_DU, %g0
278 mov SECONDARY_CONTEXT, %g3
280 ldxa [%g3] ASI_DMMU, %g5
281 add %g6, TI_FPREGS, %g1
284 stxa %g2, [%g3] ASI_DMMU
286 add %g6, TI_FPREGS + 0x40, %g2
287 faddd %f32, %f34, %f36
288 fmuld %f32, %f34, %f38
289 ldda [%g1] ASI_BLK_S, %f0 ! grrr, where is ASI_BLK_NUCLEUS 8-(
290 ldda [%g2] ASI_BLK_S, %f16
291 faddd %f32, %f34, %f40
292 fmuld %f32, %f34, %f42
293 faddd %f32, %f34, %f44
294 fmuld %f32, %f34, %f46
295 faddd %f32, %f34, %f48
296 fmuld %f32, %f34, %f50
297 faddd %f32, %f34, %f52
298 fmuld %f32, %f34, %f54
299 faddd %f32, %f34, %f56
300 fmuld %f32, %f34, %f58
301 faddd %f32, %f34, %f60
302 fmuld %f32, %f34, %f62
304 ba,pt %xcc, fpdis_exit
306 3: mov SECONDARY_CONTEXT, %g3
307 add %g6, TI_FPREGS, %g1
308 ldxa [%g3] ASI_DMMU, %g5
311 stxa %g2, [%g3] ASI_DMMU
314 ldda [%g1] ASI_BLK_S, %f0 ! grrr, where is ASI_BLK_NUCLEUS 8-(
315 ldda [%g1 + %g2] ASI_BLK_S, %f16
317 ldda [%g1] ASI_BLK_S, %f32
318 ldda [%g1 + %g2] ASI_BLK_S, %f48
321 stxa %g5, [%g3] ASI_DMMU
325 ldx [%g6 + TI_XFSR], %fsr
327 or %g3, %g4, %g3 ! anal...
329 wr %g0, FPRS_FEF, %fprs ! clean DU/DL bits
335 add %sp, PTREGS_OFF, %o0
339 .globl do_fpother_check_fitos
341 do_fpother_check_fitos:
342 sethi %hi(fp_other_bounce - 4), %g7
343 or %g7, %lo(fp_other_bounce - 4), %g7
345 /* NOTE: Need to preserve %g7 until we fully commit
346 * to the fitos fixup.
348 stx %fsr, [%g6 + TI_XFSR]
350 andcc %g3, TSTATE_PRIV, %g0
351 bne,pn %xcc, do_fptrap_after_fsr
353 ldx [%g6 + TI_XFSR], %g3
356 cmp %g1, 2 ! Unfinished FP-OP
357 bne,pn %xcc, do_fptrap_after_fsr
358 sethi %hi(1 << 23), %g1 ! Inexact
360 bne,pn %xcc, do_fptrap_after_fsr
362 lduwa [%g1] ASI_AIUP, %g3 ! This cannot ever fail
363 #define FITOS_MASK 0xc1f83fe0
364 #define FITOS_COMPARE 0x81a01880
365 sethi %hi(FITOS_MASK), %g1
366 or %g1, %lo(FITOS_MASK), %g1
368 sethi %hi(FITOS_COMPARE), %g2
369 or %g2, %lo(FITOS_COMPARE), %g2
371 bne,pn %xcc, do_fptrap_after_fsr
373 std %f62, [%g6 + TI_FPREGS + (62 * 4)]
374 sethi %hi(fitos_table_1), %g1
376 or %g1, %lo(fitos_table_1), %g1
379 ba,pt %xcc, fitos_emul_continue
416 sethi %hi(fitos_table_2), %g1
418 or %g1, %lo(fitos_table_2), %g1
422 ba,pt %xcc, fitos_emul_fini
459 ldd [%g6 + TI_FPREGS + (62 * 4)], %f62
465 stx %fsr, [%g6 + TI_XFSR]
467 ldub [%g6 + TI_FPSAVED], %g3
470 stb %g3, [%g6 + TI_FPSAVED]
472 stx %g3, [%g6 + TI_GSR]
473 mov SECONDARY_CONTEXT, %g3
474 ldxa [%g3] ASI_DMMU, %g5
477 stxa %g2, [%g3] ASI_DMMU
479 add %g6, TI_FPREGS, %g2
480 andcc %g1, FPRS_DL, %g0
483 stda %f0, [%g2] ASI_BLK_S
484 stda %f16, [%g2 + %g3] ASI_BLK_S
485 andcc %g1, FPRS_DU, %g0
488 stda %f32, [%g2] ASI_BLK_S
489 stda %f48, [%g2 + %g3] ASI_BLK_S
490 5: mov SECONDARY_CONTEXT, %g1
492 stxa %g5, [%g1] ASI_DMMU
498 sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
500 .globl cheetah_plus_patch_fpdis
501 cheetah_plus_patch_fpdis:
502 /* We configure the dTLB512_0 for 4MB pages and the
503 * dTLB512_1 for 8K pages when in context zero.
505 sethi %hi(cplus_fptrap_1), %o0
506 lduw [%o0 + %lo(cplus_fptrap_1)], %o1
508 set cplus_fptrap_insn_1, %o2
511 set cplus_fptrap_insn_2, %o2
514 set cplus_fptrap_insn_3, %o2
517 set cplus_fptrap_insn_4, %o2
524 /* The registers for cross calls will be:
526 * DATA 0: [low 32-bits] Address of function to call, jmp to this
527 * [high 32-bits] MMU Context Argument 0, place in %g5
528 * DATA 1: Address Argument 1, place in %g6
529 * DATA 2: Address Argument 2, place in %g7
531 * With this method we can do most of the cross-call tlb/cache
532 * flushing very quickly.
534 * Current CPU's IRQ worklist table is locked into %g1,
542 ldxa [%g3 + %g0] ASI_INTR_R, %g3
543 sethi %hi(KERNBASE), %g4
545 bgeu,pn %xcc, do_ivec_xcall
547 stxa %g0, [%g0] ASI_INTR_RECEIVE
550 sethi %hi(ivector_table), %g2
552 or %g2, %lo(ivector_table), %g2
554 ldub [%g3 + 0x04], %g4 /* pil */
559 lduw [%g6 + %g4], %g5 /* g5 = irq_work(cpu, pil) */
560 stw %g5, [%g3 + 0x00] /* bucket->irq_chain = g5 */
561 stw %g3, [%g6 + %g4] /* irq_work(cpu, pil) = bucket */
562 wr %g2, 0x0, %set_softint
566 ldxa [%g1 + %g0] ASI_INTR_R, %g1
570 ldxa [%g7 + %g0] ASI_INTR_R, %g7
571 stxa %g0, [%g0] ASI_INTR_RECEIVE
580 .globl save_alternate_globals
581 save_alternate_globals: /* %o0 = save_area */
583 andn %o5, PSTATE_IE, %o1
584 wrpr %o1, PSTATE_AG, %pstate
585 stx %g0, [%o0 + 0x00]
586 stx %g1, [%o0 + 0x08]
587 stx %g2, [%o0 + 0x10]
588 stx %g3, [%o0 + 0x18]
589 stx %g4, [%o0 + 0x20]
590 stx %g5, [%o0 + 0x28]
591 stx %g6, [%o0 + 0x30]
592 stx %g7, [%o0 + 0x38]
593 wrpr %o1, PSTATE_IG, %pstate
594 stx %g0, [%o0 + 0x40]
595 stx %g1, [%o0 + 0x48]
596 stx %g2, [%o0 + 0x50]
597 stx %g3, [%o0 + 0x58]
598 stx %g4, [%o0 + 0x60]
599 stx %g5, [%o0 + 0x68]
600 stx %g6, [%o0 + 0x70]
601 stx %g7, [%o0 + 0x78]
602 wrpr %o1, PSTATE_MG, %pstate
603 stx %g0, [%o0 + 0x80]
604 stx %g1, [%o0 + 0x88]
605 stx %g2, [%o0 + 0x90]
606 stx %g3, [%o0 + 0x98]
607 stx %g4, [%o0 + 0xa0]
608 stx %g5, [%o0 + 0xa8]
609 stx %g6, [%o0 + 0xb0]
610 stx %g7, [%o0 + 0xb8]
611 wrpr %o5, 0x0, %pstate
615 .globl restore_alternate_globals
616 restore_alternate_globals: /* %o0 = save_area */
618 andn %o5, PSTATE_IE, %o1
619 wrpr %o1, PSTATE_AG, %pstate
620 ldx [%o0 + 0x00], %g0
621 ldx [%o0 + 0x08], %g1
622 ldx [%o0 + 0x10], %g2
623 ldx [%o0 + 0x18], %g3
624 ldx [%o0 + 0x20], %g4
625 ldx [%o0 + 0x28], %g5
626 ldx [%o0 + 0x30], %g6
627 ldx [%o0 + 0x38], %g7
628 wrpr %o1, PSTATE_IG, %pstate
629 ldx [%o0 + 0x40], %g0
630 ldx [%o0 + 0x48], %g1
631 ldx [%o0 + 0x50], %g2
632 ldx [%o0 + 0x58], %g3
633 ldx [%o0 + 0x60], %g4
634 ldx [%o0 + 0x68], %g5
635 ldx [%o0 + 0x70], %g6
636 ldx [%o0 + 0x78], %g7
637 wrpr %o1, PSTATE_MG, %pstate
638 ldx [%o0 + 0x80], %g0
639 ldx [%o0 + 0x88], %g1
640 ldx [%o0 + 0x90], %g2
641 ldx [%o0 + 0x98], %g3
642 ldx [%o0 + 0xa0], %g4
643 ldx [%o0 + 0xa8], %g5
644 ldx [%o0 + 0xb0], %g6
645 ldx [%o0 + 0xb8], %g7
646 wrpr %o5, 0x0, %pstate
652 ldx [%o0 + PT_V9_TSTATE], %o1
656 stx %o1, [%o0 + PT_V9_G1]
658 ldx [%o0 + PT_V9_TSTATE], %o1
659 ldx [%o0 + PT_V9_G1], %o2
660 or %g0, %ulo(TSTATE_ICC), %o3
667 stx %o1, [%o0 + PT_V9_TSTATE]
669 .globl utrap, utrap_ill
670 utrap: brz,pn %g1, etrap
675 andn %l6, TSTATE_CWP, %l6
676 wrpr %l6, %l7, %tstate
683 add %sp, PTREGS_OFF, %o0
687 /* XXX Here is stuff we still need to write... -DaveM XXX */
688 .globl netbsd_syscall
693 .globl __do_data_access_exception
694 .globl __do_data_access_exception_tl1
695 __do_data_access_exception_tl1:
697 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
700 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
701 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
702 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
704 ba,pt %xcc, winfix_dax
706 __do_data_access_exception:
708 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
711 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
712 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
713 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
717 109: or %g7, %lo(109b), %g7
720 call data_access_exception
721 add %sp, PTREGS_OFF, %o0
725 .globl __do_instruction_access_exception
726 .globl __do_instruction_access_exception_tl1
727 __do_instruction_access_exception_tl1:
729 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
731 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
732 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
733 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
737 109: or %g7, %lo(109b), %g7
740 call instruction_access_exception_tl1
741 add %sp, PTREGS_OFF, %o0
745 __do_instruction_access_exception:
747 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
749 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
750 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
751 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
755 109: or %g7, %lo(109b), %g7
758 call instruction_access_exception
759 add %sp, PTREGS_OFF, %o0
763 /* This is the trap handler entry point for ECC correctable
764 * errors. They are corrected, but we listen for the trap
765 * so that the event can be logged.
767 * Disrupting errors are either:
768 * 1) single-bit ECC errors during UDB reads to system
770 * 2) data parity errors during write-back events
772 * As far as I can make out from the manual, the CEE trap
773 * is only for correctable errors during memory read
774 * accesses by the front-end of the processor.
776 * The code below is only for trap level 1 CEE events,
777 * as it is the only situation where we can safely record
778 * and log. For trap level >1 we just clear the CE bit
779 * in the AFSR and return.
782 /* Our trap handling infrastructure allows us to preserve
783 * two 64-bit values during etrap for arguments to
784 * subsequent C code. Therefore we encode the information
787 * value 1) Full 64-bits of AFAR
788 * value 2) Low 33-bits of AFSR, then bits 33-->42
789 * are UDBL error status and bits 43-->52
790 * are UDBH error status
795 ldxa [%g0] ASI_AFSR, %g1 ! Read AFSR
796 ldxa [%g0] ASI_AFAR, %g2 ! Read AFAR
797 sllx %g1, 31, %g1 ! Clear reserved bits
798 srlx %g1, 31, %g1 ! in AFSR
800 /* NOTE: UltraSparc-I/II have high and low UDB error
801 * registers, corresponding to the two UDB units
802 * present on those chips. UltraSparc-IIi only
803 * has a single UDB, called "SDB" in the manual.
804 * For IIi the upper UDB register always reads
805 * as zero so for our purposes things will just
806 * work with the checks below.
808 ldxa [%g0] ASI_UDBL_ERROR_R, %g3 ! Read UDB-Low error status
809 andcc %g3, (1 << 8), %g4 ! Check CE bit
810 sllx %g3, (64 - 10), %g3 ! Clear reserved bits
811 srlx %g3, (64 - 10), %g3 ! in UDB-Low error status
813 sllx %g3, (33 + 0), %g3 ! Shift up to encoding area
814 or %g1, %g3, %g1 ! Or it in
815 be,pn %xcc, 1f ! Branch if CE bit was clear
817 stxa %g4, [%g0] ASI_UDB_ERROR_W ! Clear CE sticky bit in UDBL
818 membar #Sync ! Synchronize ASI stores
819 1: mov 0x18, %g5 ! Addr of UDB-High error status
820 ldxa [%g5] ASI_UDBH_ERROR_R, %g3 ! Read it
822 andcc %g3, (1 << 8), %g4 ! Check CE bit
823 sllx %g3, (64 - 10), %g3 ! Clear reserved bits
824 srlx %g3, (64 - 10), %g3 ! in UDB-High error status
825 sllx %g3, (33 + 10), %g3 ! Shift up to encoding area
826 or %g1, %g3, %g1 ! Or it in
827 be,pn %xcc, 1f ! Branch if CE bit was clear
831 stxa %g4, [%g5] ASI_UDB_ERROR_W ! Clear CE sticky bit in UDBH
832 membar #Sync ! Synchronize ASI stores
833 1: mov 1, %g5 ! AFSR CE bit is
834 sllx %g5, 20, %g5 ! bit 20
835 stxa %g5, [%g0] ASI_AFSR ! Clear CE sticky bit in AFSR
836 membar #Sync ! Synchronize ASI stores
837 sllx %g2, (64 - 41), %g2 ! Clear reserved bits
838 srlx %g2, (64 - 41), %g2 ! in latched AFAR
840 andn %g2, 0x0f, %g2 ! Finish resv bit clearing
841 mov %g1, %g4 ! Move AFSR+UDB* into save reg
842 mov %g2, %g5 ! Move AFAR into save reg
845 ba,pt %xcc, etrap_irq
851 add %sp, PTREGS_OFF, %o2
852 ba,a,pt %xcc, rtrap_irq
854 /* Capture I/D/E-cache state into per-cpu error scoreboard.
856 * %g1: (TL>=0) ? 1 : 0
861 * %g6: current thread ptr
864 #define CHEETAH_LOG_ERROR \
865 /* Put "TL1" software bit into AFSR. */ \
869 /* Get log entry pointer for this cpu at this trap level. */ \
870 BRANCH_IF_JALAPENO(g2,g3,50f) \
871 ldxa [%g0] ASI_SAFARI_CONFIG, %g2; \
874 and %g2, 0x3ff, %g2; \
875 50: ldxa [%g0] ASI_JBUS_CONFIG, %g2; \
877 and %g2, 0x1f, %g2; \
878 60: sllx %g2, 9, %g2; \
879 sethi %hi(cheetah_error_log), %g3; \
880 ldx [%g3 + %lo(cheetah_error_log)], %g3; \
886 /* %g1 holds pointer to the top of the logging scoreboard */ \
887 ldx [%g1 + 0x0], %g7; \
891 stx %g4, [%g1 + 0x0]; \
892 stx %g5, [%g1 + 0x8]; \
893 add %g1, 0x10, %g1; \
894 /* %g1 now points to D-cache logging area */ \
895 set 0x3ff8, %g2; /* DC_addr mask */ \
896 and %g5, %g2, %g2; /* DC_addr bits of AFAR */ \
898 or %g3, 1, %g3; /* PHYS tag + valid */ \
899 10: ldxa [%g2] ASI_DCACHE_TAG, %g7; \
900 cmp %g3, %g7; /* TAG match? */ \
903 /* Yep, what we want, capture state. */ \
904 stx %g2, [%g1 + 0x20]; \
905 stx %g7, [%g1 + 0x28]; \
906 /* A membar Sync is required before and after utag access. */ \
908 ldxa [%g2] ASI_DCACHE_UTAG, %g7; \
910 stx %g7, [%g1 + 0x30]; \
911 ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7; \
912 stx %g7, [%g1 + 0x38]; \
914 12: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7; \
916 add %g3, (1 << 5), %g3; \
921 add %g1, 0x20, %g1; \
922 13: sethi %hi(1 << 14), %g7; \
928 add %g1, 0x40, %g1; \
929 20: /* %g1 now points to I-cache logging area */ \
930 set 0x1fe0, %g2; /* IC_addr mask */ \
931 and %g5, %g2, %g2; /* IC_addr bits of AFAR */ \
932 sllx %g2, 1, %g2; /* IC_addr[13:6]==VA[12:5] */ \
933 srlx %g5, (13 - 8), %g3; /* Make PTAG */ \
934 andn %g3, 0xff, %g3; /* Mask off undefined bits */ \
935 21: ldxa [%g2] ASI_IC_TAG, %g7; \
936 andn %g7, 0xff, %g7; \
940 /* Yep, what we want, capture state. */ \
941 stx %g2, [%g1 + 0x40]; \
942 stx %g7, [%g1 + 0x48]; \
943 add %g2, (1 << 3), %g2; \
944 ldxa [%g2] ASI_IC_TAG, %g7; \
945 add %g2, (1 << 3), %g2; \
946 stx %g7, [%g1 + 0x50]; \
947 ldxa [%g2] ASI_IC_TAG, %g7; \
948 add %g2, (1 << 3), %g2; \
949 stx %g7, [%g1 + 0x60]; \
950 ldxa [%g2] ASI_IC_TAG, %g7; \
951 stx %g7, [%g1 + 0x68]; \
952 sub %g2, (3 << 3), %g2; \
953 ldxa [%g2] ASI_IC_STAG, %g7; \
954 stx %g7, [%g1 + 0x58]; \
957 22: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7; \
959 add %g3, (1 << 3), %g3; \
964 add %g1, 0x30, %g1; \
965 23: sethi %hi(1 << 14), %g7; \
971 add %g1, 0x70, %g1; \
972 30: /* %g1 now points to E-cache logging area */ \
973 andn %g5, (32 - 1), %g2; /* E-cache subblock */ \
974 stx %g2, [%g1 + 0x20]; \
975 ldxa [%g2] ASI_EC_TAG_DATA, %g7; \
976 stx %g7, [%g1 + 0x28]; \
977 ldxa [%g2] ASI_EC_R, %g0; \
979 31: ldxa [%g3] ASI_EC_DATA, %g7; \
980 stx %g7, [%g1 + %g3]; \
987 /* These get patched into the trap table at boot time
988 * once we know we have a cheetah processor.
990 .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
991 cheetah_fecc_trap_vector:
993 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
994 andn %g1, DCU_DC | DCU_IC, %g1
995 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
997 sethi %hi(cheetah_fast_ecc), %g2
998 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
1000 cheetah_fecc_trap_vector_tl1:
1002 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1003 andn %g1, DCU_DC | DCU_IC, %g1
1004 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1006 sethi %hi(cheetah_fast_ecc), %g2
1007 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
1009 .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
1010 cheetah_cee_trap_vector:
1012 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1013 andn %g1, DCU_IC, %g1
1014 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1016 sethi %hi(cheetah_cee), %g2
1017 jmpl %g2 + %lo(cheetah_cee), %g0
1019 cheetah_cee_trap_vector_tl1:
1021 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1022 andn %g1, DCU_IC, %g1
1023 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1025 sethi %hi(cheetah_cee), %g2
1026 jmpl %g2 + %lo(cheetah_cee), %g0
1028 .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
1029 cheetah_deferred_trap_vector:
1031 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
1032 andn %g1, DCU_DC | DCU_IC, %g1;
1033 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
1035 sethi %hi(cheetah_deferred_trap), %g2
1036 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
1038 cheetah_deferred_trap_vector_tl1:
1040 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
1041 andn %g1, DCU_DC | DCU_IC, %g1;
1042 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
1044 sethi %hi(cheetah_deferred_trap), %g2
1045 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
1048 /* Cheetah+ specific traps. These are for the new I/D cache parity
1049 * error traps. The first argument to cheetah_plus_parity_handler
1050 * is encoded as follows:
1052 * Bit0: 0=dcache,1=icache
1053 * Bit1: 0=recoverable,1=unrecoverable
1055 .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
1056 cheetah_plus_dcpe_trap_vector:
1058 sethi %hi(do_cheetah_plus_data_parity), %g7
1059 jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
1066 do_cheetah_plus_data_parity:
1070 call cheetah_plus_parity_error
1071 add %sp, PTREGS_OFF, %o1
1075 cheetah_plus_dcpe_trap_vector_tl1:
1077 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
1078 sethi %hi(do_dcpe_tl1), %g3
1079 jmpl %g3 + %lo(do_dcpe_tl1), %g0
1085 .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
1086 cheetah_plus_icpe_trap_vector:
1088 sethi %hi(do_cheetah_plus_insn_parity), %g7
1089 jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
1096 do_cheetah_plus_insn_parity:
1100 call cheetah_plus_parity_error
1101 add %sp, PTREGS_OFF, %o1
1105 cheetah_plus_icpe_trap_vector_tl1:
1107 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
1108 sethi %hi(do_icpe_tl1), %g3
1109 jmpl %g3 + %lo(do_icpe_tl1), %g0
1115 /* If we take one of these traps when tl >= 1, then we
1116 * jump to interrupt globals. If some trap level above us
1117 * was also using interrupt globals, we cannot recover.
1118 * We may use all interrupt global registers except %g6.
1120 .globl do_dcpe_tl1, do_icpe_tl1
1122 rdpr %tl, %g1 ! Save original trap level
1123 mov 1, %g2 ! Setup TSTATE checking loop
1124 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
1125 1: wrpr %g2, %tl ! Set trap level to check
1126 rdpr %tstate, %g4 ! Read TSTATE for this level
1127 andcc %g4, %g3, %g0 ! Interrupt globals in use?
1128 bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
1129 wrpr %g1, %tl ! Restore original trap level
1130 add %g2, 1, %g2 ! Next trap level
1131 cmp %g2, %g1 ! Hit them all yet?
1132 ble,pt %icc, 1b ! Not yet
1134 wrpr %g1, %tl ! Restore original trap level
1135 do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
1136 /* Reset D-cache parity */
1137 sethi %hi(1 << 16), %g1 ! D-cache size
1138 mov (1 << 5), %g2 ! D-cache line size
1139 sub %g1, %g2, %g1 ! Move down 1 cacheline
1140 1: srl %g1, 14, %g3 ! Compute UTAG
1142 stxa %g3, [%g1] ASI_DCACHE_UTAG
1144 sub %g2, 8, %g3 ! 64-bit data word within line
1146 stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
1148 subcc %g3, 8, %g3 ! Next 64-bit data word
1151 subcc %g1, %g2, %g1 ! Next cacheline
1154 ba,pt %xcc, dcpe_icpe_tl1_common
1159 ba,pt %xcc, etraptl1
1160 1: or %g7, %lo(1b), %g7
1162 call cheetah_plus_parity_error
1163 add %sp, PTREGS_OFF, %o1
1168 rdpr %tl, %g1 ! Save original trap level
1169 mov 1, %g2 ! Setup TSTATE checking loop
1170 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
1171 1: wrpr %g2, %tl ! Set trap level to check
1172 rdpr %tstate, %g4 ! Read TSTATE for this level
1173 andcc %g4, %g3, %g0 ! Interrupt globals in use?
1174 bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
1175 wrpr %g1, %tl ! Restore original trap level
1176 add %g2, 1, %g2 ! Next trap level
1177 cmp %g2, %g1 ! Hit them all yet?
1178 ble,pt %icc, 1b ! Not yet
1180 wrpr %g1, %tl ! Restore original trap level
1181 do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
1183 sethi %hi(1 << 15), %g1 ! I-cache size
1184 mov (1 << 5), %g2 ! I-cache line size
1186 1: or %g1, (2 << 3), %g3
1187 stxa %g0, [%g3] ASI_IC_TAG
1192 ba,pt %xcc, dcpe_icpe_tl1_common
1197 ba,pt %xcc, etraptl1
1198 1: or %g7, %lo(1b), %g7
1200 call cheetah_plus_parity_error
1201 add %sp, PTREGS_OFF, %o1
1205 dcpe_icpe_tl1_common:
1206 /* Flush D-cache, re-enable D/I caches in DCU and finally
1207 * retry the trapping instruction.
1209 sethi %hi(1 << 16), %g1 ! D-cache size
1210 mov (1 << 5), %g2 ! D-cache line size
1212 1: stxa %g0, [%g1] ASI_DCACHE_TAG
1217 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1218 or %g1, (DCU_DC | DCU_IC), %g1
1219 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1223 /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
1224 * in the trap table. That code has done a memory barrier
1225 * and has disabled both the I-cache and D-cache in the DCU
1226 * control register. The I-cache is disabled so that we may
1227 * capture the corrupted cache line, and the D-cache is disabled
1228 * because corrupt data may have been placed there and we don't
1229 * want to reference it.
1231 * %g1 is one if this trap occurred at %tl >= 1.
1233 * Next, we turn off error reporting so that we don't recurse.
1235 .globl cheetah_fast_ecc
1237 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1238 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1239 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1242 /* Fetch and clear AFSR/AFAR */
1243 ldxa [%g0] ASI_AFSR, %g4
1244 ldxa [%g0] ASI_AFAR, %g5
1245 stxa %g4, [%g0] ASI_AFSR
1252 ba,pt %xcc, etrap_irq
1256 call cheetah_fecc_handler
1257 add %sp, PTREGS_OFF, %o0
1258 ba,a,pt %xcc, rtrap_irq
1260 /* Our caller has disabled I-cache and performed membar Sync. */
1263 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1264 andn %g2, ESTATE_ERROR_CEEN, %g2
1265 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1268 /* Fetch and clear AFSR/AFAR */
1269 ldxa [%g0] ASI_AFSR, %g4
1270 ldxa [%g0] ASI_AFAR, %g5
1271 stxa %g4, [%g0] ASI_AFSR
1278 ba,pt %xcc, etrap_irq
1282 call cheetah_cee_handler
1283 add %sp, PTREGS_OFF, %o0
1284 ba,a,pt %xcc, rtrap_irq
1286 /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
1287 .globl cheetah_deferred_trap
1288 cheetah_deferred_trap:
1289 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1290 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1291 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1294 /* Fetch and clear AFSR/AFAR */
1295 ldxa [%g0] ASI_AFSR, %g4
1296 ldxa [%g0] ASI_AFAR, %g5
1297 stxa %g4, [%g0] ASI_AFSR
1304 ba,pt %xcc, etrap_irq
1308 call cheetah_deferred_handler
1309 add %sp, PTREGS_OFF, %o0
1310 ba,a,pt %xcc, rtrap_irq
1315 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1317 sethi %hi(109f), %g7
1319 109: or %g7, %lo(109b), %g7
1321 add %sp, PTREGS_OFF, %o0
1330 /* Setup %g4/%g5 now as they are used in the
1335 ldxa [%g4] ASI_DMMU, %g4
1336 ldxa [%g3] ASI_DMMU, %g5
1337 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1339 bgu,pn %icc, winfix_mna
1342 1: sethi %hi(109f), %g7
1344 109: or %g7, %lo(109b), %g7
1347 call mem_address_unaligned
1348 add %sp, PTREGS_OFF, %o0
1354 sethi %hi(109f), %g7
1356 ldxa [%g4] ASI_DMMU, %g5
1357 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1360 ldxa [%g4] ASI_DMMU, %g4
1362 109: or %g7, %lo(109b), %g7
1366 add %sp, PTREGS_OFF, %o0
1372 sethi %hi(109f), %g7
1374 ldxa [%g4] ASI_DMMU, %g5
1375 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1378 ldxa [%g4] ASI_DMMU, %g4
1380 109: or %g7, %lo(109b), %g7
1384 add %sp, PTREGS_OFF, %o0
1388 .globl breakpoint_trap
1390 call sparc_breakpoint
1391 add %sp, PTREGS_OFF, %o0
1395 #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
1396 defined(CONFIG_SOLARIS_EMUL_MODULE)
1397 /* SunOS uses syscall zero as the 'indirect syscall' it looks
1398 * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
1399 * This is complete brain damage.
1405 cmp %o0, NR_SYSCALLS
1408 sethi %hi(sunos_nosys), %l6
1410 or %l6, %lo(sunos_nosys), %l6
1411 1: sethi %hi(sunos_sys_table), %l7
1412 or %l7, %lo(sunos_sys_table), %l7
1413 lduw [%l7 + %o0], %l6
1427 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1428 b,pt %xcc, ret_sys_call
1429 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1431 /* SunOS getuid() returns uid in %o0 and euid in %o1 */
1434 call sys32_geteuid16
1437 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1438 b,pt %xcc, ret_sys_call
1439 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1441 /* SunOS getgid() returns gid in %o0 and egid in %o1 */
1444 call sys32_getegid16
1447 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1448 b,pt %xcc, ret_sys_call
1449 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1452 /* SunOS's execv() call only specifies the argv argument, the
1453 * environment settings are the same as the calling processes.
1457 sethi %hi(sparc_execve), %g1
1458 ba,pt %xcc, execve_merge
1459 or %g1, %lo(sparc_execve), %g1
1460 #ifdef CONFIG_COMPAT
1463 stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
1466 sethi %hi(sparc32_execve), %g1
1467 or %g1, %lo(sparc32_execve), %g1
1472 add %sp, PTREGS_OFF, %o0
1474 .globl sys_pipe, sys_sigpause, sys_nis_syscall
1475 .globl sys_sigsuspend, sys_rt_sigsuspend
1476 .globl sys_rt_sigreturn
1478 .globl sys_sigaltstack
1480 sys_pipe: ba,pt %xcc, sparc_pipe
1481 add %sp, PTREGS_OFF, %o0
1482 sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
1483 add %sp, PTREGS_OFF, %o0
1484 sys_memory_ordering:
1485 ba,pt %xcc, sparc_memory_ordering
1486 add %sp, PTREGS_OFF, %o1
1487 sys_sigaltstack:ba,pt %xcc, do_sigaltstack
1488 add %i6, STACK_BIAS, %o2
1489 #ifdef CONFIG_COMPAT
1490 .globl sys32_sigstack
1491 sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
1493 .globl sys32_sigaltstack
1495 ba,pt %xcc, do_sys32_sigaltstack
1499 sys_sigsuspend: add %sp, PTREGS_OFF, %o0
1501 add %o7, 1f-.-4, %o7
1503 sys_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
1504 add %sp, PTREGS_OFF, %o2
1505 call do_rt_sigsuspend
1506 add %o7, 1f-.-4, %o7
1508 #ifdef CONFIG_COMPAT
1509 .globl sys32_rt_sigsuspend
1510 sys32_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
1512 add %sp, PTREGS_OFF, %o2
1513 call do_rt_sigsuspend32
1514 add %o7, 1f-.-4, %o7
1516 /* NOTE: %o0 has a correct value already */
1517 sys_sigpause: add %sp, PTREGS_OFF, %o1
1519 add %o7, 1f-.-4, %o7
1521 #ifdef CONFIG_COMPAT
1522 .globl sys32_sigreturn
1524 add %sp, PTREGS_OFF, %o0
1526 add %o7, 1f-.-4, %o7
1530 add %sp, PTREGS_OFF, %o0
1531 call do_rt_sigreturn
1532 add %o7, 1f-.-4, %o7
1534 #ifdef CONFIG_COMPAT
1535 .globl sys32_rt_sigreturn
1537 add %sp, PTREGS_OFF, %o0
1538 call do_rt_sigreturn32
1539 add %o7, 1f-.-4, %o7
1542 sys_ptrace: add %sp, PTREGS_OFF, %o0
1544 add %o7, 1f-.-4, %o7
1547 1: ldx [%curptr + TI_FLAGS], %l5
1548 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1551 add %sp, PTREGS_OFF, %o0
1558 /* This is how fork() was meant to be done, 8 instruction entry.
1560 * I questioned the following code briefly, let me clear things
1561 * up so you must not reason on it like I did.
1563 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
1564 * need it here because the only piece of window state we copy to
1565 * the child is the CWP register. Even if the parent sleeps,
1566 * we are safe because we stuck it into pt_regs of the parent
1567 * so it will not change.
1569 * XXX This raises the question, whether we can do the same on
1570 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
1571 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
1572 * XXX fork_kwim in UREG_G1 (global registers are considered
1573 * XXX volatile across a system call in the sparc ABI I think
1574 * XXX if it isn't we can use regs->y instead, anyone who depends
1575 * XXX upon the Y register being preserved across a fork deserves
1578 * In fact we should take advantage of that fact for other things
1579 * during system calls...
1581 .globl sys_fork, sys_vfork, sys_clone, sparc_exit
1582 .globl ret_from_syscall
1584 sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
1585 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
1586 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
1587 ba,pt %xcc, sys_clone
1593 ba,pt %xcc, sparc_do_fork
1594 add %sp, PTREGS_OFF, %o2
1596 /* Clear current_thread_info()->new_child, and
1597 * check performance counter stuff too.
1599 stb %g0, [%g6 + TI_NEW_CHILD]
1600 ldx [%g6 + TI_FLAGS], %l0
1603 andcc %l0, _TIF_PERFCTR, %g0
1606 ldx [%g6 + TI_PCR], %o7
1609 /* Blackbird errata workaround. See commentary in
1610 * smp.c:smp_percpu_timer_interrupt() for more
1616 99: wr %g0, %g0, %pic
1619 1: b,pt %xcc, ret_sys_call
1620 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
1621 sparc_exit: wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV), %pstate
1625 wrpr %g3, 0x0, %cansave
1626 wrpr %g0, 0x0, %otherwin
1627 wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV | PSTATE_IE), %pstate
1628 ba,pt %xcc, sys_exit
1629 stb %g0, [%g6 + TI_WSAVED]
1631 linux_sparc_ni_syscall:
1632 sethi %hi(sys_ni_syscall), %l7
1634 or %l7, %lo(sys_ni_syscall), %l7
1636 linux_syscall_trace32:
1637 add %sp, PTREGS_OFF, %o0
1647 linux_syscall_trace:
1648 add %sp, PTREGS_OFF, %o0
1659 /* Linux 32-bit and SunOS system calls enter here... */
1661 .globl linux_sparc_syscall32
1662 linux_sparc_syscall32:
1663 /* Direct access to user regs, much faster. */
1664 cmp %g1, NR_SYSCALLS ! IEU1 Group
1665 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1666 srl %i0, 0, %o0 ! IEU0
1667 sll %g1, 2, %l4 ! IEU0 Group
1668 srl %i4, 0, %o4 ! IEU1
1669 lduw [%l7 + %l4], %l7 ! Load
1670 srl %i1, 0, %o1 ! IEU0 Group
1671 ldx [%curptr + TI_FLAGS], %l0 ! Load
1673 srl %i5, 0, %o5 ! IEU1
1674 srl %i2, 0, %o2 ! IEU0 Group
1675 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1676 bne,pn %icc, linux_syscall_trace32 ! CTI
1678 call %l7 ! CTI Group brk forced
1679 srl %i3, 0, %o3 ! IEU0
1682 /* Linux native and SunOS system calls enter here... */
1684 .globl linux_sparc_syscall, ret_sys_call
1685 linux_sparc_syscall:
1686 /* Direct access to user regs, much faster. */
1687 cmp %g1, NR_SYSCALLS ! IEU1 Group
1688 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1690 sll %g1, 2, %l4 ! IEU0 Group
1692 lduw [%l7 + %l4], %l7 ! Load
1693 4: mov %i2, %o2 ! IEU0 Group
1694 ldx [%curptr + TI_FLAGS], %l0 ! Load
1697 mov %i4, %o4 ! IEU0 Group
1698 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1699 bne,pn %icc, linux_syscall_trace ! CTI Group
1701 2: call %l7 ! CTI Group brk forced
1705 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1707 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
1708 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
1710 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
1713 /* Check if force_successful_syscall_return()
1716 ldub [%curptr + TI_SYS_NOERROR], %l0
1720 stb %g0, [%curptr + TI_SYS_NOERROR]
1723 cmp %o0, -ERESTART_RESTARTBLOCK
1725 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
1727 /* System call success, clear Carry condition code. */
1729 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1730 bne,pn %icc, linux_syscall_trace2
1731 add %l1, 0x4, %l2 ! npc = npc+4
1732 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1733 ba,pt %xcc, rtrap_clr_l6
1734 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1737 /* System call failure, set Carry condition code.
1738 * Also, get abs(errno) to return to the process.
1740 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
1743 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1745 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1746 bne,pn %icc, linux_syscall_trace2
1747 add %l1, 0x4, %l2 ! npc = npc+4
1748 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1751 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1752 linux_syscall_trace2:
1753 add %sp, PTREGS_OFF, %o0
1756 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1758 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1761 .globl __flushw_user
1766 1: save %sp, -128, %sp
1772 restore %g0, %g0, %g0