]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SPARC64]: Move syscall success and newchild state out of thread flags.
authorDavid S. Miller <davem@davemloft.net>
Mon, 25 Jul 2005 02:36:26 +0000 (19:36 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Jul 2005 02:36:26 +0000 (19:36 -0700)
These two bits were accesses non-atomically from assembler
code.  So, in order to eliminate any potential races resulting
from that, move these pieces of state into two bytes elsewhere
in struct thread_info.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc64/kernel/entry.S
arch/sparc64/kernel/process.c
arch/sparc64/kernel/smp.c
arch/sparc64/kernel/traps.c
include/asm-sparc64/ptrace.h
include/asm-sparc64/system.h
include/asm-sparc64/thread_info.h

index d781f10adc52eab8d8d57cf55f208650b0e9f185..88332f00094ac5d00ae9f0e2acdc0adbbdf595b5 100644 (file)
@@ -1600,11 +1600,11 @@ sys_clone:      flushw
                ba,pt           %xcc, sparc_do_fork
                 add            %sp, PTREGS_OFF, %o2
 ret_from_syscall:
-               /* Clear SPARC_FLAG_NEWCHILD, switch_to leaves thread.flags in
-                * %o7 for us.  Check performance counter stuff too.
+               /* Clear current_thread_info()->new_child, and
+                * check performance counter stuff too.
                 */
-               andn            %o7, _TIF_NEWCHILD, %l0
-               stx             %l0, [%g6 + TI_FLAGS]
+               stb             %g0, [%g6 + TI_NEW_CHILD]
+               ldx             [%g6 + TI_FLAGS], %l0
                call            schedule_tail
                 mov            %g7, %o0
                andcc           %l0, _TIF_PERFCTR, %g0
@@ -1720,12 +1720,11 @@ ret_sys_call:
        /* Check if force_successful_syscall_return()
         * was invoked.
         */
-       ldx             [%curptr + TI_FLAGS], %l0
-       andcc           %l0, _TIF_SYSCALL_SUCCESS, %g0
-       be,pt           %icc, 1f
-        andn           %l0, _TIF_SYSCALL_SUCCESS, %l0
+       ldub            [%curptr + TI_SYS_NOERROR], %l0
+       brz,pt          %l0, 1f
+        nop
        ba,pt           %xcc, 80f
-        stx            %l0, [%curptr + TI_FLAGS]
+        stb            %g0, [%curptr + TI_SYS_NOERROR]
 
 1:
        cmp             %o0, -ERESTART_RESTARTBLOCK
index a0cd2b2494d6cc5f111faeed82a42ab96ba99323..cffb1c8ab4fc4adb071e288954e6b95be9adf7cd 100644 (file)
@@ -621,8 +621,8 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
        memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ));
 
        t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) |
-               _TIF_NEWCHILD |
                (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT);
+       t->new_child = 1;
        t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS;
        t->kregs = (struct pt_regs *)(child_trap_frame+sizeof(struct sparc_stackf));
        t->fpsaved[0] = 0;
index 7e8e2919e18677e67e5bc7f37c626190cd70a394..b9b42491e118b6e273f40889de677ffb5d98cc1f 100644 (file)
@@ -137,7 +137,7 @@ void __init smp_callin(void)
        /* Clear this or we will die instantly when we
         * schedule back to this idler...
         */
-       clear_thread_flag(TIF_NEWCHILD);
+       current_thread_info()->new_child = 0;
 
        /* Attach to the address space of init_task. */
        atomic_inc(&init_mm.mm_count);
index a9f4596d7c2bcd82419386d808b5f35d69d2a46a..100b0107c4be89b1484c8b370dd8898871cfe10f 100644 (file)
@@ -2125,6 +2125,8 @@ void __init trap_init(void)
            TI_PCR != offsetof(struct thread_info, pcr_reg) ||
            TI_CEE_STUFF != offsetof(struct thread_info, cee_stuff) ||
            TI_PRE_COUNT != offsetof(struct thread_info, preempt_count) ||
+           TI_NEW_CHILD != offsetof(struct thread_info, new_child) ||
+           TI_SYS_NOERROR != offsetof(struct thread_info, syscall_noerror) ||
            TI_FPREGS != offsetof(struct thread_info, fpregs) ||
            (TI_FPREGS & (64 - 1)))
                thread_info_offsets_are_bolixed_dave();
