diff options
author | David S. Miller <davem@davemloft.net> | 2005-07-24 22:36:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-07-24 22:36:26 -0400 |
commit | db7d9a4eb700be766cc9f29241483dbb1e748832 (patch) | |
tree | 48848384df15d9404ceab05867d7f4ef6b1a4bbe /arch/sparc64 | |
parent | cdd5186f753b23ab51f86679bdc4cc698ab0b893 (diff) |
[SPARC64]: Move syscall success and newchild state out of thread flags.
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>
Diffstat (limited to 'arch/sparc64')
-rw-r--r-- | arch/sparc64/kernel/entry.S | 17 | ||||
-rw-r--r-- | arch/sparc64/kernel/process.c | 2 | ||||
-rw-r--r-- | arch/sparc64/kernel/smp.c | 2 | ||||
-rw-r--r-- | arch/sparc64/kernel/traps.c | 2 |
4 files changed, 12 insertions, 11 deletions
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S index d781f10adc52..88332f00094a 100644 --- a/arch/sparc64/kernel/entry.S +++ b/arch/sparc64/kernel/entry.S | |||
@@ -1600,11 +1600,11 @@ sys_clone: flushw | |||
1600 | ba,pt %xcc, sparc_do_fork | 1600 | ba,pt %xcc, sparc_do_fork |
1601 | add %sp, PTREGS_OFF, %o2 | 1601 | add %sp, PTREGS_OFF, %o2 |
1602 | ret_from_syscall: | 1602 | ret_from_syscall: |
1603 | /* Clear SPARC_FLAG_NEWCHILD, switch_to leaves thread.flags in | 1603 | /* Clear current_thread_info()->new_child, and |
1604 | * %o7 for us. Check performance counter stuff too. | 1604 | * check performance counter stuff too. |
1605 | */ | 1605 | */ |
1606 | andn %o7, _TIF_NEWCHILD, %l0 | 1606 | stb %g0, [%g6 + TI_NEW_CHILD] |
1607 | stx %l0, [%g6 + TI_FLAGS] | 1607 | ldx [%g6 + TI_FLAGS], %l0 |
1608 | call schedule_tail | 1608 | call schedule_tail |
1609 | mov %g7, %o0 | 1609 | mov %g7, %o0 |
1610 | andcc %l0, _TIF_PERFCTR, %g0 | 1610 | andcc %l0, _TIF_PERFCTR, %g0 |
@@ -1720,12 +1720,11 @@ ret_sys_call: | |||
1720 | /* Check if force_successful_syscall_return() | 1720 | /* Check if force_successful_syscall_return() |
1721 | * was invoked. | 1721 | * was invoked. |
1722 | */ | 1722 | */ |
1723 | ldx [%curptr + TI_FLAGS], %l0 | 1723 | ldub [%curptr + TI_SYS_NOERROR], %l0 |
1724 | andcc %l0, _TIF_SYSCALL_SUCCESS, %g0 | 1724 | brz,pt %l0, 1f |
1725 | be,pt %icc, 1f | 1725 | nop |
1726 | andn %l0, _TIF_SYSCALL_SUCCESS, %l0 | ||
1727 | ba,pt %xcc, 80f | 1726 | ba,pt %xcc, 80f |
1728 | stx %l0, [%curptr + TI_FLAGS] | 1727 | stb %g0, [%curptr + TI_SYS_NOERROR] |
1729 | 1728 | ||
1730 | 1: | 1729 | 1: |
1731 | cmp %o0, -ERESTART_RESTARTBLOCK | 1730 | cmp %o0, -ERESTART_RESTARTBLOCK |
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c index a0cd2b2494d6..cffb1c8ab4fc 100644 --- a/arch/sparc64/kernel/process.c +++ b/arch/sparc64/kernel/process.c | |||
@@ -621,8 +621,8 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, | |||
621 | memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ)); | 621 | memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ)); |
622 | 622 | ||
623 | t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) | | 623 | t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) | |
624 | _TIF_NEWCHILD | | ||
625 | (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT); | 624 | (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT); |
625 | t->new_child = 1; | ||
626 | t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS; | 626 | t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS; |
627 | t->kregs = (struct pt_regs *)(child_trap_frame+sizeof(struct sparc_stackf)); | 627 | t->kregs = (struct pt_regs *)(child_trap_frame+sizeof(struct sparc_stackf)); |
628 | t->fpsaved[0] = 0; | 628 | t->fpsaved[0] = 0; |
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c index 7e8e2919e186..b9b42491e118 100644 --- a/arch/sparc64/kernel/smp.c +++ b/arch/sparc64/kernel/smp.c | |||
@@ -137,7 +137,7 @@ void __init smp_callin(void) | |||
137 | /* Clear this or we will die instantly when we | 137 | /* Clear this or we will die instantly when we |
138 | * schedule back to this idler... | 138 | * schedule back to this idler... |
139 | */ | 139 | */ |
140 | clear_thread_flag(TIF_NEWCHILD); | 140 | current_thread_info()->new_child = 0; |
141 | 141 | ||
142 | /* Attach to the address space of init_task. */ | 142 | /* Attach to the address space of init_task. */ |
143 | atomic_inc(&init_mm.mm_count); | 143 | atomic_inc(&init_mm.mm_count); |
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c index a9f4596d7c2b..100b0107c4be 100644 --- a/arch/sparc64/kernel/traps.c +++ b/arch/sparc64/kernel/traps.c | |||
@@ -2125,6 +2125,8 @@ void __init trap_init(void) | |||
2125 | TI_PCR != offsetof(struct thread_info, pcr_reg) || | 2125 | TI_PCR != offsetof(struct thread_info, pcr_reg) || |
2126 | TI_CEE_STUFF != offsetof(struct thread_info, cee_stuff) || | 2126 | TI_CEE_STUFF != offsetof(struct thread_info, cee_stuff) || |
2127 | TI_PRE_COUNT != offsetof(struct thread_info, preempt_count) || | 2127 | TI_PRE_COUNT != offsetof(struct thread_info, preempt_count) || |
2128 | TI_NEW_CHILD != offsetof(struct thread_info, new_child) || | ||
2129 | TI_SYS_NOERROR != offsetof(struct thread_info, syscall_noerror) || | ||
2128 | TI_FPREGS != offsetof(struct thread_info, fpregs) || | 2130 | TI_FPREGS != offsetof(struct thread_info, fpregs) || |
2129 | (TI_FPREGS & (64 - 1))) | 2131 | (TI_FPREGS & (64 - 1))) |
2130 | thread_info_offsets_are_bolixed_dave(); | 2132 | thread_info_offsets_are_bolixed_dave(); |