]> err.no Git - linux-2.6/blobdiff - arch/sparc64/kernel/rtrap.S
Merge git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm
[linux-2.6] / arch / sparc64 / kernel / rtrap.S
index a2fa277da62b44a5c49f87c48e506b8c0669c990..ecf6753b204a07d2da8b5a9c1bad0bbc35995218 100644 (file)
@@ -5,7 +5,6 @@
  * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  */
 
-#include <linux/config.h>
 
 #include <asm/asi.h>
 #include <asm/pstate.h>
 #define                RTRAP_PSTATE_IRQOFF     (PSTATE_RMO|PSTATE_PEF|PSTATE_PRIV)
 #define                RTRAP_PSTATE_AG_IRQOFF  (PSTATE_RMO|PSTATE_PEF|PSTATE_PRIV|PSTATE_AG)
 
-               /* Register %l6 keeps track of whether we are returning
-                * from a system call or not.  It is cleared if we call
-                * do_notify_resume, and it must not be otherwise modified
-                * until we fully commit to returning to userspace.
-                */
-
                .text
                .align                  32
 __handle_softirq:
@@ -57,14 +50,12 @@ __handle_user_windows:
                be,pt                   %xcc, __handle_user_windows_continue
                 nop
                mov                     %l5, %o1
-               mov                     %l6, %o2
                add                     %sp, PTREGS_OFF, %o0
-               mov                     %l0, %o3
+               mov                     %l0, %o2
 
                call                    do_notify_resume
                 wrpr                   %g0, RTRAP_PSTATE, %pstate
                wrpr                    %g0, RTRAP_PSTATE_IRQOFF, %pstate
-               clr                     %l6
                /* Signal delivery can modify pt_regs tstate, so we must
                 * reload it.
                 */
@@ -100,14 +91,12 @@ __handle_perfctrs:
                be,pt                   %xcc, __handle_perfctrs_continue
                 sethi                  %hi(TSTATE_PEF), %o0
                mov                     %l5, %o1
-               mov                     %l6, %o2
                add                     %sp, PTREGS_OFF, %o0
-               mov                     %l0, %o3
+               mov                     %l0, %o2
                call                    do_notify_resume
 
                 wrpr                   %g0, RTRAP_PSTATE, %pstate
                wrpr                    %g0, RTRAP_PSTATE_IRQOFF, %pstate
-               clr                     %l6
                /* Signal delivery can modify pt_regs tstate, so we must
                 * reload it.
                 */
@@ -128,13 +117,11 @@ __handle_userfpu:
 
 __handle_signal:
                mov                     %l5, %o1
-               mov                     %l6, %o2
                add                     %sp, PTREGS_OFF, %o0
-               mov                     %l0, %o3
+               mov                     %l0, %o2
                call                    do_notify_resume
                 wrpr                   %g0, RTRAP_PSTATE, %pstate
                wrpr                    %g0, RTRAP_PSTATE_IRQOFF, %pstate
-               clr                     %l6
 
                /* Signal delivery can modify pt_regs tstate, so we must
                 * reload it.
@@ -146,9 +133,8 @@ __handle_signal:
                 andn                   %l1, %l4, %l1
 
                .align                  64
-               .globl                  rtrap_irq, rtrap_clr_l6, rtrap, irqsz_patchme, rtrap_xcall
+               .globl                  rtrap_irq, rtrap, irqsz_patchme, rtrap_xcall
 rtrap_irq:
-rtrap_clr_l6:  clr                     %l6
 rtrap:
 #ifndef CONFIG_SMP
                sethi                   %hi(per_cpu____cpu_data), %l0
@@ -166,14 +152,26 @@ rtrap:
 __handle_softirq_continue:
 rtrap_xcall:
                sethi                   %hi(0xf << 20), %l4
-               andcc                   %l1, TSTATE_PRIV, %l3
                and                     %l1, %l4, %l4
+               andn                    %l1, %l4, %l1
+               srl                     %l4, 20, %l4
+#ifdef CONFIG_TRACE_IRQFLAGS
+               brnz,pn                 %l4, rtrap_no_irq_enable
+                nop
+               call                    trace_hardirqs_on
+                nop
+               wrpr                    %l4, %pil
+rtrap_no_irq_enable:
+#endif
+               andcc                   %l1, TSTATE_PRIV, %l3
                bne,pn                  %icc, to_kernel
-                andn                   %l1, %l4, %l1
+                nop
 
                /* We must hold IRQs off and atomically test schedule+signal
                 * state, then hold them off all the way back to userspace.
-                * If we are returning to kernel, none of this matters.
+                * If we are returning to kernel, none of this matters.  Note
+                * that we are disabling interrupts via PSTATE_IE, not using
+                * %pil.
                 *
                 * If we do not do this, there is a window where we would do
                 * the tests, later the signal/resched event arrives but we do
@@ -234,8 +232,10 @@ rt_continue:       ldx                     [%sp + PTREGS_OFF + PT_V9_G1], %g1
 
                /* Normal globals are restored, go to trap globals.  */
 661:           wrpr                    %g0, RTRAP_PSTATE_AG_IRQOFF, %pstate