index 2d2b5a113d242345fc5909fefb62c12af7596b78..6194f771e9fc738536b0165a2ee7f6b99e625b34 100644 (file)
@@ -94,8 +94,9 @@ struct sparc_trapf {
 #define STACKFRAME32_SZ        sizeof(struct sparc_stackf32)
 
 #ifdef __KERNEL__
-#define force_successful_syscall_return()      \
-       set_thread_flag(TIF_SYSCALL_SUCCESS)
+#define force_successful_syscall_return()          \
+do {   current_thread_info()->syscall_noerror = 1; \
+} while (0)
 #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
 #define instruction_pointer(regs) ((regs)->tpc)
 #ifdef CONFIG_SMP
index f9be2c5b4dc97360013fb5ddfe2d54c23aeaad90..ee4bdfc6b88f3a7b047da2361bb117bfbe312581 100644 (file)
@@ -190,24 +190,23 @@ do {      if (test_thread_flag(TIF_PERFCTR)) {                            \
        "wrpr   %%g1, %%cwp\n\t"                                        \
        "ldx    [%%g6 + %3], %%o6\n\t"                                  \
        "ldub   [%%g6 + %2], %%o5\n\t"                                  \
-       "ld   [%%g6 + %4], %%o7\n\t"                                  \
+       "ldub   [%%g6 + %4], %%o7\n\t"                                  \
        "mov    %%g6, %%l2\n\t"                                         \
        "wrpr   %%o5, 0x0, %%wstate\n\t"                                \
        "ldx    [%%sp + 2047 + 0x70], %%i6\n\t"                         \
        "ldx    [%%sp + 2047 + 0x78], %%i7\n\t"                         \
        "wrpr   %%g0, 0x94, %%pstate\n\t"                               \
        "mov    %%l2, %%g6\n\t"                                         \
-       "ldx    [%%g6 + %7], %%g4\n\t"                                  \
+       "ldx    [%%g6 + %6], %%g4\n\t"                                  \
        "wrpr   %%g0, 0x96, %%pstate\n\t"                               \
-       "andcc  %%o7, %6, %%g0\n\t"                                     \
-       "beq,pt %%icc, 1f\n\t"                                          \
+       "brz,pt %%o7, 1f\n\t"                                           \
        " mov   %%g7, %0\n\t"                                           \
        "b,a ret_from_syscall\n\t"                                      \
        "1:\n\t"                                                        \
        : "=&r" (last)                                                  \
        : "0" (next->thread_info),                                      \
-         "i" (TI_WSTATE), "i" (TI_KSP), "i" (TI_FLAGS), "i" (TI_CWP),  \
-         "i" (_TIF_NEWCHILD), "i" (TI_TASK)                            \
+         "i" (TI_WSTATE), "i" (TI_KSP), "i" (TI_NEW_CHILD),            \
+         "i" (TI_CWP), "i" (TI_TASK)                                   \
        : "cc",                                                         \
                "g1", "g2", "g3",                   "g7",               \
                      "l2", "l3", "l4", "l5", "l6", "l7",               \
index a1d25c06f92a127172c1c8817f6a1076376b4569..352d9943661af3738a05c0b29748a8937692f44f 100644 (file)
@@ -47,7 +47,9 @@ struct thread_info {
        struct pt_regs          *kregs;
        struct exec_domain      *exec_domain;
        int                     preempt_count;  /* 0 => preemptable, <0 => BUG */
-       int                     __pad;
+       __u8                    new_child;
+       __u8                    syscall_noerror;
+       __u16                   __pad;
 
        unsigned long           *utraps;
 
@@ -87,6 +89,8 @@ struct thread_info {
 #define TI_KREGS       0x00000028
 #define TI_EXEC_DOMAIN 0x00000030
 #define TI_PRE_COUNT   0x00000038
+#define TI_NEW_CHILD   0x0000003c
+#define TI_SYS_NOERROR 0x0000003d
 #define TI_UTRAPS      0x00000040
 #define TI_REG_WINDOW  0x00000048
 #define TI_RWIN_SPTRS  0x000003c8      
@@ -219,10 +223,10 @@ register struct thread_info *current_thread_info_reg asm("g6");
 #define TIF_UNALIGNED          5       /* allowed to do unaligned accesses */
 #define TIF_NEWSIGNALS         6       /* wants new-style signals */
 #define TIF_32BIT              7       /* 32-bit binary */
-#define TIF_NEWCHILD           8       /* just-spawned child process */
+/* flag bit 8 is available */
 #define TIF_SECCOMP            9       /* secure computing */
 #define TIF_SYSCALL_AUDIT      10      /* syscall auditing active */
-#define TIF_SYSCALL_SUCCESS    11
+/* flag bit 11 is available */
 /* NOTE: Thread flags >= 12 should be ones we have no interest
  *       in using in assembly, else we can't use the mask as
  *       an immediate value in instructions such as andcc.
@@ -239,10 +243,8 @@ register struct thread_info *current_thread_info_reg asm("g6");
 #define _TIF_UNALIGNED         (1<<TIF_UNALIGNED)
 #define _TIF_NEWSIGNALS                (1<<TIF_NEWSIGNALS)
 #define _TIF_32BIT             (1<<TIF_32BIT)
-#define _TIF_NEWCHILD          (1<<TIF_NEWCHILD)
 #define _TIF_SECCOMP           (1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT     (1<<TIF_SYSCALL_AUDIT)
-#define _TIF_SYSCALL_SUCCESS   (1<<TIF_SYSCALL_SUCCESS)
 #define _TIF_ABI_PENDING       (1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG    (1<<TIF_POLLING_NRFLAG)