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
705 cmp %g3, 0x80 ! first win spill/fill trap
707 cmp %g3, 0xff ! last win spill/fill trap
710 ba,pt %xcc, winfix_dax
712 1: sethi %hi(109f), %g7
714 109: or %g7, %lo(109b), %g7
717 call data_access_exception_tl1
718 add %sp, PTREGS_OFF, %o0
722 __do_data_access_exception:
724 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
727 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
728 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
729 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
733 109: or %g7, %lo(109b), %g7
736 call data_access_exception
737 add %sp, PTREGS_OFF, %o0
741 .globl __do_instruction_access_exception
742 .globl __do_instruction_access_exception_tl1
743 __do_instruction_access_exception_tl1:
745 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
747 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
748 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
749 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
753 109: or %g7, %lo(109b), %g7
756 call instruction_access_exception_tl1
757 add %sp, PTREGS_OFF, %o0
761 __do_instruction_access_exception:
763 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
765 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
766 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
767 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
771 109: or %g7, %lo(109b), %g7
774 call instruction_access_exception
775 add %sp, PTREGS_OFF, %o0
779 /* This is the trap handler entry point for ECC correctable
780 * errors. They are corrected, but we listen for the trap
781 * so that the event can be logged.
783 * Disrupting errors are either:
784 * 1) single-bit ECC errors during UDB reads to system
786 * 2) data parity errors during write-back events
788 * As far as I can make out from the manual, the CEE trap
789 * is only for correctable errors during memory read
790 * accesses by the front-end of the processor.
792 * The code below is only for trap level 1 CEE events,
793 * as it is the only situation where we can safely record
794 * and log. For trap level >1 we just clear the CE bit
795 * in the AFSR and return.
798 /* Our trap handling infrastructure allows us to preserve
799 * two 64-bit values during etrap for arguments to
800 * subsequent C code. Therefore we encode the information
803 * value 1) Full 64-bits of AFAR
804 * value 2) Low 33-bits of AFSR, then bits 33-->42
805 * are UDBL error status and bits 43-->52
806 * are UDBH error status
811 ldxa [%g0] ASI_AFSR, %g1 ! Read AFSR
812 ldxa [%g0] ASI_AFAR, %g2 ! Read AFAR
813 sllx %g1, 31, %g1 ! Clear reserved bits
814 srlx %g1, 31, %g1 ! in AFSR
816 /* NOTE: UltraSparc-I/II have high and low UDB error
817 * registers, corresponding to the two UDB units
818 * present on those chips. UltraSparc-IIi only
819 * has a single UDB, called "SDB" in the manual.
820 * For IIi the upper UDB register always reads
821 * as zero so for our purposes things will just
822 * work with the checks below.
824 ldxa [%g0] ASI_UDBL_ERROR_R, %g3 ! Read UDB-Low error status
825 andcc %g3, (1 << 8), %g4 ! Check CE bit
826 sllx %g3, (64 - 10), %g3 ! Clear reserved bits
827 srlx %g3, (64 - 10), %g3 ! in UDB-Low error status
829 sllx %g3, (33 + 0), %g3 ! Shift up to encoding area
830 or %g1, %g3, %g1 ! Or it in
831 be,pn %xcc, 1f ! Branch if CE bit was clear
833 stxa %g4, [%g0] ASI_UDB_ERROR_W ! Clear CE sticky bit in UDBL
834 membar #Sync ! Synchronize ASI stores
835 1: mov 0x18, %g5 ! Addr of UDB-High error status
836 ldxa [%g5] ASI_UDBH_ERROR_R, %g3 ! Read it
838 andcc %g3, (1 << 8), %g4 ! Check CE bit
839 sllx %g3, (64 - 10), %g3 ! Clear reserved bits
840 srlx %g3, (64 - 10), %g3 ! in UDB-High error status
841 sllx %g3, (33 + 10), %g3 ! Shift up to encoding area
842 or %g1, %g3, %g1 ! Or it in
843 be,pn %xcc, 1f ! Branch if CE bit was clear
847 stxa %g4, [%g5] ASI_UDB_ERROR_W ! Clear CE sticky bit in UDBH
848 membar #Sync ! Synchronize ASI stores
849 1: mov 1, %g5 ! AFSR CE bit is
850 sllx %g5, 20, %g5 ! bit 20
851 stxa %g5, [%g0] ASI_AFSR ! Clear CE sticky bit in AFSR
852 membar #Sync ! Synchronize ASI stores
853 sllx %g2, (64 - 41), %g2 ! Clear reserved bits
854 srlx %g2, (64 - 41), %g2 ! in latched AFAR
856 andn %g2, 0x0f, %g2 ! Finish resv bit clearing
857 mov %g1, %g4 ! Move AFSR+UDB* into save reg
858 mov %g2, %g5 ! Move AFAR into save reg
861 ba,pt %xcc, etrap_irq
867 add %sp, PTREGS_OFF, %o2
868 ba,a,pt %xcc, rtrap_irq
870 /* Capture I/D/E-cache state into per-cpu error scoreboard.
872 * %g1: (TL>=0) ? 1 : 0
877 * %g6: current thread ptr
880 #define CHEETAH_LOG_ERROR \
881 /* Put "TL1" software bit into AFSR. */ \
885 /* Get log entry pointer for this cpu at this trap level. */ \
886 BRANCH_IF_JALAPENO(g2,g3,50f) \
887 ldxa [%g0] ASI_SAFARI_CONFIG, %g2; \
890 and %g2, 0x3ff, %g2; \
891 50: ldxa [%g0] ASI_JBUS_CONFIG, %g2; \
893 and %g2, 0x1f, %g2; \
894 60: sllx %g2, 9, %g2; \
895 sethi %hi(cheetah_error_log), %g3; \
896 ldx [%g3 + %lo(cheetah_error_log)], %g3; \
902 /* %g1 holds pointer to the top of the logging scoreboard */ \
903 ldx [%g1 + 0x0], %g7; \
907 stx %g4, [%g1 + 0x0]; \
908 stx %g5, [%g1 + 0x8]; \
909 add %g1, 0x10, %g1; \
910 /* %g1 now points to D-cache logging area */ \
911 set 0x3ff8, %g2; /* DC_addr mask */ \
912 and %g5, %g2, %g2; /* DC_addr bits of AFAR */ \
914 or %g3, 1, %g3; /* PHYS tag + valid */ \
915 10: ldxa [%g2] ASI_DCACHE_TAG, %g7; \
916 cmp %g3, %g7; /* TAG match? */ \
919 /* Yep, what we want, capture state. */ \
920 stx %g2, [%g1 + 0x20]; \
921 stx %g7, [%g1 + 0x28]; \
922 /* A membar Sync is required before and after utag access. */ \
924 ldxa [%g2] ASI_DCACHE_UTAG, %g7; \
926 stx %g7, [%g1 + 0x30]; \
927 ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7; \
928 stx %g7, [%g1 + 0x38]; \
930 12: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7; \
932 add %g3, (1 << 5), %g3; \
937 add %g1, 0x20, %g1; \
938 13: sethi %hi(1 << 14), %g7; \
944 add %g1, 0x40, %g1; \
945 20: /* %g1 now points to I-cache logging area */ \
946 set 0x1fe0, %g2; /* IC_addr mask */ \
947 and %g5, %g2, %g2; /* IC_addr bits of AFAR */ \
948 sllx %g2, 1, %g2; /* IC_addr[13:6]==VA[12:5] */ \
949 srlx %g5, (13 - 8), %g3; /* Make PTAG */ \
950 andn %g3, 0xff, %g3; /* Mask off undefined bits */ \
951 21: ldxa [%g2] ASI_IC_TAG, %g7; \
952 andn %g7, 0xff, %g7; \
956 /* Yep, what we want, capture state. */ \
957 stx %g2, [%g1 + 0x40]; \
958 stx %g7, [%g1 + 0x48]; \
959 add %g2, (1 << 3), %g2; \
960 ldxa [%g2] ASI_IC_TAG, %g7; \
961 add %g2, (1 << 3), %g2; \
962 stx %g7, [%g1 + 0x50]; \
963 ldxa [%g2] ASI_IC_TAG, %g7; \
964 add %g2, (1 << 3), %g2; \
965 stx %g7, [%g1 + 0x60]; \
966 ldxa [%g2] ASI_IC_TAG, %g7; \
967 stx %g7, [%g1 + 0x68]; \
968 sub %g2, (3 << 3), %g2; \
969 ldxa [%g2] ASI_IC_STAG, %g7; \
970 stx %g7, [%g1 + 0x58]; \
973 22: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7; \
975 add %g3, (1 << 3), %g3; \
980 add %g1, 0x30, %g1; \
981 23: sethi %hi(1 << 14), %g7; \
987 add %g1, 0x70, %g1; \
988 30: /* %g1 now points to E-cache logging area */ \
989 andn %g5, (32 - 1), %g2; /* E-cache subblock */ \
990 stx %g2, [%g1 + 0x20]; \
991 ldxa [%g2] ASI_EC_TAG_DATA, %g7; \
992 stx %g7, [%g1 + 0x28]; \
993 ldxa [%g2] ASI_EC_R, %g0; \
995 31: ldxa [%g3] ASI_EC_DATA, %g7; \
996 stx %g7, [%g1 + %g3]; \
1003 /* These get patched into the trap table at boot time
1004 * once we know we have a cheetah processor.
1006 .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
1007 cheetah_fecc_trap_vector:
1009 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1010 andn %g1, DCU_DC | DCU_IC, %g1
1011 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1013 sethi %hi(cheetah_fast_ecc), %g2
1014 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
1016 cheetah_fecc_trap_vector_tl1:
1018 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1019 andn %g1, DCU_DC | DCU_IC, %g1
1020 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1022 sethi %hi(cheetah_fast_ecc), %g2
1023 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
1025 .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
1026 cheetah_cee_trap_vector:
1028 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1029 andn %g1, DCU_IC, %g1
1030 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1032 sethi %hi(cheetah_cee), %g2
1033 jmpl %g2 + %lo(cheetah_cee), %g0
1035 cheetah_cee_trap_vector_tl1:
1037 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1038 andn %g1, DCU_IC, %g1
1039 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1041 sethi %hi(cheetah_cee), %g2
1042 jmpl %g2 + %lo(cheetah_cee), %g0
1044 .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
1045 cheetah_deferred_trap_vector:
1047 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
1048 andn %g1, DCU_DC | DCU_IC, %g1;
1049 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
1051 sethi %hi(cheetah_deferred_trap), %g2
1052 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
1054 cheetah_deferred_trap_vector_tl1:
1056 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
1057 andn %g1, DCU_DC | DCU_IC, %g1;
1058 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
1060 sethi %hi(cheetah_deferred_trap), %g2
1061 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
1064 /* Cheetah+ specific traps. These are for the new I/D cache parity
1065 * error traps. The first argument to cheetah_plus_parity_handler
1066 * is encoded as follows:
1068 * Bit0: 0=dcache,1=icache
1069 * Bit1: 0=recoverable,1=unrecoverable
1071 .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
1072 cheetah_plus_dcpe_trap_vector:
1074 sethi %hi(do_cheetah_plus_data_parity), %g7
1075 jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
1082 do_cheetah_plus_data_parity:
1086 call cheetah_plus_parity_error
1087 add %sp, PTREGS_OFF, %o1
1091 cheetah_plus_dcpe_trap_vector_tl1:
1093 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
1094 sethi %hi(do_dcpe_tl1), %g3
1095 jmpl %g3 + %lo(do_dcpe_tl1), %g0
1101 .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
1102 cheetah_plus_icpe_trap_vector:
1104 sethi %hi(do_cheetah_plus_insn_parity), %g7
1105 jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
1112 do_cheetah_plus_insn_parity:
1116 call cheetah_plus_parity_error
1117 add %sp, PTREGS_OFF, %o1
1121 cheetah_plus_icpe_trap_vector_tl1:
1123 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
1124 sethi %hi(do_icpe_tl1), %g3
1125 jmpl %g3 + %lo(do_icpe_tl1), %g0
1131 /* If we take one of these traps when tl >= 1, then we
1132 * jump to interrupt globals. If some trap level above us
1133 * was also using interrupt globals, we cannot recover.
1134 * We may use all interrupt global registers except %g6.
1136 .globl do_dcpe_tl1, do_icpe_tl1
1138 rdpr %tl, %g1 ! Save original trap level
1139 mov 1, %g2 ! Setup TSTATE checking loop
1140 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
1141 1: wrpr %g2, %tl ! Set trap level to check
1142 rdpr %tstate, %g4 ! Read TSTATE for this level
1143 andcc %g4, %g3, %g0 ! Interrupt globals in use?
1144 bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
1145 wrpr %g1, %tl ! Restore original trap level
1146 add %g2, 1, %g2 ! Next trap level
1147 cmp %g2, %g1 ! Hit them all yet?
1148 ble,pt %icc, 1b ! Not yet
1150 wrpr %g1, %tl ! Restore original trap level
1151 do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
1152 /* Reset D-cache parity */
1153 sethi %hi(1 << 16), %g1 ! D-cache size
1154 mov (1 << 5), %g2 ! D-cache line size
1155 sub %g1, %g2, %g1 ! Move down 1 cacheline
1156 1: srl %g1, 14, %g3 ! Compute UTAG
1158 stxa %g3, [%g1] ASI_DCACHE_UTAG
1160 sub %g2, 8, %g3 ! 64-bit data word within line
1162 stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
1164 subcc %g3, 8, %g3 ! Next 64-bit data word
1167 subcc %g1, %g2, %g1 ! Next cacheline
1170 ba,pt %xcc, dcpe_icpe_tl1_common
1175 ba,pt %xcc, etraptl1
1176 1: or %g7, %lo(1b), %g7
1178 call cheetah_plus_parity_error
1179 add %sp, PTREGS_OFF, %o1
1184 rdpr %tl, %g1 ! Save original trap level
1185 mov 1, %g2 ! Setup TSTATE checking loop
1186 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
1187 1: wrpr %g2, %tl ! Set trap level to check
1188 rdpr %tstate, %g4 ! Read TSTATE for this level
1189 andcc %g4, %g3, %g0 ! Interrupt globals in use?
1190 bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
1191 wrpr %g1, %tl ! Restore original trap level
1192 add %g2, 1, %g2 ! Next trap level
1193 cmp %g2, %g1 ! Hit them all yet?
1194 ble,pt %icc, 1b ! Not yet
1196 wrpr %g1, %tl ! Restore original trap level
1197 do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
1199 sethi %hi(1 << 15), %g1 ! I-cache size
1200 mov (1 << 5), %g2 ! I-cache line size
1202 1: or %g1, (2 << 3), %g3
1203 stxa %g0, [%g3] ASI_IC_TAG
1208 ba,pt %xcc, dcpe_icpe_tl1_common
1213 ba,pt %xcc, etraptl1
1214 1: or %g7, %lo(1b), %g7
1216 call cheetah_plus_parity_error
1217 add %sp, PTREGS_OFF, %o1
1221 dcpe_icpe_tl1_common:
1222 /* Flush D-cache, re-enable D/I caches in DCU and finally
1223 * retry the trapping instruction.
1225 sethi %hi(1 << 16), %g1 ! D-cache size
1226 mov (1 << 5), %g2 ! D-cache line size
1228 1: stxa %g0, [%g1] ASI_DCACHE_TAG
1233 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1234 or %g1, (DCU_DC | DCU_IC), %g1
1235 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1239 /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
1240 * in the trap table. That code has done a memory barrier
1241 * and has disabled both the I-cache and D-cache in the DCU
1242 * control register. The I-cache is disabled so that we may
1243 * capture the corrupted cache line, and the D-cache is disabled
1244 * because corrupt data may have been placed there and we don't
1245 * want to reference it.
1247 * %g1 is one if this trap occurred at %tl >= 1.
1249 * Next, we turn off error reporting so that we don't recurse.
1251 .globl cheetah_fast_ecc
1253 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1254 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1255 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1258 /* Fetch and clear AFSR/AFAR */
1259 ldxa [%g0] ASI_AFSR, %g4
1260 ldxa [%g0] ASI_AFAR, %g5
1261 stxa %g4, [%g0] ASI_AFSR
1268 ba,pt %xcc, etrap_irq
1272 call cheetah_fecc_handler
1273 add %sp, PTREGS_OFF, %o0
1274 ba,a,pt %xcc, rtrap_irq
1276 /* Our caller has disabled I-cache and performed membar Sync. */
1279 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1280 andn %g2, ESTATE_ERROR_CEEN, %g2
1281 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1284 /* Fetch and clear AFSR/AFAR */
1285 ldxa [%g0] ASI_AFSR, %g4
1286 ldxa [%g0] ASI_AFAR, %g5
1287 stxa %g4, [%g0] ASI_AFSR
1294 ba,pt %xcc, etrap_irq
1298 call cheetah_cee_handler
1299 add %sp, PTREGS_OFF, %o0
1300 ba,a,pt %xcc, rtrap_irq
1302 /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
1303 .globl cheetah_deferred_trap
1304 cheetah_deferred_trap:
1305 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1306 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1307 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1310 /* Fetch and clear AFSR/AFAR */
1311 ldxa [%g0] ASI_AFSR, %g4
1312 ldxa [%g0] ASI_AFAR, %g5
1313 stxa %g4, [%g0] ASI_AFSR
1320 ba,pt %xcc, etrap_irq
1324 call cheetah_deferred_handler
1325 add %sp, PTREGS_OFF, %o0
1326 ba,a,pt %xcc, rtrap_irq
1331 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1333 sethi %hi(109f), %g7
1335 109: or %g7, %lo(109b), %g7
1337 add %sp, PTREGS_OFF, %o0
1346 /* Setup %g4/%g5 now as they are used in the
1351 ldxa [%g4] ASI_DMMU, %g4
1352 ldxa [%g3] ASI_DMMU, %g5
1353 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1355 bgu,pn %icc, winfix_mna
1358 1: sethi %hi(109f), %g7
1360 109: or %g7, %lo(109b), %g7
1363 call mem_address_unaligned
1364 add %sp, PTREGS_OFF, %o0
1370 sethi %hi(109f), %g7
1372 ldxa [%g4] ASI_DMMU, %g5
1373 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1376 ldxa [%g4] ASI_DMMU, %g4
1378 109: or %g7, %lo(109b), %g7
1382 add %sp, PTREGS_OFF, %o0
1388 sethi %hi(109f), %g7
1390 ldxa [%g4] ASI_DMMU, %g5
1391 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1394 ldxa [%g4] ASI_DMMU, %g4
1396 109: or %g7, %lo(109b), %g7
1400 add %sp, PTREGS_OFF, %o0
1404 .globl breakpoint_trap
1406 call sparc_breakpoint
1407 add %sp, PTREGS_OFF, %o0
1411 #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
1412 defined(CONFIG_SOLARIS_EMUL_MODULE)
1413 /* SunOS uses syscall zero as the 'indirect syscall' it looks
1414 * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
1415 * This is complete brain damage.
1421 cmp %o0, NR_SYSCALLS
1424 sethi %hi(sunos_nosys), %l6
1426 or %l6, %lo(sunos_nosys), %l6
1427 1: sethi %hi(sunos_sys_table), %l7
1428 or %l7, %lo(sunos_sys_table), %l7
1429 lduw [%l7 + %o0], %l6
1443 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1444 b,pt %xcc, ret_sys_call
1445 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1447 /* SunOS getuid() returns uid in %o0 and euid in %o1 */
1450 call sys32_geteuid16
1453 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1454 b,pt %xcc, ret_sys_call
1455 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1457 /* SunOS getgid() returns gid in %o0 and egid in %o1 */
1460 call sys32_getegid16
1463 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1464 b,pt %xcc, ret_sys_call
1465 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1468 /* SunOS's execv() call only specifies the argv argument, the
1469 * environment settings are the same as the calling processes.
1473 sethi %hi(sparc_execve), %g1
1474 ba,pt %xcc, execve_merge
1475 or %g1, %lo(sparc_execve), %g1
1476 #ifdef CONFIG_COMPAT
1479 stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
1482 sethi %hi(sparc32_execve), %g1
1483 or %g1, %lo(sparc32_execve), %g1
1488 add %sp, PTREGS_OFF, %o0
1490 .globl sys_pipe, sys_sigpause, sys_nis_syscall
1491 .globl sys_sigsuspend, sys_rt_sigsuspend
1492 .globl sys_rt_sigreturn
1494 .globl sys_sigaltstack
1496 sys_pipe: ba,pt %xcc, sparc_pipe
1497 add %sp, PTREGS_OFF, %o0
1498 sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
1499 add %sp, PTREGS_OFF, %o0
1500 sys_memory_ordering:
1501 ba,pt %xcc, sparc_memory_ordering
1502 add %sp, PTREGS_OFF, %o1
1503 sys_sigaltstack:ba,pt %xcc, do_sigaltstack
1504 add %i6, STACK_BIAS, %o2
1505 #ifdef CONFIG_COMPAT
1506 .globl sys32_sigstack
1507 sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
1509 .globl sys32_sigaltstack
1511 ba,pt %xcc, do_sys32_sigaltstack
1515 sys_sigsuspend: add %sp, PTREGS_OFF, %o0
1517 add %o7, 1f-.-4, %o7
1519 sys_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
1520 add %sp, PTREGS_OFF, %o2
1521 call do_rt_sigsuspend
1522 add %o7, 1f-.-4, %o7
1524 #ifdef CONFIG_COMPAT
1525 .globl sys32_rt_sigsuspend
1526 sys32_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
1528 add %sp, PTREGS_OFF, %o2
1529 call do_rt_sigsuspend32
1530 add %o7, 1f-.-4, %o7
1532 /* NOTE: %o0 has a correct value already */
1533 sys_sigpause: add %sp, PTREGS_OFF, %o1
1535 add %o7, 1f-.-4, %o7
1537 #ifdef CONFIG_COMPAT
1538 .globl sys32_sigreturn
1540 add %sp, PTREGS_OFF, %o0
1542 add %o7, 1f-.-4, %o7
1546 add %sp, PTREGS_OFF, %o0
1547 call do_rt_sigreturn
1548 add %o7, 1f-.-4, %o7
1550 #ifdef CONFIG_COMPAT
1551 .globl sys32_rt_sigreturn
1553 add %sp, PTREGS_OFF, %o0
1554 call do_rt_sigreturn32
1555 add %o7, 1f-.-4, %o7
1558 sys_ptrace: add %sp, PTREGS_OFF, %o0
1560 add %o7, 1f-.-4, %o7
1563 1: ldx [%curptr + TI_FLAGS], %l5
1564 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1567 add %sp, PTREGS_OFF, %o0
1574 /* This is how fork() was meant to be done, 8 instruction entry.
1576 * I questioned the following code briefly, let me clear things
1577 * up so you must not reason on it like I did.
1579 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
1580 * need it here because the only piece of window state we copy to
1581 * the child is the CWP register. Even if the parent sleeps,
1582 * we are safe because we stuck it into pt_regs of the parent
1583 * so it will not change.
1585 * XXX This raises the question, whether we can do the same on
1586 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
1587 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
1588 * XXX fork_kwim in UREG_G1 (global registers are considered
1589 * XXX volatile across a system call in the sparc ABI I think
1590 * XXX if it isn't we can use regs->y instead, anyone who depends
1591 * XXX upon the Y register being preserved across a fork deserves
1594 * In fact we should take advantage of that fact for other things
1595 * during system calls...
1597 .globl sys_fork, sys_vfork, sys_clone, sparc_exit
1598 .globl ret_from_syscall
1600 sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
1601 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
1602 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
1603 ba,pt %xcc, sys_clone
1609 ba,pt %xcc, sparc_do_fork
1610 add %sp, PTREGS_OFF, %o2
1612 /* Clear current_thread_info()->new_child, and
1613 * check performance counter stuff too.
1615 stb %g0, [%g6 + TI_NEW_CHILD]
1616 ldx [%g6 + TI_FLAGS], %l0
1619 andcc %l0, _TIF_PERFCTR, %g0
1622 ldx [%g6 + TI_PCR], %o7
1625 /* Blackbird errata workaround. See commentary in
1626 * smp.c:smp_percpu_timer_interrupt() for more
1632 99: wr %g0, %g0, %pic
1635 1: b,pt %xcc, ret_sys_call
1636 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
1637 sparc_exit: wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV), %pstate
1641 wrpr %g3, 0x0, %cansave
1642 wrpr %g0, 0x0, %otherwin
1643 wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV | PSTATE_IE), %pstate
1644 ba,pt %xcc, sys_exit
1645 stb %g0, [%g6 + TI_WSAVED]
1647 linux_sparc_ni_syscall:
1648 sethi %hi(sys_ni_syscall), %l7
1650 or %l7, %lo(sys_ni_syscall), %l7
1652 linux_syscall_trace32:
1653 add %sp, PTREGS_OFF, %o0
1663 linux_syscall_trace:
1664 add %sp, PTREGS_OFF, %o0
1675 /* Linux 32-bit and SunOS system calls enter here... */
1677 .globl linux_sparc_syscall32
1678 linux_sparc_syscall32:
1679 /* Direct access to user regs, much faster. */
1680 cmp %g1, NR_SYSCALLS ! IEU1 Group
1681 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1682 srl %i0, 0, %o0 ! IEU0
1683 sll %g1, 2, %l4 ! IEU0 Group
1684 srl %i4, 0, %o4 ! IEU1
1685 lduw [%l7 + %l4], %l7 ! Load
1686 srl %i1, 0, %o1 ! IEU0 Group
1687 ldx [%curptr + TI_FLAGS], %l0 ! Load
1689 srl %i5, 0, %o5 ! IEU1
1690 srl %i2, 0, %o2 ! IEU0 Group
1691 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1692 bne,pn %icc, linux_syscall_trace32 ! CTI
1694 call %l7 ! CTI Group brk forced
1695 srl %i3, 0, %o3 ! IEU0
1698 /* Linux native and SunOS system calls enter here... */
1700 .globl linux_sparc_syscall, ret_sys_call
1701 linux_sparc_syscall:
1702 /* Direct access to user regs, much faster. */
1703 cmp %g1, NR_SYSCALLS ! IEU1 Group
1704 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1706 sll %g1, 2, %l4 ! IEU0 Group
1708 lduw [%l7 + %l4], %l7 ! Load
1709 4: mov %i2, %o2 ! IEU0 Group
1710 ldx [%curptr + TI_FLAGS], %l0 ! Load
1713 mov %i4, %o4 ! IEU0 Group
1714 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1715 bne,pn %icc, linux_syscall_trace ! CTI Group
1717 2: call %l7 ! CTI Group brk forced
1721 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1723 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
1724 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
1726 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
1729 /* Check if force_successful_syscall_return()
1732 ldub [%curptr + TI_SYS_NOERROR], %l0
1736 stb %g0, [%curptr + TI_SYS_NOERROR]
1739 cmp %o0, -ERESTART_RESTARTBLOCK
1741 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
1743 /* System call success, clear Carry condition code. */
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]
1749 ba,pt %xcc, rtrap_clr_l6
1750 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1753 /* System call failure, set Carry condition code.
1754 * Also, get abs(errno) to return to the process.
1756 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
1759 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1761 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1762 bne,pn %icc, linux_syscall_trace2
1763 add %l1, 0x4, %l2 ! npc = npc+4
1764 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1767 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1768 linux_syscall_trace2:
1769 add %sp, PTREGS_OFF, %o0
1772 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1774 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1777 .globl __flushw_user
1782 1: save %sp, -128, %sp
1788 restore %g0, %g0, %g0