-               .section                .gl_1insn_patch, "ax"
+               nop
+               .section                .sun4v_2insn_patch, "ax"
                .word                   661b
+               wrpr                    %g0, RTRAP_PSTATE_IRQOFF, %pstate
                SET_GL(1)
                .previous
 
@@ -255,7 +255,6 @@ rt_continue:        ldx                     [%sp + PTREGS_OFF + PT_V9_G1], %g1
 
                ld                      [%sp + PTREGS_OFF + PT_V9_Y], %o3
                wr                      %o3, %g0, %y
-               srl                     %l4, 20, %l4
                wrpr                    %l4, 0x0, %pil
                wrpr                    %g0, 0x1, %tl
                wrpr                    %l1, %g0, %tstate
@@ -264,11 +263,23 @@ rt_continue:      ldx                     [%sp + PTREGS_OFF + PT_V9_G1], %g1
 
                brnz,pn                 %l3, kern_rtt
                 mov                    PRIMARY_CONTEXT, %l7
-               ldxa                    [%l7 + %l7] ASI_DMMU, %l0
+
+661:           ldxa                    [%l7 + %l7] ASI_DMMU, %l0
+               .section                .sun4v_1insn_patch, "ax"
+               .word                   661b
+               ldxa                    [%l7 + %l7] ASI_MMU, %l0
+               .previous
+
                sethi                   %hi(sparc64_kern_pri_nuc_bits), %l1
                ldx                     [%l1 + %lo(sparc64_kern_pri_nuc_bits)], %l1
                or                      %l0, %l1, %l0
-               stxa                    %l0, [%l7] ASI_DMMU
+
+661:           stxa                    %l0, [%l7] ASI_DMMU
+               .section                .sun4v_1insn_patch, "ax"
+               .word                   661b
+               stxa                    %l0, [%l7] ASI_MMU
+               .previous
+
                sethi                   %hi(KERNBASE), %l7
                flush                   %l7
                rdpr                    %wstate, %l1
@@ -303,7 +314,13 @@ user_rtt_fill_fixup:
                sethi   %hi(sparc64_kern_pri_context), %g2
                ldx     [%g2 + %lo(sparc64_kern_pri_context)], %g2
                mov     PRIMARY_CONTEXT, %g1
-               stxa    %g2, [%g1] ASI_DMMU
+
+661:           stxa    %g2, [%g1] ASI_DMMU
+               .section .sun4v_1insn_patch, "ax"
+               .word   661b
+               stxa    %g2, [%g1] ASI_MMU
+               .previous
+
                sethi   %hi(KERNBASE), %g1
                flush   %g1
 
@@ -313,14 +330,15 @@ user_rtt_fill_fixup:
 
                mov     %g6, %l1
                wrpr    %g0, 0x0, %tl
-               wrpr    %g0, RTRAP_PSTATE, %pstate
 
 661:           nop
-               .section                .gl_1insn_patch, "ax"
+               .section                .sun4v_1insn_patch, "ax"
                .word                   661b
                SET_GL(0)
                .previous
 
+               wrpr    %g0, RTRAP_PSTATE, %pstate
+
                mov     %l1, %g6
                ldx     [%g6 + TI_TASK], %g4
                LOAD_PER_CPU_BASE(%g5, %g6, %g1, %g2, %g3)
@@ -354,8 +372,8 @@ to_kernel:
                 ldx                    [%g6 + TI_FLAGS], %l5
                andcc                   %l5, _TIF_NEED_RESCHED, %g0
                be,pt                   %xcc, kern_fpucheck
-                srl                    %l4, 20, %l5
-               cmp                     %l5, 0
+                nop
+               cmp                     %l4, 0
                bne,pn                  %xcc, kern_fpucheck
                 sethi                  %hi(PREEMPT_ACTIVE), %l6
                stw                     %l6, [%g6 + TI_PRE_COUNT]