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/errno.h>
15 #include <asm/ptrace.h>
17 #include <asm/signal.h>
18 #include <asm/pgtable.h>
19 #include <asm/processor.h>
20 #include <asm/visasm.h>
21 #include <asm/estate.h>
22 #include <asm/auxio.h>
23 #include <asm/sfafsr.h>
25 #include <asm/unistd.h>
32 /* This is trivial with the new code... */
35 sethi %hi(TSTATE_PEF), %g4
41 andcc %g5, FPRS_FEF, %g0
45 /* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
48 109: or %g7, %lo(109b), %g7
50 ba,a,pt %xcc, rtrap_clr_l6
52 1: TRAP_LOAD_THREAD_REG(%g6, %g1)
53 ldub [%g6 + TI_FPSAVED], %g5
54 wr %g0, FPRS_FEF, %fprs
55 andcc %g5, FPRS_FEF, %g0
58 ldx [%g6 + TI_GSR], %g7
59 1: andcc %g5, FPRS_DL, %g0
62 andcc %g5, FPRS_DU, %g0
93 b,pt %xcc, fpdis_exit2
95 1: mov SECONDARY_CONTEXT, %g3
96 add %g6, TI_FPREGS + 0x80, %g1
100 661: ldxa [%g3] ASI_DMMU, %g5
101 .section .sun4v_1insn_patch, "ax"
103 ldxa [%g3] ASI_MMU, %g5
106 sethi %hi(sparc64_kern_sec_context), %g2
107 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
109 661: stxa %g2, [%g3] ASI_DMMU
110 .section .sun4v_1insn_patch, "ax"
112 stxa %g2, [%g3] ASI_MMU
116 add %g6, TI_FPREGS + 0xc0, %g2
120 ldda [%g1] ASI_BLK_S, %f32
121 ldda [%g2] ASI_BLK_S, %f48
133 b,pt %xcc, fpdis_exit
135 2: andcc %g5, FPRS_DU, %g0
138 mov SECONDARY_CONTEXT, %g3
141 661: ldxa [%g3] ASI_DMMU, %g5
142 .section .sun4v_1insn_patch, "ax"
144 ldxa [%g3] ASI_MMU, %g5
147 add %g6, TI_FPREGS, %g1
148 sethi %hi(sparc64_kern_sec_context), %g2
149 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
151 661: stxa %g2, [%g3] ASI_DMMU
152 .section .sun4v_1insn_patch, "ax"
154 stxa %g2, [%g3] ASI_MMU
158 add %g6, TI_FPREGS + 0x40, %g2
159 faddd %f32, %f34, %f36
160 fmuld %f32, %f34, %f38
162 ldda [%g1] ASI_BLK_S, %f0
163 ldda [%g2] ASI_BLK_S, %f16
165 faddd %f32, %f34, %f40
166 fmuld %f32, %f34, %f42
167 faddd %f32, %f34, %f44
168 fmuld %f32, %f34, %f46
169 faddd %f32, %f34, %f48
170 fmuld %f32, %f34, %f50
171 faddd %f32, %f34, %f52
172 fmuld %f32, %f34, %f54
173 faddd %f32, %f34, %f56
174 fmuld %f32, %f34, %f58
175 faddd %f32, %f34, %f60
176 fmuld %f32, %f34, %f62
177 ba,pt %xcc, fpdis_exit
179 3: mov SECONDARY_CONTEXT, %g3
180 add %g6, TI_FPREGS, %g1
182 661: ldxa [%g3] ASI_DMMU, %g5
183 .section .sun4v_1insn_patch, "ax"
185 ldxa [%g3] ASI_MMU, %g5
188 sethi %hi(sparc64_kern_sec_context), %g2
189 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
191 661: stxa %g2, [%g3] ASI_DMMU
192 .section .sun4v_1insn_patch, "ax"
194 stxa %g2, [%g3] ASI_MMU
200 ldda [%g1] ASI_BLK_S, %f0
201 ldda [%g1 + %g2] ASI_BLK_S, %f16
203 ldda [%g1] ASI_BLK_S, %f32
204 ldda [%g1 + %g2] ASI_BLK_S, %f48
208 661: stxa %g5, [%g3] ASI_DMMU
209 .section .sun4v_1insn_patch, "ax"
211 stxa %g5, [%g3] ASI_MMU
217 ldx [%g6 + TI_XFSR], %fsr
219 or %g3, %g4, %g3 ! anal...
221 wr %g0, FPRS_FEF, %fprs ! clean DU/DL bits
227 add %sp, PTREGS_OFF, %o0
231 .globl do_fpother_check_fitos
233 do_fpother_check_fitos:
234 TRAP_LOAD_THREAD_REG(%g6, %g1)
235 sethi %hi(fp_other_bounce - 4), %g7
236 or %g7, %lo(fp_other_bounce - 4), %g7
238 /* NOTE: Need to preserve %g7 until we fully commit
239 * to the fitos fixup.
241 stx %fsr, [%g6 + TI_XFSR]
243 andcc %g3, TSTATE_PRIV, %g0
244 bne,pn %xcc, do_fptrap_after_fsr
246 ldx [%g6 + TI_XFSR], %g3
249 cmp %g1, 2 ! Unfinished FP-OP
250 bne,pn %xcc, do_fptrap_after_fsr
251 sethi %hi(1 << 23), %g1 ! Inexact
253 bne,pn %xcc, do_fptrap_after_fsr
255 lduwa [%g1] ASI_AIUP, %g3 ! This cannot ever fail
256 #define FITOS_MASK 0xc1f83fe0
257 #define FITOS_COMPARE 0x81a01880
258 sethi %hi(FITOS_MASK), %g1
259 or %g1, %lo(FITOS_MASK), %g1
261 sethi %hi(FITOS_COMPARE), %g2
262 or %g2, %lo(FITOS_COMPARE), %g2
264 bne,pn %xcc, do_fptrap_after_fsr
266 std %f62, [%g6 + TI_FPREGS + (62 * 4)]
267 sethi %hi(fitos_table_1), %g1
269 or %g1, %lo(fitos_table_1), %g1
272 ba,pt %xcc, fitos_emul_continue
309 sethi %hi(fitos_table_2), %g1
311 or %g1, %lo(fitos_table_2), %g1
315 ba,pt %xcc, fitos_emul_fini
352 ldd [%g6 + TI_FPREGS + (62 * 4)], %f62
358 TRAP_LOAD_THREAD_REG(%g6, %g1)
359 stx %fsr, [%g6 + TI_XFSR]
361 ldub [%g6 + TI_FPSAVED], %g3
364 stb %g3, [%g6 + TI_FPSAVED]
366 stx %g3, [%g6 + TI_GSR]
367 mov SECONDARY_CONTEXT, %g3
369 661: ldxa [%g3] ASI_DMMU, %g5
370 .section .sun4v_1insn_patch, "ax"
372 ldxa [%g3] ASI_MMU, %g5
375 sethi %hi(sparc64_kern_sec_context), %g2
376 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
378 661: stxa %g2, [%g3] ASI_DMMU
379 .section .sun4v_1insn_patch, "ax"
381 stxa %g2, [%g3] ASI_MMU
385 add %g6, TI_FPREGS, %g2
386 andcc %g1, FPRS_DL, %g0
389 stda %f0, [%g2] ASI_BLK_S
390 stda %f16, [%g2 + %g3] ASI_BLK_S
391 andcc %g1, FPRS_DU, %g0
394 stda %f32, [%g2] ASI_BLK_S
395 stda %f48, [%g2 + %g3] ASI_BLK_S
396 5: mov SECONDARY_CONTEXT, %g1
399 661: stxa %g5, [%g1] ASI_DMMU
400 .section .sun4v_1insn_patch, "ax"
402 stxa %g5, [%g1] ASI_MMU
409 /* The registers for cross calls will be:
411 * DATA 0: [low 32-bits] Address of function to call, jmp to this
412 * [high 32-bits] MMU Context Argument 0, place in %g5
413 * DATA 1: Address Argument 1, place in %g1
414 * DATA 2: Address Argument 2, place in %g7
416 * With this method we can do most of the cross-call tlb/cache
417 * flushing very quickly.
424 ldxa [%g3 + %g0] ASI_INTR_R, %g3
425 sethi %hi(KERNBASE), %g4
427 bgeu,pn %xcc, do_ivec_xcall
429 stxa %g0, [%g0] ASI_INTR_RECEIVE
432 sethi %hi(ivector_table), %g2
434 or %g2, %lo(ivector_table), %g2
437 TRAP_LOAD_IRQ_WORK(%g6, %g1)
439 lduw [%g6], %g5 /* g5 = irq_work(cpu) */
440 stw %g5, [%g3 + 0x00] /* bucket->irq_chain = g5 */
441 stw %g3, [%g6] /* irq_work(cpu) = bucket */
442 wr %g0, 1 << PIL_DEVICE_IRQ, %set_softint
446 ldxa [%g1 + %g0] ASI_INTR_R, %g1
450 ldxa [%g7 + %g0] ASI_INTR_R, %g7
451 stxa %g0, [%g0] ASI_INTR_RECEIVE
462 ldx [%o0 + PT_V9_TSTATE], %o1
466 stx %o1, [%o0 + PT_V9_G1]
468 ldx [%o0 + PT_V9_TSTATE], %o1
469 ldx [%o0 + PT_V9_G1], %o2
470 or %g0, %ulo(TSTATE_ICC), %o3
477 stx %o1, [%o0 + PT_V9_TSTATE]
480 utrap_trap: /* %g3=handler,%g4=level */
481 TRAP_LOAD_THREAD_REG(%g6, %g1)
482 ldx [%g6 + TI_UTRAPS], %g1
483 brnz,pt %g1, invoke_utrap
490 add %sp, PTREGS_OFF, %o0
500 andn %l6, TSTATE_CWP, %l6
501 wrpr %l6, %l7, %tstate
507 /* We need to carefully read the error status, ACK
508 * the errors, prevent recursive traps, and pass the
509 * information on to C code for logging.
511 * We pass the AFAR in as-is, and we encode the status
512 * information as described in asm-sparc64/sfafsr.h
514 .globl __spitfire_access_error
515 __spitfire_access_error:
516 /* Disable ESTATE error reporting so that we do not
517 * take recursive traps and RED state the processor.
519 stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
523 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
525 /* __spitfire_cee_trap branches here with AFSR in %g4 and
526 * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the
527 * ESTATE Error Enable register.
529 __spitfire_cee_trap_continue:
530 ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
533 and %g3, 0x1ff, %g3 ! Paranoia
534 sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
540 sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
544 /* Read in the UDB error register state, clearing the
545 * sticky error bits as-needed. We only clear them if
546 * the UE bit is set. Likewise, __spitfire_cee_trap
547 * below will only do so if the CE bit is set.
549 * NOTE: UltraSparc-I/II have high and low UDB error
550 * registers, corresponding to the two UDB units
551 * present on those chips. UltraSparc-IIi only
552 * has a single UDB, called "SDB" in the manual.
553 * For IIi the upper UDB register always reads
554 * as zero so for our purposes things will just
555 * work with the checks below.
557 1: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
558 and %g3, 0x3ff, %g7 ! Paranoia
559 sllx %g7, SFSTAT_UDBH_SHIFT, %g7
561 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
564 stxa %g3, [%g0] ASI_UDB_ERROR_W
568 ldxa [%g3] ASI_UDBL_ERROR_R, %g3
569 and %g3, 0x3ff, %g7 ! Paranoia
570 sllx %g7, SFSTAT_UDBL_SHIFT, %g7
572 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
576 stxa %g3, [%g7] ASI_UDB_ERROR_W
579 1: /* Ok, now that we've latched the error state,
580 * clear the sticky bits in the AFSR.
582 stxa %g4, [%g0] ASI_AFSR
597 1: ba,pt %xcc, etrap_irq
602 call spitfire_access_error
603 add %sp, PTREGS_OFF, %o0
607 /* This is the trap handler entry point for ECC correctable
608 * errors. They are corrected, but we listen for the trap
609 * so that the event can be logged.
611 * Disrupting errors are either:
612 * 1) single-bit ECC errors during UDB reads to system
614 * 2) data parity errors during write-back events
616 * As far as I can make out from the manual, the CEE trap
617 * is only for correctable errors during memory read
618 * accesses by the front-end of the processor.
620 * The code below is only for trap level 1 CEE events,
621 * as it is the only situation where we can safely record
622 * and log. For trap level >1 we just clear the CE bit
623 * in the AFSR and return.
625 * This is just like __spiftire_access_error above, but it
626 * specifically handles correctable errors. If an
627 * uncorrectable error is indicated in the AFSR we
628 * will branch directly above to __spitfire_access_error
629 * to handle it instead. Uncorrectable therefore takes
630 * priority over correctable, and the error logging
631 * C code will notice this case by inspecting the
634 .globl __spitfire_cee_trap
636 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
638 sllx %g3, SFAFSR_UE_SHIFT, %g3
639 andcc %g4, %g3, %g0 ! Check for UE
640 bne,pn %xcc, __spitfire_access_error
643 /* Ok, in this case we only have a correctable error.
644 * Indicate we only wish to capture that state in register
645 * %g1, and we only disable CE error reporting unlike UE
646 * handling which disables all errors.
648 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
649 andn %g3, ESTATE_ERR_CE, %g3
650 stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
653 /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
654 ba,pt %xcc, __spitfire_cee_trap_continue
657 .globl __spitfire_data_access_exception
658 .globl __spitfire_data_access_exception_tl1
659 __spitfire_data_access_exception_tl1:
661 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
664 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
665 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
666 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
669 cmp %g3, 0x80 ! first win spill/fill trap
671 cmp %g3, 0xff ! last win spill/fill trap
674 ba,pt %xcc, winfix_dax
676 1: sethi %hi(109f), %g7
678 109: or %g7, %lo(109b), %g7
681 call spitfire_data_access_exception_tl1
682 add %sp, PTREGS_OFF, %o0
686 __spitfire_data_access_exception:
688 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
691 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
692 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
693 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
697 109: or %g7, %lo(109b), %g7
700 call spitfire_data_access_exception
701 add %sp, PTREGS_OFF, %o0
705 .globl __spitfire_insn_access_exception
706 .globl __spitfire_insn_access_exception_tl1
707 __spitfire_insn_access_exception_tl1:
709 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
711 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
712 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
713 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
717 109: or %g7, %lo(109b), %g7
720 call spitfire_insn_access_exception_tl1
721 add %sp, PTREGS_OFF, %o0
725 __spitfire_insn_access_exception:
727 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
729 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
730 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
731 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
735 109: or %g7, %lo(109b), %g7
738 call spitfire_insn_access_exception
739 add %sp, PTREGS_OFF, %o0
743 /* These get patched into the trap table at boot time
744 * once we know we have a cheetah processor.
746 .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
747 cheetah_fecc_trap_vector:
749 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
750 andn %g1, DCU_DC | DCU_IC, %g1
751 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
753 sethi %hi(cheetah_fast_ecc), %g2
754 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
756 cheetah_fecc_trap_vector_tl1:
758 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
759 andn %g1, DCU_DC | DCU_IC, %g1
760 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
762 sethi %hi(cheetah_fast_ecc), %g2
763 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
765 .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
766 cheetah_cee_trap_vector:
768 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
769 andn %g1, DCU_IC, %g1
770 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
772 sethi %hi(cheetah_cee), %g2
773 jmpl %g2 + %lo(cheetah_cee), %g0
775 cheetah_cee_trap_vector_tl1:
777 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
778 andn %g1, DCU_IC, %g1
779 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
781 sethi %hi(cheetah_cee), %g2
782 jmpl %g2 + %lo(cheetah_cee), %g0
784 .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
785 cheetah_deferred_trap_vector:
787 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
788 andn %g1, DCU_DC | DCU_IC, %g1;
789 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
791 sethi %hi(cheetah_deferred_trap), %g2
792 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
794 cheetah_deferred_trap_vector_tl1:
796 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
797 andn %g1, DCU_DC | DCU_IC, %g1;
798 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
800 sethi %hi(cheetah_deferred_trap), %g2
801 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
804 /* Cheetah+ specific traps. These are for the new I/D cache parity
805 * error traps. The first argument to cheetah_plus_parity_handler
806 * is encoded as follows:
808 * Bit0: 0=dcache,1=icache
809 * Bit1: 0=recoverable,1=unrecoverable
811 .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
812 cheetah_plus_dcpe_trap_vector:
814 sethi %hi(do_cheetah_plus_data_parity), %g7
815 jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
822 do_cheetah_plus_data_parity:
825 ba,pt %xcc, etrap_irq
828 call cheetah_plus_parity_error
829 add %sp, PTREGS_OFF, %o1
830 ba,a,pt %xcc, rtrap_irq
832 cheetah_plus_dcpe_trap_vector_tl1:
834 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
835 sethi %hi(do_dcpe_tl1), %g3
836 jmpl %g3 + %lo(do_dcpe_tl1), %g0
842 .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
843 cheetah_plus_icpe_trap_vector:
845 sethi %hi(do_cheetah_plus_insn_parity), %g7
846 jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
853 do_cheetah_plus_insn_parity:
856 ba,pt %xcc, etrap_irq
859 call cheetah_plus_parity_error
860 add %sp, PTREGS_OFF, %o1
861 ba,a,pt %xcc, rtrap_irq
863 cheetah_plus_icpe_trap_vector_tl1:
865 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
866 sethi %hi(do_icpe_tl1), %g3
867 jmpl %g3 + %lo(do_icpe_tl1), %g0
873 /* If we take one of these traps when tl >= 1, then we
874 * jump to interrupt globals. If some trap level above us
875 * was also using interrupt globals, we cannot recover.
876 * We may use all interrupt global registers except %g6.
878 .globl do_dcpe_tl1, do_icpe_tl1
880 rdpr %tl, %g1 ! Save original trap level
881 mov 1, %g2 ! Setup TSTATE checking loop
882 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
883 1: wrpr %g2, %tl ! Set trap level to check
884 rdpr %tstate, %g4 ! Read TSTATE for this level
885 andcc %g4, %g3, %g0 ! Interrupt globals in use?
886 bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
887 wrpr %g1, %tl ! Restore original trap level
888 add %g2, 1, %g2 ! Next trap level
889 cmp %g2, %g1 ! Hit them all yet?
890 ble,pt %icc, 1b ! Not yet
892 wrpr %g1, %tl ! Restore original trap level
893 do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
894 sethi %hi(dcache_parity_tl1_occurred), %g2
895 lduw [%g2 + %lo(dcache_parity_tl1_occurred)], %g1
897 stw %g1, [%g2 + %lo(dcache_parity_tl1_occurred)]
898 /* Reset D-cache parity */
899 sethi %hi(1 << 16), %g1 ! D-cache size
900 mov (1 << 5), %g2 ! D-cache line size
901 sub %g1, %g2, %g1 ! Move down 1 cacheline
902 1: srl %g1, 14, %g3 ! Compute UTAG
904 stxa %g3, [%g1] ASI_DCACHE_UTAG
906 sub %g2, 8, %g3 ! 64-bit data word within line
908 stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
910 subcc %g3, 8, %g3 ! Next 64-bit data word
913 subcc %g1, %g2, %g1 ! Next cacheline
916 ba,pt %xcc, dcpe_icpe_tl1_common
922 1: or %g7, %lo(1b), %g7
924 call cheetah_plus_parity_error
925 add %sp, PTREGS_OFF, %o1
930 rdpr %tl, %g1 ! Save original trap level
931 mov 1, %g2 ! Setup TSTATE checking loop
932 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
933 1: wrpr %g2, %tl ! Set trap level to check
934 rdpr %tstate, %g4 ! Read TSTATE for this level
935 andcc %g4, %g3, %g0 ! Interrupt globals in use?
936 bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
937 wrpr %g1, %tl ! Restore original trap level
938 add %g2, 1, %g2 ! Next trap level
939 cmp %g2, %g1 ! Hit them all yet?
940 ble,pt %icc, 1b ! Not yet
942 wrpr %g1, %tl ! Restore original trap level
943 do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
944 sethi %hi(icache_parity_tl1_occurred), %g2
945 lduw [%g2 + %lo(icache_parity_tl1_occurred)], %g1
947 stw %g1, [%g2 + %lo(icache_parity_tl1_occurred)]
949 sethi %hi(1 << 15), %g1 ! I-cache size
950 mov (1 << 5), %g2 ! I-cache line size
952 1: or %g1, (2 << 3), %g3
953 stxa %g0, [%g3] ASI_IC_TAG
958 ba,pt %xcc, dcpe_icpe_tl1_common
964 1: or %g7, %lo(1b), %g7
966 call cheetah_plus_parity_error
967 add %sp, PTREGS_OFF, %o1
971 dcpe_icpe_tl1_common:
972 /* Flush D-cache, re-enable D/I caches in DCU and finally
973 * retry the trapping instruction.
975 sethi %hi(1 << 16), %g1 ! D-cache size
976 mov (1 << 5), %g2 ! D-cache line size
978 1: stxa %g0, [%g1] ASI_DCACHE_TAG
983 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
984 or %g1, (DCU_DC | DCU_IC), %g1
985 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
989 /* Capture I/D/E-cache state into per-cpu error scoreboard.
991 * %g1: (TL>=0) ? 1 : 0
996 * %g6: unused, will have current thread ptr after etrap
1000 /* Put "TL1" software bit into AFSR. */
1005 /* Get log entry pointer for this cpu at this trap level. */
1006 BRANCH_IF_JALAPENO(g2,g3,50f)
1007 ldxa [%g0] ASI_SAFARI_CONFIG, %g2
1012 50: ldxa [%g0] ASI_JBUS_CONFIG, %g2
1016 60: sllx %g2, 9, %g2
1017 sethi %hi(cheetah_error_log), %g3
1018 ldx [%g3 + %lo(cheetah_error_log)], %g3
1026 /* %g1 holds pointer to the top of the logging scoreboard */
1027 ldx [%g1 + 0x0], %g7
1032 stx %g4, [%g1 + 0x0]
1033 stx %g5, [%g1 + 0x8]
1036 /* %g1 now points to D-cache logging area */
1037 set 0x3ff8, %g2 /* DC_addr mask */
1038 and %g5, %g2, %g2 /* DC_addr bits of AFAR */
1040 or %g3, 1, %g3 /* PHYS tag + valid */
1042 10: ldxa [%g2] ASI_DCACHE_TAG, %g7
1043 cmp %g3, %g7 /* TAG match? */
1047 /* Yep, what we want, capture state. */
1048 stx %g2, [%g1 + 0x20]
1049 stx %g7, [%g1 + 0x28]
1051 /* A membar Sync is required before and after utag access. */
1053 ldxa [%g2] ASI_DCACHE_UTAG, %g7
1055 stx %g7, [%g1 + 0x30]
1056 ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
1057 stx %g7, [%g1 + 0x38]
1060 12: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
1062 add %g3, (1 << 5), %g3
1070 13: sethi %hi(1 << 14), %g7
1079 /* %g1 now points to I-cache logging area */
1080 20: set 0x1fe0, %g2 /* IC_addr mask */
1081 and %g5, %g2, %g2 /* IC_addr bits of AFAR */
1082 sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
1083 srlx %g5, (13 - 8), %g3 /* Make PTAG */
1084 andn %g3, 0xff, %g3 /* Mask off undefined bits */
1086 21: ldxa [%g2] ASI_IC_TAG, %g7
1092 /* Yep, what we want, capture state. */
1093 stx %g2, [%g1 + 0x40]
1094 stx %g7, [%g1 + 0x48]
1095 add %g2, (1 << 3), %g2
1096 ldxa [%g2] ASI_IC_TAG, %g7
1097 add %g2, (1 << 3), %g2
1098 stx %g7, [%g1 + 0x50]
1099 ldxa [%g2] ASI_IC_TAG, %g7
1100 add %g2, (1 << 3), %g2
1101 stx %g7, [%g1 + 0x60]
1102 ldxa [%g2] ASI_IC_TAG, %g7
1103 stx %g7, [%g1 + 0x68]
1104 sub %g2, (3 << 3), %g2
1105 ldxa [%g2] ASI_IC_STAG, %g7
1106 stx %g7, [%g1 + 0x58]
1110 22: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
1112 add %g3, (1 << 3), %g3
1120 23: sethi %hi(1 << 14), %g7
1129 /* %g1 now points to E-cache logging area */
1130 30: andn %g5, (32 - 1), %g2
1131 stx %g2, [%g1 + 0x20]
1132 ldxa [%g2] ASI_EC_TAG_DATA, %g7
1133 stx %g7, [%g1 + 0x28]
1134 ldxa [%g2] ASI_EC_R, %g0
1137 31: ldxa [%g3] ASI_EC_DATA, %g7
1138 stx %g7, [%g1 + %g3]
1151 ba,pt %xcc, c_deferred
1153 /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
1154 * in the trap table. That code has done a memory barrier
1155 * and has disabled both the I-cache and D-cache in the DCU
1156 * control register. The I-cache is disabled so that we may
1157 * capture the corrupted cache line, and the D-cache is disabled
1158 * because corrupt data may have been placed there and we don't
1159 * want to reference it.
1161 * %g1 is one if this trap occurred at %tl >= 1.
1163 * Next, we turn off error reporting so that we don't recurse.
1165 .globl cheetah_fast_ecc
1167 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1168 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1169 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1172 /* Fetch and clear AFSR/AFAR */
1173 ldxa [%g0] ASI_AFSR, %g4
1174 ldxa [%g0] ASI_AFAR, %g5
1175 stxa %g4, [%g0] ASI_AFSR
1178 ba,pt %xcc, __cheetah_log_error
1184 ba,pt %xcc, etrap_irq
1188 call cheetah_fecc_handler
1189 add %sp, PTREGS_OFF, %o0
1190 ba,a,pt %xcc, rtrap_irq
1192 /* Our caller has disabled I-cache and performed membar Sync. */
1195 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1196 andn %g2, ESTATE_ERROR_CEEN, %g2
1197 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1200 /* Fetch and clear AFSR/AFAR */
1201 ldxa [%g0] ASI_AFSR, %g4
1202 ldxa [%g0] ASI_AFAR, %g5
1203 stxa %g4, [%g0] ASI_AFSR
1206 ba,pt %xcc, __cheetah_log_error
1212 ba,pt %xcc, etrap_irq
1216 call cheetah_cee_handler
1217 add %sp, PTREGS_OFF, %o0
1218 ba,a,pt %xcc, rtrap_irq
1220 /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
1221 .globl cheetah_deferred_trap
1222 cheetah_deferred_trap:
1223 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1224 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1225 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1228 /* Fetch and clear AFSR/AFAR */
1229 ldxa [%g0] ASI_AFSR, %g4
1230 ldxa [%g0] ASI_AFAR, %g5
1231 stxa %g4, [%g0] ASI_AFSR
1234 ba,pt %xcc, __cheetah_log_error
1240 ba,pt %xcc, etrap_irq
1244 call cheetah_deferred_handler
1245 add %sp, PTREGS_OFF, %o0
1246 ba,a,pt %xcc, rtrap_irq
1251 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1253 sethi %hi(109f), %g7
1255 109: or %g7, %lo(109b), %g7
1257 add %sp, PTREGS_OFF, %o0
1266 /* Setup %g4/%g5 now as they are used in the
1271 ldxa [%g4] ASI_DMMU, %g4
1272 ldxa [%g3] ASI_DMMU, %g5
1273 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1275 bgu,pn %icc, winfix_mna
1278 1: sethi %hi(109f), %g7
1280 109: or %g7, %lo(109b), %g7
1283 call mem_address_unaligned
1284 add %sp, PTREGS_OFF, %o0
1290 sethi %hi(109f), %g7
1292 ldxa [%g4] ASI_DMMU, %g5
1293 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1296 ldxa [%g4] ASI_DMMU, %g4
1298 109: or %g7, %lo(109b), %g7
1302 add %sp, PTREGS_OFF, %o0
1308 sethi %hi(109f), %g7
1310 ldxa [%g4] ASI_DMMU, %g5
1311 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1314 ldxa [%g4] ASI_DMMU, %g4
1316 109: or %g7, %lo(109b), %g7
1320 add %sp, PTREGS_OFF, %o0
1324 .globl breakpoint_trap
1326 call sparc_breakpoint
1327 add %sp, PTREGS_OFF, %o0
1331 #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
1332 defined(CONFIG_SOLARIS_EMUL_MODULE)
1333 /* SunOS uses syscall zero as the 'indirect syscall' it looks
1334 * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
1335 * This is complete brain damage.
1341 cmp %o0, NR_SYSCALLS
1344 sethi %hi(sunos_nosys), %l6
1346 or %l6, %lo(sunos_nosys), %l6
1347 1: sethi %hi(sunos_sys_table), %l7
1348 or %l7, %lo(sunos_sys_table), %l7
1349 lduw [%l7 + %o0], %l6
1363 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1364 b,pt %xcc, ret_sys_call
1365 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1367 /* SunOS getuid() returns uid in %o0 and euid in %o1 */
1370 call sys32_geteuid16
1373 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1374 b,pt %xcc, ret_sys_call
1375 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1377 /* SunOS getgid() returns gid in %o0 and egid in %o1 */
1380 call sys32_getegid16
1383 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1384 b,pt %xcc, ret_sys_call
1385 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1388 /* SunOS's execv() call only specifies the argv argument, the
1389 * environment settings are the same as the calling processes.
1393 sethi %hi(sparc_execve), %g1
1394 ba,pt %xcc, execve_merge
1395 or %g1, %lo(sparc_execve), %g1
1396 #ifdef CONFIG_COMPAT
1399 stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
1402 sethi %hi(sparc32_execve), %g1
1403 or %g1, %lo(sparc32_execve), %g1
1408 add %sp, PTREGS_OFF, %o0
1410 .globl sys_pipe, sys_sigpause, sys_nis_syscall
1411 .globl sys_rt_sigreturn
1413 .globl sys_sigaltstack
1415 sys_pipe: ba,pt %xcc, sparc_pipe
1416 add %sp, PTREGS_OFF, %o0
1417 sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
1418 add %sp, PTREGS_OFF, %o0
1419 sys_memory_ordering:
1420 ba,pt %xcc, sparc_memory_ordering
1421 add %sp, PTREGS_OFF, %o1
1422 sys_sigaltstack:ba,pt %xcc, do_sigaltstack
1423 add %i6, STACK_BIAS, %o2
1424 #ifdef CONFIG_COMPAT
1425 .globl sys32_sigstack
1426 sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
1428 .globl sys32_sigaltstack
1430 ba,pt %xcc, do_sys32_sigaltstack
1434 #ifdef CONFIG_COMPAT
1435 .globl sys32_sigreturn
1437 add %sp, PTREGS_OFF, %o0
1439 add %o7, 1f-.-4, %o7
1443 add %sp, PTREGS_OFF, %o0
1444 call do_rt_sigreturn
1445 add %o7, 1f-.-4, %o7
1447 #ifdef CONFIG_COMPAT
1448 .globl sys32_rt_sigreturn
1450 add %sp, PTREGS_OFF, %o0
1451 call do_rt_sigreturn32
1452 add %o7, 1f-.-4, %o7
1455 sys_ptrace: add %sp, PTREGS_OFF, %o0
1457 add %o7, 1f-.-4, %o7
1460 1: ldx [%curptr + TI_FLAGS], %l5
1461 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1464 add %sp, PTREGS_OFF, %o0
1471 /* This is how fork() was meant to be done, 8 instruction entry.
1473 * I questioned the following code briefly, let me clear things
1474 * up so you must not reason on it like I did.
1476 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
1477 * need it here because the only piece of window state we copy to
1478 * the child is the CWP register. Even if the parent sleeps,
1479 * we are safe because we stuck it into pt_regs of the parent
1480 * so it will not change.
1482 * XXX This raises the question, whether we can do the same on
1483 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
1484 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
1485 * XXX fork_kwim in UREG_G1 (global registers are considered
1486 * XXX volatile across a system call in the sparc ABI I think
1487 * XXX if it isn't we can use regs->y instead, anyone who depends
1488 * XXX upon the Y register being preserved across a fork deserves
1491 * In fact we should take advantage of that fact for other things
1492 * during system calls...
1494 .globl sys_fork, sys_vfork, sys_clone, sparc_exit
1495 .globl ret_from_syscall
1497 sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
1498 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
1499 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
1500 ba,pt %xcc, sys_clone
1506 ba,pt %xcc, sparc_do_fork
1507 add %sp, PTREGS_OFF, %o2
1509 /* Clear current_thread_info()->new_child, and
1510 * check performance counter stuff too.
1512 stb %g0, [%g6 + TI_NEW_CHILD]
1513 ldx [%g6 + TI_FLAGS], %l0
1516 andcc %l0, _TIF_PERFCTR, %g0
1519 ldx [%g6 + TI_PCR], %o7
1522 /* Blackbird errata workaround. See commentary in
1523 * smp.c:smp_percpu_timer_interrupt() for more
1529 99: wr %g0, %g0, %pic
1532 1: b,pt %xcc, ret_sys_call
1533 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
1534 sparc_exit: rdpr %pstate, %g2
1535 wrpr %g2, PSTATE_IE, %pstate
1539 wrpr %g3, 0x0, %cansave
1540 wrpr %g0, 0x0, %otherwin
1541 wrpr %g2, 0x0, %pstate
1542 ba,pt %xcc, sys_exit
1543 stb %g0, [%g6 + TI_WSAVED]
1545 linux_sparc_ni_syscall:
1546 sethi %hi(sys_ni_syscall), %l7
1548 or %l7, %lo(sys_ni_syscall), %l7
1550 linux_syscall_trace32:
1551 add %sp, PTREGS_OFF, %o0
1561 linux_syscall_trace:
1562 add %sp, PTREGS_OFF, %o0
1573 /* Linux 32-bit and SunOS system calls enter here... */
1575 .globl linux_sparc_syscall32
1576 linux_sparc_syscall32:
1577 /* Direct access to user regs, much faster. */
1578 cmp %g1, NR_SYSCALLS ! IEU1 Group
1579 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1580 srl %i0, 0, %o0 ! IEU0
1581 sll %g1, 2, %l4 ! IEU0 Group
1582 srl %i4, 0, %o4 ! IEU1
1583 lduw [%l7 + %l4], %l7 ! Load
1584 srl %i1, 0, %o1 ! IEU0 Group
1585 ldx [%curptr + TI_FLAGS], %l0 ! Load
1587 srl %i5, 0, %o5 ! IEU1
1588 srl %i2, 0, %o2 ! IEU0 Group
1589 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1590 bne,pn %icc, linux_syscall_trace32 ! CTI
1592 call %l7 ! CTI Group brk forced
1593 srl %i3, 0, %o3 ! IEU0
1596 /* Linux native and SunOS system calls enter here... */
1598 .globl linux_sparc_syscall, ret_sys_call
1599 linux_sparc_syscall:
1600 /* Direct access to user regs, much faster. */
1601 cmp %g1, NR_SYSCALLS ! IEU1 Group
1602 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1604 sll %g1, 2, %l4 ! IEU0 Group
1606 lduw [%l7 + %l4], %l7 ! Load
1607 4: mov %i2, %o2 ! IEU0 Group
1608 ldx [%curptr + TI_FLAGS], %l0 ! Load
1611 mov %i4, %o4 ! IEU0 Group
1612 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1613 bne,pn %icc, linux_syscall_trace ! CTI Group
1615 2: call %l7 ! CTI Group brk forced
1619 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1621 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
1622 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
1624 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
1627 /* Check if force_successful_syscall_return()
1630 ldub [%curptr + TI_SYS_NOERROR], %l2
1632 stb %g0, [%curptr + TI_SYS_NOERROR]
1634 cmp %o0, -ERESTART_RESTARTBLOCK
1636 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
1638 /* System call success, clear Carry condition code. */
1640 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1641 bne,pn %icc, linux_syscall_trace2
1642 add %l1, 0x4, %l2 ! npc = npc+4
1643 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1644 ba,pt %xcc, rtrap_clr_l6
1645 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1648 /* System call failure, set Carry condition code.
1649 * Also, get abs(errno) to return to the process.
1651 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
1654 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1656 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1657 bne,pn %icc, linux_syscall_trace2
1658 add %l1, 0x4, %l2 ! npc = npc+4
1659 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1662 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1663 linux_syscall_trace2:
1664 add %sp, PTREGS_OFF, %o0
1667 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1669 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1672 .globl __flushw_user
1677 1: save %sp, -128, %sp
1683 restore %g0, %g0, %g0
1688 .globl hard_smp_processor_id
1689 hard_smp_processor_id:
1691 .globl real_hard_smp_processor_id
1692 real_hard_smp_processor_id:
1700 * returns %o0: sysino
1702 .globl sun4v_devino_to_sysino
1703 sun4v_devino_to_sysino:
1704 mov HV_FAST_INTR_DEVINO2SYSINO, %o5
1711 * returns %o0: intr_enabled (HV_INTR_{DISABLED,ENABLED})
1713 .globl sun4v_intr_getenabled
1714 sun4v_intr_getenabled:
1715 mov HV_FAST_INTR_GETENABLED, %o5
1721 * %o1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
1723 .globl sun4v_intr_setenabled
1724 sun4v_intr_setenabled:
1725 mov HV_FAST_INTR_SETENABLED, %o5
1732 * returns %o0: intr_state (HV_INTR_STATE_*)
1734 .globl sun4v_intr_getstate
1735 sun4v_intr_getstate:
1736 mov HV_FAST_INTR_GETSTATE, %o5
1742 * %o1: intr_state (HV_INTR_STATE_*)
1744 .globl sun4v_intr_setstate
1745 sun4v_intr_setstate:
1746 mov HV_FAST_INTR_SETSTATE, %o5
1753 * returns %o0: cpuid
1755 .globl sun4v_intr_gettarget
1756 sun4v_intr_gettarget:
1757 mov HV_FAST_INTR_GETTARGET, %o5
1765 .globl sun4v_intr_settarget
1766 sun4v_intr_settarget:
1767 mov HV_FAST_INTR_SETTARGET, %o5
1774 * %o2: num queue entries
1776 * returns %o0: status
1778 .globl sun4v_cpu_qconf
1780 mov HV_FAST_CPU_QCONF, %o5
1785 /* returns %o0: status
1787 .globl sun4v_cpu_yield
1789 mov HV_FAST_CPU_YIELD, %o5
1794 /* %o0: num cpus in cpu list
1795 * %o1: cpu list paddr
1796 * %o2: mondo block paddr
1798 * returns %o0: status
1800 .globl sun4v_cpu_mondo_send
1801 sun4v_cpu_mondo_send:
1802 mov HV_FAST_CPU_MONDO_SEND, %o5
1809 * returns %o0: -status if status non-zero, else
1810 * %o0: cpu state as HV_CPU_STATE_*
1812 .globl sun4v_cpu_state
1814 mov HV_FAST_CPU_STATE, %o5