Skip to content

Commit 9a28dbf

Browse files
committed
sparc64: Use a TS_RESTORE_SIGMASK
This mirrors x86 changeset 5a8da0e ("signals: x86 TS_RESTORE_SIGMASK") on sparc64. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent faa6cfd commit 9a28dbf

File tree

4 files changed

+44
-24
lines changed

4 files changed

+44
-24
lines changed

arch/sparc64/kernel/rtrap.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ __handle_user_windows:
4646
wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
4747
ldx [%g6 + TI_FLAGS], %l0
4848

49-
1: andcc %l0, (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), %g0
49+
1: andcc %l0, _TIF_SIGPENDING, %g0
5050
be,pt %xcc, __handle_user_windows_continue
5151
nop
5252
mov %l5, %o1
@@ -86,7 +86,7 @@ __handle_perfctrs:
8686
wrpr %g0, RTRAP_PSTATE, %pstate
8787
wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
8888
ldx [%g6 + TI_FLAGS], %l0
89-
1: andcc %l0, (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), %g0
89+
1: andcc %l0, _TIF_SIGPENDING, %g0
9090

9191
be,pt %xcc, __handle_perfctrs_continue
9292
sethi %hi(TSTATE_PEF), %o0
@@ -195,7 +195,7 @@ __handle_preemption_continue:
195195
andcc %l1, %o0, %g0
196196
andcc %l0, _TIF_NEED_RESCHED, %g0
197197
bne,pn %xcc, __handle_preemption
198-
andcc %l0, (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), %g0
198+
andcc %l0, _TIF_SIGPENDING, %g0
199199
bne,pn %xcc, __handle_signal
200200
__handle_signal_continue:
201201
ldub [%g6 + TI_WSAVED], %o2

arch/sparc64/kernel/signal.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ static long _sigpause_common(old_sigset_t set)
247247

248248
current->state = TASK_INTERRUPTIBLE;
249249
schedule();
250-
set_thread_flag(TIF_RESTORE_SIGMASK);
250+
251+
set_restore_sigmask();
252+
251253
return -ERESTARTNOHAND;
252254
}
253255

@@ -537,7 +539,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
537539
} else
538540
restart_syscall = 0;
539541

540-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
542+
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
541543
oldset = &current->saved_sigmask;
542544
else
543545
oldset = &current->blocked;
@@ -566,13 +568,12 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
566568
syscall_restart(orig_i0, regs, &ka.sa);
567569
handle_signal(signr, &ka, &info, oldset, regs);
568570

569-
/* a signal was successfully delivered; the saved
571+
/* A signal was successfully delivered; the saved
570572
* sigmask will have been stored in the signal frame,
571573
* and will be restored by sigreturn, so we can simply
572-
* clear the TIF_RESTORE_SIGMASK flag.
574+
* clear the TS_RESTORE_SIGMASK flag.
573575
*/
574-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
575-
clear_thread_flag(TIF_RESTORE_SIGMASK);
576+
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
576577
return;
577578
}
578579
if (restart_syscall &&
@@ -591,17 +592,17 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
591592
regs->tnpc -= 4;
592593
}
593594

594-
/* if there's no signal to deliver, we just put the saved sigmask
595+
/* If there's no signal to deliver, we just put the saved sigmask
595596
* back
596597
*/
597-
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
598-
clear_thread_flag(TIF_RESTORE_SIGMASK);
598+
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
599+
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
599600
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
600601
}
601602
}
602603

603604
void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long thread_info_flags)
604605
{
605-
if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
606+
if (thread_info_flags & _TIF_SIGPENDING)
606607
do_signal(regs, orig_i0);
607608
}

arch/sparc64/kernel/signal32.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -788,13 +788,12 @@ void do_signal32(sigset_t *oldset, struct pt_regs * regs,
788788
syscall_restart32(orig_i0, regs, &ka.sa);
789789
handle_signal32(signr, &ka, &info, oldset, regs);
790790

791-
/* a signal was successfully delivered; the saved
791+
/* A signal was successfully delivered; the saved
792792
* sigmask will have been stored in the signal frame,
793793
* and will be restored by sigreturn, so we can simply
794-
* clear the TIF_RESTORE_SIGMASK flag.
794+
* clear the TS_RESTORE_SIGMASK flag.
795795
*/
796-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
797-
clear_thread_flag(TIF_RESTORE_SIGMASK);
796+
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
798797
return;
799798
}
800799
if (restart_syscall &&
@@ -813,11 +812,11 @@ void do_signal32(sigset_t *oldset, struct pt_regs * regs,
813812
regs->tnpc -= 4;
814813
}
815814

816-
/* if there's no signal to deliver, we just put the saved sigmask
815+
/* If there's no signal to deliver, we just put the saved sigmask
817816
* back
818817
*/
819-
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
820-
clear_thread_flag(TIF_RESTORE_SIGMASK);
818+
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
819+
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
821820
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
822821
}
823822
}

include/asm-sparc64/thread_info.h

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct thread_info {
3838
struct task_struct *task;
3939
unsigned long flags;
4040
__u8 fpsaved[7];
41-
__u8 pad;
41+
__u8 status;
4242
unsigned long ksp;
4343

4444
/* D$ line 2 */
@@ -217,7 +217,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
217217
* nop
218218
*/
219219
#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
220-
#define TIF_RESTORE_SIGMASK 1 /* restore signal mask in do_signal() */
220+
/* flags bit 1 is available */
221221
#define TIF_SIGPENDING 2 /* signal pending */
222222
#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
223223
#define TIF_PERFCTR 4 /* performance counters active */
@@ -244,14 +244,34 @@ register struct thread_info *current_thread_info_reg asm("g6");
244244
#define _TIF_32BIT (1<<TIF_32BIT)
245245
#define _TIF_SECCOMP (1<<TIF_SECCOMP)
246246
#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
247-
#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
248247
#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
249248
#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
250249

251250
#define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
252-
(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | \
251+
(_TIF_SIGPENDING | \
253252
_TIF_NEED_RESCHED | _TIF_PERFCTR))
254253

254+
/*
255+
* Thread-synchronous status.
256+
*
257+
* This is different from the flags in that nobody else
258+
* ever touches our thread-synchronous status, so we don't
259+
* have to worry about atomic accesses.
260+
*
261+
* Note that there are only 8 bits available.
262+
*/
263+
#define TS_RESTORE_SIGMASK 0x0001 /* restore signal mask in do_signal() */
264+
265+
#ifndef __ASSEMBLY__
266+
#define HAVE_SET_RESTORE_SIGMASK 1
267+
static inline void set_restore_sigmask(void)
268+
{
269+
struct thread_info *ti = current_thread_info();
270+
ti->status |= TS_RESTORE_SIGMASK;
271+
set_bit(TIF_SIGPENDING, &ti->flags);
272+
}
273+
#endif /* !__ASSEMBLY__ */
274+
255275
#endif /* __KERNEL__ */
256276

257277
#endif /* _ASM_THREAD_INFO_H */

0 commit comments

Comments
 (0)