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>
24 #include <asm/sfafsr.h>
28 #define NR_SYSCALLS 284 /* Each OS is different... */
33 .globl sparc64_vpte_patchme1
34 .globl sparc64_vpte_patchme2
36 * On a second level vpte miss, check whether the original fault is to the OBP
37 * range (note that this is only possible for instruction miss, data misses to
38 * obp range do not use vpte). If so, go back directly to the faulting address.
39 * This is because we want to read the tpc, otherwise we have no way of knowing
40 * the 8k aligned faulting address if we are using >8k kernel pagesize. This
41 * also ensures no vpte range addresses are dropped into tlb while obp is
42 * executing (see inherit_locked_prom_mappings() rant).
45 /* Load 0xf0000000, which is LOW_OBP_ADDRESS. */
49 /* Is addr >= LOW_OBP_ADDRESS? */
51 blu,pn %xcc, sparc64_vpte_patchme1
54 /* Load 0x100000000, which is HI_OBP_ADDRESS. */
57 /* Is addr < HI_OBP_ADDRESS? */
59 blu,pn %xcc, obp_iaddr_patch
62 /* These two instructions are patched by paginig_init(). */
63 sparc64_vpte_patchme1:
65 sparc64_vpte_patchme2:
68 /* With kernel PGD in %g5, branch back into dtlb_backend. */
69 ba,pt %xcc, sparc64_kpte_continue
70 andn %g1, 0x3, %g1 /* Finish PMD offset adjustment. */
73 /* Restore previous TAG_ACCESS, %g5 is zero, and we will
74 * skip over the trap instruction so that the top level
75 * TLB miss handler will thing this %g5 value is just an
76 * invalid PTE, thus branching to full fault processing.
79 stxa %g4, [%g1 + %g1] ASI_DMMU
82 .globl obp_iaddr_patch
84 /* These two instructions patched by inherit_prom_mappings(). */
88 /* Behave as if we are at TL0. */
90 rdpr %tpc, %g4 /* Find original faulting iaddr */
91 srlx %g4, 13, %g4 /* Throw out context bits */
92 sllx %g4, 13, %g4 /* g4 has vpn + ctx0 now */
94 /* Restore previous TAG_ACCESS. */
96 stxa %g4, [%g1 + %g1] ASI_IMMU
103 /* Load PMD, is it valid? */
104 lduwa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
108 /* Get PTE offset. */
114 ldxa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
115 brgez,pn %g5, longpath
118 /* TLB load and return from trap. */
119 stxa %g5, [%g0] ASI_ITLB_DATA_IN
122 .globl obp_daddr_patch
124 /* These two instructions patched by inherit_prom_mappings(). */
128 /* Get PMD offset. */
133 /* Load PMD, is it valid? */
134 lduwa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
138 /* Get PTE offset. */
144 ldxa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
145 brgez,pn %g5, longpath
148 /* TLB load and return from trap. */
149 stxa %g5, [%g0] ASI_DTLB_DATA_IN
153 * On a first level data miss, check whether this is to the OBP range (note
154 * that such accesses can be made by prom, as well as by kernel using
155 * prom_getproperty on "address"), and if so, do not use vpte access ...
156 * rather, use information saved during inherit_prom_mappings() using 8k
160 /* Load 0xf0000000, which is LOW_OBP_ADDRESS. */
164 /* Is addr >= LOW_OBP_ADDRESS? */
166 blu,pn %xcc, vmalloc_addr
169 /* Load 0x100000000, which is HI_OBP_ADDRESS. */
172 /* Is addr < HI_OBP_ADDRESS? */
174 blu,pn %xcc, obp_daddr_patch
178 /* If we get here, a vmalloc addr accessed, load kernel VPTE. */
179 ldxa [%g3 + %g6] ASI_N, %g5
180 brgez,pn %g5, longpath
183 /* PTE is valid, load into TLB and return from trap. */
184 stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Reload TLB
187 /* This is trivial with the new code... */
190 sethi %hi(TSTATE_PEF), %g4 ! IEU0
196 andcc %g5, FPRS_FEF, %g0
200 /* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
203 109: or %g7, %lo(109b), %g7
205 ba,a,pt %xcc, rtrap_clr_l6
207 1: ldub [%g6 + TI_FPSAVED], %g5 ! Load Group
208 wr %g0, FPRS_FEF, %fprs ! LSU Group+4bubbles
209 andcc %g5, FPRS_FEF, %g0 ! IEU1 Group
210 be,a,pt %icc, 1f ! CTI
212 ldx [%g6 + TI_GSR], %g7 ! Load Group
213 1: andcc %g5, FPRS_DL, %g0 ! IEU1
214 bne,pn %icc, 2f ! CTI
216 andcc %g5, FPRS_DU, %g0 ! IEU1 Group
217 bne,pn %icc, 1f ! CTI
247 b,pt %xcc, fpdis_exit2
249 1: mov SECONDARY_CONTEXT, %g3
250 add %g6, TI_FPREGS + 0x80, %g1
253 ldxa [%g3] ASI_DMMU, %g5
256 stxa %g2, [%g3] ASI_DMMU
258 add %g6, TI_FPREGS + 0xc0, %g2
261 ldda [%g1] ASI_BLK_S, %f32 ! grrr, where is ASI_BLK_NUCLEUS 8-(
262 ldda [%g2] ASI_BLK_S, %f48
274 b,pt %xcc, fpdis_exit
276 2: andcc %g5, FPRS_DU, %g0
279 mov SECONDARY_CONTEXT, %g3
281 ldxa [%g3] ASI_DMMU, %g5
282 add %g6, TI_FPREGS, %g1
285 stxa %g2, [%g3] ASI_DMMU
287 add %g6, TI_FPREGS + 0x40, %g2
288 faddd %f32, %f34, %f36
289 fmuld %f32, %f34, %f38
290 ldda [%g1] ASI_BLK_S, %f0 ! grrr, where is ASI_BLK_NUCLEUS 8-(
291 ldda [%g2] ASI_BLK_S, %f16
292 faddd %f32, %f34, %f40
293 fmuld %f32, %f34, %f42
294 faddd %f32, %f34, %f44
295 fmuld %f32, %f34, %f46
296 faddd %f32, %f34, %f48
297 fmuld %f32, %f34, %f50
298 faddd %f32, %f34, %f52
299 fmuld %f32, %f34, %f54
300 faddd %f32, %f34, %f56
301 fmuld %f32, %f34, %f58
302 faddd %f32, %f34, %f60
303 fmuld %f32, %f34, %f62
305 ba,pt %xcc, fpdis_exit
307 3: mov SECONDARY_CONTEXT, %g3
308 add %g6, TI_FPREGS, %g1
309 ldxa [%g3] ASI_DMMU, %g5
312 stxa %g2, [%g3] ASI_DMMU
315 ldda [%g1] ASI_BLK_S, %f0 ! grrr, where is ASI_BLK_NUCLEUS 8-(
316 ldda [%g1 + %g2] ASI_BLK_S, %f16
318 ldda [%g1] ASI_BLK_S, %f32
319 ldda [%g1 + %g2] ASI_BLK_S, %f48
322 stxa %g5, [%g3] ASI_DMMU
326 ldx [%g6 + TI_XFSR], %fsr
328 or %g3, %g4, %g3 ! anal...
330 wr %g0, FPRS_FEF, %fprs ! clean DU/DL bits
336 add %sp, PTREGS_OFF, %o0
340 .globl do_fpother_check_fitos
342 do_fpother_check_fitos:
343 sethi %hi(fp_other_bounce - 4), %g7
344 or %g7, %lo(fp_other_bounce - 4), %g7
346 /* NOTE: Need to preserve %g7 until we fully commit
347 * to the fitos fixup.
349 stx %fsr, [%g6 + TI_XFSR]
351 andcc %g3, TSTATE_PRIV, %g0
352 bne,pn %xcc, do_fptrap_after_fsr
354 ldx [%g6 + TI_XFSR], %g3
357 cmp %g1, 2 ! Unfinished FP-OP
358 bne,pn %xcc, do_fptrap_after_fsr
359 sethi %hi(1 << 23), %g1 ! Inexact
361 bne,pn %xcc, do_fptrap_after_fsr
363 lduwa [%g1] ASI_AIUP, %g3 ! This cannot ever fail
364 #define FITOS_MASK 0xc1f83fe0
365 #define FITOS_COMPARE 0x81a01880
366 sethi %hi(FITOS_MASK), %g1
367 or %g1, %lo(FITOS_MASK), %g1
369 sethi %hi(FITOS_COMPARE), %g2
370 or %g2, %lo(FITOS_COMPARE), %g2
372 bne,pn %xcc, do_fptrap_after_fsr
374 std %f62, [%g6 + TI_FPREGS + (62 * 4)]
375 sethi %hi(fitos_table_1), %g1
377 or %g1, %lo(fitos_table_1), %g1
380 ba,pt %xcc, fitos_emul_continue
417 sethi %hi(fitos_table_2), %g1
419 or %g1, %lo(fitos_table_2), %g1
423 ba,pt %xcc, fitos_emul_fini
460 ldd [%g6 + TI_FPREGS + (62 * 4)], %f62
466 stx %fsr, [%g6 + TI_XFSR]
468 ldub [%g6 + TI_FPSAVED], %g3
471 stb %g3, [%g6 + TI_FPSAVED]
473 stx %g3, [%g6 + TI_GSR]
474 mov SECONDARY_CONTEXT, %g3
475 ldxa [%g3] ASI_DMMU, %g5
478 stxa %g2, [%g3] ASI_DMMU
480 add %g6, TI_FPREGS, %g2
481 andcc %g1, FPRS_DL, %g0
484 stda %f0, [%g2] ASI_BLK_S
485 stda %f16, [%g2 + %g3] ASI_BLK_S
486 andcc %g1, FPRS_DU, %g0
489 stda %f32, [%g2] ASI_BLK_S
490 stda %f48, [%g2 + %g3] ASI_BLK_S
491 5: mov SECONDARY_CONTEXT, %g1
493 stxa %g5, [%g1] ASI_DMMU
499 sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
501 .globl cheetah_plus_patch_fpdis
502 cheetah_plus_patch_fpdis:
503 /* We configure the dTLB512_0 for 4MB pages and the
504 * dTLB512_1 for 8K pages when in context zero.
506 sethi %hi(cplus_fptrap_1), %o0
507 lduw [%o0 + %lo(cplus_fptrap_1)], %o1
509 set cplus_fptrap_insn_1, %o2
512 set cplus_fptrap_insn_2, %o2
515 set cplus_fptrap_insn_3, %o2
518 set cplus_fptrap_insn_4, %o2
525 /* The registers for cross calls will be:
527 * DATA 0: [low 32-bits] Address of function to call, jmp to this
528 * [high 32-bits] MMU Context Argument 0, place in %g5
529 * DATA 1: Address Argument 1, place in %g6
530 * DATA 2: Address Argument 2, place in %g7
532 * With this method we can do most of the cross-call tlb/cache
533 * flushing very quickly.
535 * Current CPU's IRQ worklist table is locked into %g1,
543 ldxa [%g3 + %g0] ASI_INTR_R, %g3
544 sethi %hi(KERNBASE), %g4
546 bgeu,pn %xcc, do_ivec_xcall
548 stxa %g0, [%g0] ASI_INTR_RECEIVE
551 sethi %hi(ivector_table), %g2
553 or %g2, %lo(ivector_table), %g2
555 ldub [%g3 + 0x04], %g4 /* pil */
560 lduw [%g6 + %g4], %g5 /* g5 = irq_work(cpu, pil) */
561 stw %g5, [%g3 + 0x00] /* bucket->irq_chain = g5 */
562 stw %g3, [%g6 + %g4] /* irq_work(cpu, pil) = bucket */
563 wr %g2, 0x0, %set_softint
567 ldxa [%g1 + %g0] ASI_INTR_R, %g1
571 ldxa [%g7 + %g0] ASI_INTR_R, %g7
572 stxa %g0, [%g0] ASI_INTR_RECEIVE
581 .globl save_alternate_globals
582 save_alternate_globals: /* %o0 = save_area */
584 andn %o5, PSTATE_IE, %o1
585 wrpr %o1, PSTATE_AG, %pstate
586 stx %g0, [%o0 + 0x00]
587 stx %g1, [%o0 + 0x08]
588 stx %g2, [%o0 + 0x10]
589 stx %g3, [%o0 + 0x18]
590 stx %g4, [%o0 + 0x20]
591 stx %g5, [%o0 + 0x28]
592 stx %g6, [%o0 + 0x30]
593 stx %g7, [%o0 + 0x38]
594 wrpr %o1, PSTATE_IG, %pstate
595 stx %g0, [%o0 + 0x40]
596 stx %g1, [%o0 + 0x48]
597 stx %g2, [%o0 + 0x50]
598 stx %g3, [%o0 + 0x58]
599 stx %g4, [%o0 + 0x60]
600 stx %g5, [%o0 + 0x68]
601 stx %g6, [%o0 + 0x70]
602 stx %g7, [%o0 + 0x78]
603 wrpr %o1, PSTATE_MG, %pstate
604 stx %g0, [%o0 + 0x80]
605 stx %g1, [%o0 + 0x88]
606 stx %g2, [%o0 + 0x90]
607 stx %g3, [%o0 + 0x98]
608 stx %g4, [%o0 + 0xa0]
609 stx %g5, [%o0 + 0xa8]
610 stx %g6, [%o0 + 0xb0]
611 stx %g7, [%o0 + 0xb8]
612 wrpr %o5, 0x0, %pstate
616 .globl restore_alternate_globals
617 restore_alternate_globals: /* %o0 = save_area */
619 andn %o5, PSTATE_IE, %o1
620 wrpr %o1, PSTATE_AG, %pstate
621 ldx [%o0 + 0x00], %g0
622 ldx [%o0 + 0x08], %g1
623 ldx [%o0 + 0x10], %g2
624 ldx [%o0 + 0x18], %g3
625 ldx [%o0 + 0x20], %g4
626 ldx [%o0 + 0x28], %g5
627 ldx [%o0 + 0x30], %g6
628 ldx [%o0 + 0x38], %g7
629 wrpr %o1, PSTATE_IG, %pstate
630 ldx [%o0 + 0x40], %g0
631 ldx [%o0 + 0x48], %g1
632 ldx [%o0 + 0x50], %g2
633 ldx [%o0 + 0x58], %g3
634 ldx [%o0 + 0x60], %g4
635 ldx [%o0 + 0x68], %g5
636 ldx [%o0 + 0x70], %g6
637 ldx [%o0 + 0x78], %g7
638 wrpr %o1, PSTATE_MG, %pstate
639 ldx [%o0 + 0x80], %g0
640 ldx [%o0 + 0x88], %g1
641 ldx [%o0 + 0x90], %g2
642 ldx [%o0 + 0x98], %g3
643 ldx [%o0 + 0xa0], %g4
644 ldx [%o0 + 0xa8], %g5
645 ldx [%o0 + 0xb0], %g6
646 ldx [%o0 + 0xb8], %g7
647 wrpr %o5, 0x0, %pstate
653 ldx [%o0 + PT_V9_TSTATE], %o1
657 stx %o1, [%o0 + PT_V9_G1]
659 ldx [%o0 + PT_V9_TSTATE], %o1
660 ldx [%o0 + PT_V9_G1], %o2
661 or %g0, %ulo(TSTATE_ICC), %o3
668 stx %o1, [%o0 + PT_V9_TSTATE]
670 .globl utrap, utrap_ill
671 utrap: brz,pn %g1, etrap
676 andn %l6, TSTATE_CWP, %l6
677 wrpr %l6, %l7, %tstate
684 add %sp, PTREGS_OFF, %o0
688 /* XXX Here is stuff we still need to write... -DaveM XXX */
689 .globl netbsd_syscall
694 /* We need to carefully read the error status, ACK
695 * the errors, prevent recursive traps, and pass the
696 * information on to C code for logging.
698 * We pass the AFAR in as-is, and we encode the status
699 * information as described in asm-sparc64/sfafsr.h
701 .globl __spitfire_access_error
702 __spitfire_access_error:
703 /* Disable ESTATE error reporting so that we do not
704 * take recursive traps and RED state the processor.
706 stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
710 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
712 /* __spitfire_cee_trap branches here with AFSR in %g4 and
713 * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the
714 * ESTATE Error Enable register.
716 __spitfire_cee_trap_continue:
717 ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
720 and %g3, 0x1ff, %g3 ! Paranoia
721 sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
727 sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
731 /* Read in the UDB error register state, clearing the
732 * sticky error bits as-needed. We only clear them if
733 * the UE bit is set. Likewise, __spitfire_cee_trap
734 * below will only do so if the CE bit is set.
736 * NOTE: UltraSparc-I/II have high and low UDB error
737 * registers, corresponding to the two UDB units
738 * present on those chips. UltraSparc-IIi only
739 * has a single UDB, called "SDB" in the manual.
740 * For IIi the upper UDB register always reads
741 * as zero so for our purposes things will just
742 * work with the checks below.
744 1: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
745 and %g3, 0x3ff, %g7 ! Paranoia
746 sllx %g7, SFSTAT_UDBH_SHIFT, %g7
748 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
751 stxa %g3, [%g0] ASI_UDB_ERROR_W
755 ldxa [%g3] ASI_UDBL_ERROR_R, %g3
756 and %g3, 0x3ff, %g7 ! Paranoia
757 sllx %g7, SFSTAT_UDBL_SHIFT, %g7
759 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
763 stxa %g3, [%g7] ASI_UDB_ERROR_W
766 1: /* Ok, now that we've latched the error state,
767 * clear the sticky bits in the AFSR.
769 stxa %g4, [%g0] ASI_AFSR
784 1: ba,pt %xcc, etrap_irq
789 call spitfire_access_error
790 add %sp, PTREGS_OFF, %o0
794 /* This is the trap handler entry point for ECC correctable
795 * errors. They are corrected, but we listen for the trap
796 * so that the event can be logged.
798 * Disrupting errors are either:
799 * 1) single-bit ECC errors during UDB reads to system
801 * 2) data parity errors during write-back events
803 * As far as I can make out from the manual, the CEE trap
804 * is only for correctable errors during memory read
805 * accesses by the front-end of the processor.
807 * The code below is only for trap level 1 CEE events,
808 * as it is the only situation where we can safely record
809 * and log. For trap level >1 we just clear the CE bit
810 * in the AFSR and return.
812 * This is just like __spiftire_access_error above, but it
813 * specifically handles correctable errors. If an
814 * uncorrectable error is indicated in the AFSR we
815 * will branch directly above to __spitfire_access_error
816 * to handle it instead. Uncorrectable therefore takes
817 * priority over correctable, and the error logging
818 * C code will notice this case by inspecting the
821 .globl __spitfire_cee_trap
823 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
825 sllx %g3, SFAFSR_UE_SHIFT, %g3
826 andcc %g4, %g3, %g0 ! Check for UE
827 bne,pn %xcc, __spitfire_access_error
830 /* Ok, in this case we only have a correctable error.
831 * Indicate we only wish to capture that state in register
832 * %g1, and we only disable CE error reporting unlike UE
833 * handling which disables all errors.
835 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
836 andn %g3, ESTATE_ERR_CE, %g3
837 stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
840 /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
841 ba,pt %xcc, __spitfire_cee_trap_continue
844 .globl __spitfire_data_access_exception
845 .globl __spitfire_data_access_exception_tl1
846 __spitfire_data_access_exception_tl1:
848 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
851 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
852 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
853 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
856 cmp %g3, 0x80 ! first win spill/fill trap
858 cmp %g3, 0xff ! last win spill/fill trap
861 ba,pt %xcc, winfix_dax
863 1: sethi %hi(109f), %g7
865 109: or %g7, %lo(109b), %g7
868 call spitfire_data_access_exception_tl1
869 add %sp, PTREGS_OFF, %o0
873 __spitfire_data_access_exception:
875 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
878 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
879 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
880 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
884 109: or %g7, %lo(109b), %g7
887 call spitfire_data_access_exception
888 add %sp, PTREGS_OFF, %o0
892 .globl __spitfire_insn_access_exception
893 .globl __spitfire_insn_access_exception_tl1
894 __spitfire_insn_access_exception_tl1:
896 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
898 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
899 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
900 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
904 109: or %g7, %lo(109b), %g7
907 call spitfire_insn_access_exception_tl1
908 add %sp, PTREGS_OFF, %o0
912 __spitfire_insn_access_exception:
914 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
916 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
917 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
918 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
922 109: or %g7, %lo(109b), %g7
925 call spitfire_insn_access_exception
926 add %sp, PTREGS_OFF, %o0
930 /* These get patched into the trap table at boot time
931 * once we know we have a cheetah processor.
933 .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
934 cheetah_fecc_trap_vector:
936 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
937 andn %g1, DCU_DC | DCU_IC, %g1
938 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
940 sethi %hi(cheetah_fast_ecc), %g2
941 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
943 cheetah_fecc_trap_vector_tl1:
945 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
946 andn %g1, DCU_DC | DCU_IC, %g1
947 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
949 sethi %hi(cheetah_fast_ecc), %g2
950 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
952 .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
953 cheetah_cee_trap_vector:
955 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
956 andn %g1, DCU_IC, %g1
957 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
959 sethi %hi(cheetah_cee), %g2
960 jmpl %g2 + %lo(cheetah_cee), %g0
962 cheetah_cee_trap_vector_tl1:
964 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
965 andn %g1, DCU_IC, %g1
966 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
968 sethi %hi(cheetah_cee), %g2
969 jmpl %g2 + %lo(cheetah_cee), %g0
971 .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
972 cheetah_deferred_trap_vector:
974 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
975 andn %g1, DCU_DC | DCU_IC, %g1;
976 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
978 sethi %hi(cheetah_deferred_trap), %g2
979 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
981 cheetah_deferred_trap_vector_tl1:
983 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
984 andn %g1, DCU_DC | DCU_IC, %g1;
985 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
987 sethi %hi(cheetah_deferred_trap), %g2
988 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
991 /* Cheetah+ specific traps. These are for the new I/D cache parity
992 * error traps. The first argument to cheetah_plus_parity_handler
993 * is encoded as follows:
995 * Bit0: 0=dcache,1=icache
996 * Bit1: 0=recoverable,1=unrecoverable
998 .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
999 cheetah_plus_dcpe_trap_vector:
1001 sethi %hi(do_cheetah_plus_data_parity), %g7
1002 jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
1009 do_cheetah_plus_data_parity:
1013 call cheetah_plus_parity_error
1014 add %sp, PTREGS_OFF, %o1
1018 cheetah_plus_dcpe_trap_vector_tl1:
1020 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
1021 sethi %hi(do_dcpe_tl1), %g3
1022 jmpl %g3 + %lo(do_dcpe_tl1), %g0
1028 .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
1029 cheetah_plus_icpe_trap_vector:
1031 sethi %hi(do_cheetah_plus_insn_parity), %g7
1032 jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
1039 do_cheetah_plus_insn_parity:
1043 call cheetah_plus_parity_error
1044 add %sp, PTREGS_OFF, %o1
1048 cheetah_plus_icpe_trap_vector_tl1:
1050 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
1051 sethi %hi(do_icpe_tl1), %g3
1052 jmpl %g3 + %lo(do_icpe_tl1), %g0
1058 /* If we take one of these traps when tl >= 1, then we
1059 * jump to interrupt globals. If some trap level above us
1060 * was also using interrupt globals, we cannot recover.
1061 * We may use all interrupt global registers except %g6.
1063 .globl do_dcpe_tl1, do_icpe_tl1
1065 rdpr %tl, %g1 ! Save original trap level
1066 mov 1, %g2 ! Setup TSTATE checking loop
1067 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
1068 1: wrpr %g2, %tl ! Set trap level to check
1069 rdpr %tstate, %g4 ! Read TSTATE for this level
1070 andcc %g4, %g3, %g0 ! Interrupt globals in use?
1071 bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
1072 wrpr %g1, %tl ! Restore original trap level
1073 add %g2, 1, %g2 ! Next trap level
1074 cmp %g2, %g1 ! Hit them all yet?
1075 ble,pt %icc, 1b ! Not yet
1077 wrpr %g1, %tl ! Restore original trap level
1078 do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
1079 /* Reset D-cache parity */
1080 sethi %hi(1 << 16), %g1 ! D-cache size
1081 mov (1 << 5), %g2 ! D-cache line size
1082 sub %g1, %g2, %g1 ! Move down 1 cacheline
1083 1: srl %g1, 14, %g3 ! Compute UTAG
1085 stxa %g3, [%g1] ASI_DCACHE_UTAG
1087 sub %g2, 8, %g3 ! 64-bit data word within line
1089 stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
1091 subcc %g3, 8, %g3 ! Next 64-bit data word
1094 subcc %g1, %g2, %g1 ! Next cacheline
1097 ba,pt %xcc, dcpe_icpe_tl1_common
1102 ba,pt %xcc, etraptl1
1103 1: or %g7, %lo(1b), %g7
1105 call cheetah_plus_parity_error
1106 add %sp, PTREGS_OFF, %o1
1111 rdpr %tl, %g1 ! Save original trap level
1112 mov 1, %g2 ! Setup TSTATE checking loop
1113 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
1114 1: wrpr %g2, %tl ! Set trap level to check
1115 rdpr %tstate, %g4 ! Read TSTATE for this level
1116 andcc %g4, %g3, %g0 ! Interrupt globals in use?
1117 bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
1118 wrpr %g1, %tl ! Restore original trap level
1119 add %g2, 1, %g2 ! Next trap level
1120 cmp %g2, %g1 ! Hit them all yet?
1121 ble,pt %icc, 1b ! Not yet
1123 wrpr %g1, %tl ! Restore original trap level
1124 do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
1126 sethi %hi(1 << 15), %g1 ! I-cache size
1127 mov (1 << 5), %g2 ! I-cache line size
1129 1: or %g1, (2 << 3), %g3
1130 stxa %g0, [%g3] ASI_IC_TAG
1135 ba,pt %xcc, dcpe_icpe_tl1_common
1140 ba,pt %xcc, etraptl1
1141 1: or %g7, %lo(1b), %g7
1143 call cheetah_plus_parity_error
1144 add %sp, PTREGS_OFF, %o1
1148 dcpe_icpe_tl1_common:
1149 /* Flush D-cache, re-enable D/I caches in DCU and finally
1150 * retry the trapping instruction.
1152 sethi %hi(1 << 16), %g1 ! D-cache size
1153 mov (1 << 5), %g2 ! D-cache line size
1155 1: stxa %g0, [%g1] ASI_DCACHE_TAG
1160 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
1161 or %g1, (DCU_DC | DCU_IC), %g1
1162 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
1166 /* Capture I/D/E-cache state into per-cpu error scoreboard.
1168 * %g1: (TL>=0) ? 1 : 0
1173 * %g6: current thread ptr
1176 __cheetah_log_error:
1177 /* Put "TL1" software bit into AFSR. */
1182 /* Get log entry pointer for this cpu at this trap level. */
1183 BRANCH_IF_JALAPENO(g2,g3,50f)
1184 ldxa [%g0] ASI_SAFARI_CONFIG, %g2
1189 50: ldxa [%g0] ASI_JBUS_CONFIG, %g2
1193 60: sllx %g2, 9, %g2
1194 sethi %hi(cheetah_error_log), %g3
1195 ldx [%g3 + %lo(cheetah_error_log)], %g3
1203 /* %g1 holds pointer to the top of the logging scoreboard */
1204 ldx [%g1 + 0x0], %g7
1209 stx %g4, [%g1 + 0x0]
1210 stx %g5, [%g1 + 0x8]
1213 /* %g1 now points to D-cache logging area */
1214 set 0x3ff8, %g2 /* DC_addr mask */
1215 and %g5, %g2, %g2 /* DC_addr bits of AFAR */
1217 or %g3, 1, %g3 /* PHYS tag + valid */
1219 10: ldxa [%g2] ASI_DCACHE_TAG, %g7
1220 cmp %g3, %g7 /* TAG match? */
1224 /* Yep, what we want, capture state. */
1225 stx %g2, [%g1 + 0x20]
1226 stx %g7, [%g1 + 0x28]
1228 /* A membar Sync is required before and after utag access. */
1230 ldxa [%g2] ASI_DCACHE_UTAG, %g7
1232 stx %g7, [%g1 + 0x30]
1233 ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
1234 stx %g7, [%g1 + 0x38]
1237 12: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
1239 add %g3, (1 << 5), %g3
1247 13: sethi %hi(1 << 14), %g7
1256 /* %g1 now points to I-cache logging area */
1257 20: set 0x1fe0, %g2 /* IC_addr mask */
1258 and %g5, %g2, %g2 /* IC_addr bits of AFAR */
1259 sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
1260 srlx %g5, (13 - 8), %g3 /* Make PTAG */
1261 andn %g3, 0xff, %g3 /* Mask off undefined bits */
1263 21: ldxa [%g2] ASI_IC_TAG, %g7
1269 /* Yep, what we want, capture state. */
1270 stx %g2, [%g1 + 0x40]
1271 stx %g7, [%g1 + 0x48]
1272 add %g2, (1 << 3), %g2
1273 ldxa [%g2] ASI_IC_TAG, %g7
1274 add %g2, (1 << 3), %g2
1275 stx %g7, [%g1 + 0x50]
1276 ldxa [%g2] ASI_IC_TAG, %g7
1277 add %g2, (1 << 3), %g2
1278 stx %g7, [%g1 + 0x60]
1279 ldxa [%g2] ASI_IC_TAG, %g7
1280 stx %g7, [%g1 + 0x68]
1281 sub %g2, (3 << 3), %g2
1282 ldxa [%g2] ASI_IC_STAG, %g7
1283 stx %g7, [%g1 + 0x58]
1287 22: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
1289 add %g3, (1 << 3), %g3
1297 23: sethi %hi(1 << 14), %g7
1306 /* %g1 now points to E-cache logging area */
1307 30: andn %g5, (32 - 1), %g2
1308 stx %g2, [%g1 + 0x20]
1309 ldxa [%g2] ASI_EC_TAG_DATA, %g7
1310 stx %g7, [%g1 + 0x28]
1311 ldxa [%g2] ASI_EC_R, %g0
1314 31: ldxa [%g3] ASI_EC_DATA, %g7
1315 stx %g7, [%g1 + %g3]
1328 ba,pt %xcc, c_deferred
1330 /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
1331 * in the trap table. That code has done a memory barrier
1332 * and has disabled both the I-cache and D-cache in the DCU
1333 * control register. The I-cache is disabled so that we may
1334 * capture the corrupted cache line, and the D-cache is disabled
1335 * because corrupt data may have been placed there and we don't
1336 * want to reference it.
1338 * %g1 is one if this trap occurred at %tl >= 1.
1340 * Next, we turn off error reporting so that we don't recurse.
1342 .globl cheetah_fast_ecc
1344 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1345 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1346 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1349 /* Fetch and clear AFSR/AFAR */
1350 ldxa [%g0] ASI_AFSR, %g4
1351 ldxa [%g0] ASI_AFAR, %g5
1352 stxa %g4, [%g0] ASI_AFSR
1355 ba,pt %xcc, __cheetah_log_error
1361 ba,pt %xcc, etrap_irq
1365 call cheetah_fecc_handler
1366 add %sp, PTREGS_OFF, %o0
1367 ba,a,pt %xcc, rtrap_irq
1369 /* Our caller has disabled I-cache and performed membar Sync. */
1372 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1373 andn %g2, ESTATE_ERROR_CEEN, %g2
1374 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1377 /* Fetch and clear AFSR/AFAR */
1378 ldxa [%g0] ASI_AFSR, %g4
1379 ldxa [%g0] ASI_AFAR, %g5
1380 stxa %g4, [%g0] ASI_AFSR
1383 ba,pt %xcc, __cheetah_log_error
1389 ba,pt %xcc, etrap_irq
1393 call cheetah_cee_handler
1394 add %sp, PTREGS_OFF, %o0
1395 ba,a,pt %xcc, rtrap_irq
1397 /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
1398 .globl cheetah_deferred_trap
1399 cheetah_deferred_trap:
1400 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1401 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1402 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1405 /* Fetch and clear AFSR/AFAR */
1406 ldxa [%g0] ASI_AFSR, %g4
1407 ldxa [%g0] ASI_AFAR, %g5
1408 stxa %g4, [%g0] ASI_AFSR
1411 ba,pt %xcc, __cheetah_log_error
1417 ba,pt %xcc, etrap_irq
1421 call cheetah_deferred_handler
1422 add %sp, PTREGS_OFF, %o0
1423 ba,a,pt %xcc, rtrap_irq
1428 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1430 sethi %hi(109f), %g7
1432 109: or %g7, %lo(109b), %g7
1434 add %sp, PTREGS_OFF, %o0
1443 /* Setup %g4/%g5 now as they are used in the
1448 ldxa [%g4] ASI_DMMU, %g4
1449 ldxa [%g3] ASI_DMMU, %g5
1450 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1452 bgu,pn %icc, winfix_mna
1455 1: sethi %hi(109f), %g7
1457 109: or %g7, %lo(109b), %g7
1460 call mem_address_unaligned
1461 add %sp, PTREGS_OFF, %o0
1467 sethi %hi(109f), %g7
1469 ldxa [%g4] ASI_DMMU, %g5
1470 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1473 ldxa [%g4] ASI_DMMU, %g4
1475 109: or %g7, %lo(109b), %g7
1479 add %sp, PTREGS_OFF, %o0
1485 sethi %hi(109f), %g7
1487 ldxa [%g4] ASI_DMMU, %g5
1488 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1491 ldxa [%g4] ASI_DMMU, %g4
1493 109: or %g7, %lo(109b), %g7
1497 add %sp, PTREGS_OFF, %o0
1501 .globl breakpoint_trap
1503 call sparc_breakpoint
1504 add %sp, PTREGS_OFF, %o0
1508 #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
1509 defined(CONFIG_SOLARIS_EMUL_MODULE)
1510 /* SunOS uses syscall zero as the 'indirect syscall' it looks
1511 * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
1512 * This is complete brain damage.
1518 cmp %o0, NR_SYSCALLS
1521 sethi %hi(sunos_nosys), %l6
1523 or %l6, %lo(sunos_nosys), %l6
1524 1: sethi %hi(sunos_sys_table), %l7
1525 or %l7, %lo(sunos_sys_table), %l7
1526 lduw [%l7 + %o0], %l6
1540 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1541 b,pt %xcc, ret_sys_call
1542 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1544 /* SunOS getuid() returns uid in %o0 and euid in %o1 */
1547 call sys32_geteuid16
1550 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1551 b,pt %xcc, ret_sys_call
1552 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1554 /* SunOS getgid() returns gid in %o0 and egid in %o1 */
1557 call sys32_getegid16
1560 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1561 b,pt %xcc, ret_sys_call
1562 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1565 /* SunOS's execv() call only specifies the argv argument, the
1566 * environment settings are the same as the calling processes.
1570 sethi %hi(sparc_execve), %g1
1571 ba,pt %xcc, execve_merge
1572 or %g1, %lo(sparc_execve), %g1
1573 #ifdef CONFIG_COMPAT
1576 stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
1579 sethi %hi(sparc32_execve), %g1
1580 or %g1, %lo(sparc32_execve), %g1
1585 add %sp, PTREGS_OFF, %o0
1587 .globl sys_pipe, sys_sigpause, sys_nis_syscall
1588 .globl sys_sigsuspend, sys_rt_sigsuspend
1589 .globl sys_rt_sigreturn
1591 .globl sys_sigaltstack
1593 sys_pipe: ba,pt %xcc, sparc_pipe
1594 add %sp, PTREGS_OFF, %o0
1595 sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
1596 add %sp, PTREGS_OFF, %o0
1597 sys_memory_ordering:
1598 ba,pt %xcc, sparc_memory_ordering
1599 add %sp, PTREGS_OFF, %o1
1600 sys_sigaltstack:ba,pt %xcc, do_sigaltstack
1601 add %i6, STACK_BIAS, %o2
1602 #ifdef CONFIG_COMPAT
1603 .globl sys32_sigstack
1604 sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
1606 .globl sys32_sigaltstack
1608 ba,pt %xcc, do_sys32_sigaltstack
1612 sys_sigsuspend: add %sp, PTREGS_OFF, %o0
1614 add %o7, 1f-.-4, %o7
1616 sys_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
1617 add %sp, PTREGS_OFF, %o2
1618 call do_rt_sigsuspend
1619 add %o7, 1f-.-4, %o7
1621 #ifdef CONFIG_COMPAT
1622 .globl sys32_rt_sigsuspend
1623 sys32_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
1625 add %sp, PTREGS_OFF, %o2
1626 call do_rt_sigsuspend32
1627 add %o7, 1f-.-4, %o7
1629 /* NOTE: %o0 has a correct value already */
1630 sys_sigpause: add %sp, PTREGS_OFF, %o1
1632 add %o7, 1f-.-4, %o7
1634 #ifdef CONFIG_COMPAT
1635 .globl sys32_sigreturn
1637 add %sp, PTREGS_OFF, %o0
1639 add %o7, 1f-.-4, %o7
1643 add %sp, PTREGS_OFF, %o0
1644 call do_rt_sigreturn
1645 add %o7, 1f-.-4, %o7
1647 #ifdef CONFIG_COMPAT
1648 .globl sys32_rt_sigreturn
1650 add %sp, PTREGS_OFF, %o0
1651 call do_rt_sigreturn32
1652 add %o7, 1f-.-4, %o7
1655 sys_ptrace: add %sp, PTREGS_OFF, %o0
1657 add %o7, 1f-.-4, %o7
1660 1: ldx [%curptr + TI_FLAGS], %l5
1661 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1664 add %sp, PTREGS_OFF, %o0
1671 /* This is how fork() was meant to be done, 8 instruction entry.
1673 * I questioned the following code briefly, let me clear things
1674 * up so you must not reason on it like I did.
1676 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
1677 * need it here because the only piece of window state we copy to
1678 * the child is the CWP register. Even if the parent sleeps,
1679 * we are safe because we stuck it into pt_regs of the parent
1680 * so it will not change.
1682 * XXX This raises the question, whether we can do the same on
1683 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
1684 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
1685 * XXX fork_kwim in UREG_G1 (global registers are considered
1686 * XXX volatile across a system call in the sparc ABI I think
1687 * XXX if it isn't we can use regs->y instead, anyone who depends
1688 * XXX upon the Y register being preserved across a fork deserves
1691 * In fact we should take advantage of that fact for other things
1692 * during system calls...
1694 .globl sys_fork, sys_vfork, sys_clone, sparc_exit
1695 .globl ret_from_syscall
1697 sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
1698 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
1699 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
1700 ba,pt %xcc, sys_clone
1706 ba,pt %xcc, sparc_do_fork
1707 add %sp, PTREGS_OFF, %o2
1709 /* Clear current_thread_info()->new_child, and
1710 * check performance counter stuff too.
1712 stb %g0, [%g6 + TI_NEW_CHILD]
1713 ldx [%g6 + TI_FLAGS], %l0
1716 andcc %l0, _TIF_PERFCTR, %g0
1719 ldx [%g6 + TI_PCR], %o7
1722 /* Blackbird errata workaround. See commentary in
1723 * smp.c:smp_percpu_timer_interrupt() for more
1729 99: wr %g0, %g0, %pic
1732 1: b,pt %xcc, ret_sys_call
1733 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
1734 sparc_exit: wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV), %pstate
1738 wrpr %g3, 0x0, %cansave
1739 wrpr %g0, 0x0, %otherwin
1740 wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV | PSTATE_IE), %pstate
1741 ba,pt %xcc, sys_exit
1742 stb %g0, [%g6 + TI_WSAVED]
1744 linux_sparc_ni_syscall:
1745 sethi %hi(sys_ni_syscall), %l7
1747 or %l7, %lo(sys_ni_syscall), %l7
1749 linux_syscall_trace32:
1750 add %sp, PTREGS_OFF, %o0
1760 linux_syscall_trace:
1761 add %sp, PTREGS_OFF, %o0
1772 /* Linux 32-bit and SunOS system calls enter here... */
1774 .globl linux_sparc_syscall32
1775 linux_sparc_syscall32:
1776 /* Direct access to user regs, much faster. */
1777 cmp %g1, NR_SYSCALLS ! IEU1 Group
1778 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1779 srl %i0, 0, %o0 ! IEU0
1780 sll %g1, 2, %l4 ! IEU0 Group
1781 srl %i4, 0, %o4 ! IEU1
1782 lduw [%l7 + %l4], %l7 ! Load
1783 srl %i1, 0, %o1 ! IEU0 Group
1784 ldx [%curptr + TI_FLAGS], %l0 ! Load
1786 srl %i5, 0, %o5 ! IEU1
1787 srl %i2, 0, %o2 ! IEU0 Group
1788 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1789 bne,pn %icc, linux_syscall_trace32 ! CTI
1791 call %l7 ! CTI Group brk forced
1792 srl %i3, 0, %o3 ! IEU0
1795 /* Linux native and SunOS system calls enter here... */
1797 .globl linux_sparc_syscall, ret_sys_call
1798 linux_sparc_syscall:
1799 /* Direct access to user regs, much faster. */
1800 cmp %g1, NR_SYSCALLS ! IEU1 Group
1801 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1803 sll %g1, 2, %l4 ! IEU0 Group
1805 lduw [%l7 + %l4], %l7 ! Load
1806 4: mov %i2, %o2 ! IEU0 Group
1807 ldx [%curptr + TI_FLAGS], %l0 ! Load
1810 mov %i4, %o4 ! IEU0 Group
1811 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1812 bne,pn %icc, linux_syscall_trace ! CTI Group
1814 2: call %l7 ! CTI Group brk forced
1818 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1820 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
1821 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
1823 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
1826 /* Check if force_successful_syscall_return()
1829 ldub [%curptr + TI_SYS_NOERROR], %l0
1833 stb %g0, [%curptr + TI_SYS_NOERROR]
1836 cmp %o0, -ERESTART_RESTARTBLOCK
1838 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
1840 /* System call success, clear Carry condition code. */
1842 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1843 bne,pn %icc, linux_syscall_trace2
1844 add %l1, 0x4, %l2 ! npc = npc+4
1845 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1846 ba,pt %xcc, rtrap_clr_l6
1847 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1850 /* System call failure, set Carry condition code.
1851 * Also, get abs(errno) to return to the process.
1853 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
1856 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1858 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1859 bne,pn %icc, linux_syscall_trace2
1860 add %l1, 0x4, %l2 ! npc = npc+4
1861 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1864 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1865 linux_syscall_trace2:
1866 add %sp, PTREGS_OFF, %o0
1869 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1871 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1874 .globl __flushw_user
1879 1: save %sp, -128, %sp
1885 restore %g0, %g0, %g0