Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KEYS: Extend TIF_NOTIFY_RESUME to (almost) all architectures [try #6]

Implement TIF_NOTIFY_RESUME for most of those architectures in which isn't yet
available, and, whilst we're at it, have it call the appropriate tracehook.

After this patch, blackfin, m68k* and xtensa still lack support and need
alteration of assembly code to make it work.

Resume notification can then be used (by a later patch) to install a new
session keyring on the parent of a process.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>

cc: linux-arch@vger.kernel.org
Signed-off-by: James Morris <jmorris@namei.org>

authored by

David Howells and committed by
James Morris
d0420c83 7b1b9164

+64 -6
+4 -1
arch/alpha/include/asm/thread_info.h
··· 75 75 #define TIF_UAC_SIGBUS 7 76 76 #define TIF_MEMDIE 8 77 77 #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */ 78 + #define TIF_NOTIFY_RESUME 10 /* callback before returning to user */ 78 79 #define TIF_FREEZE 16 /* is freezing for suspend */ 79 80 80 81 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) ··· 83 82 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 84 83 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 85 84 #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 85 + #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 86 86 #define _TIF_FREEZE (1<<TIF_FREEZE) 87 87 88 88 /* Work to do on interrupt/exception return. */ 89 - #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED) 89 + #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 90 + _TIF_NOTIFY_RESUME) 90 91 91 92 /* Work to do on any return to userspace. */ 92 93 #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
+5
arch/alpha/kernel/signal.c
··· 683 683 { 684 684 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) 685 685 do_signal(regs, sw, r0, r19); 686 + 687 + if (thread_info_flags & _TIF_NOTIFY_RESUME) { 688 + clear_thread_flag(TIF_NOTIFY_RESUME); 689 + tracehook_notify_resume(regs); 690 + } 686 691 }
+3
arch/arm/include/asm/thread_info.h
··· 130 130 * TIF_SYSCALL_TRACE - syscall trace active 131 131 * TIF_SIGPENDING - signal pending 132 132 * TIF_NEED_RESCHED - rescheduling necessary 133 + * TIF_NOTIFY_RESUME - callback before returning to user 133 134 * TIF_USEDFPU - FPU was used by this task this quantum (SMP) 134 135 * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED 135 136 */ 136 137 #define TIF_SIGPENDING 0 137 138 #define TIF_NEED_RESCHED 1 139 + #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ 138 140 #define TIF_SYSCALL_TRACE 8 139 141 #define TIF_POLLING_NRFLAG 16 140 142 #define TIF_USING_IWMMXT 17 ··· 145 143 146 144 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 147 145 #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 146 + #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 148 147 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 149 148 #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 150 149 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
+1 -1
arch/arm/kernel/entry-common.S
··· 51 51 work_pending: 52 52 tst r1, #_TIF_NEED_RESCHED 53 53 bne work_resched 54 - tst r1, #_TIF_SIGPENDING 54 + tst r1, #_TIF_SIGPENDING|_TIF_NOTIFY_RESUME 55 55 beq no_work_pending 56 56 mov r0, sp @ 'regs' 57 57 mov r2, why @ 'syscall'
+5
arch/arm/kernel/signal.c
··· 707 707 { 708 708 if (thread_flags & _TIF_SIGPENDING) 709 709 do_signal(&current->blocked, regs, syscall); 710 + 711 + if (thread_flags & _TIF_NOTIFY_RESUME) { 712 + clear_thread_flag(TIF_NOTIFY_RESUME); 713 + tracehook_notify_resume(regs); 714 + } 710 715 }
+5 -1
arch/avr32/include/asm/thread_info.h
··· 84 84 #define TIF_MEMDIE 6 85 85 #define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */ 86 86 #define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */ 87 + #define TIF_NOTIFY_RESUME 9 /* callback before returning to user */ 87 88 #define TIF_FREEZE 29 88 89 #define TIF_DEBUG 30 /* debugging enabled */ 89 90 #define TIF_USERSPACE 31 /* true if FS sets userspace */ ··· 97 96 #define _TIF_MEMDIE (1 << TIF_MEMDIE) 98 97 #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 99 98 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP) 99 + #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 100 100 #define _TIF_FREEZE (1 << TIF_FREEZE) 101 101 102 102 /* Note: The masks below must never span more than 16 bits! */ ··· 105 103 /* work to do on interrupt/exception return */ 106 104 #define _TIF_WORK_MASK \ 107 105 ((1 << TIF_SIGPENDING) \ 106 + | _TIF_NOTIFY_RESUME \ 108 107 | (1 << TIF_NEED_RESCHED) \ 109 108 | (1 << TIF_POLLING_NRFLAG) \ 110 109 | (1 << TIF_BREAKPOINT) \ 111 110 | (1 << TIF_RESTORE_SIGMASK)) 112 111 113 112 /* work to do on any return to userspace */ 114 - #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | (1 << TIF_SYSCALL_TRACE)) 113 + #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | (1 << TIF_SYSCALL_TRACE) | \ 114 + _TIF_NOTIFY_RESUME) 115 115 /* work to do on return from debug mode */ 116 116 #define _TIF_DBGWORK_MASK (_TIF_WORK_MASK & ~(1 << TIF_BREAKPOINT)) 117 117
+1 -1
arch/avr32/kernel/entry-avr32b.S
··· 281 281 ld.w r1, r0[TI_flags] 282 282 rjmp 1b 283 283 284 - 2: mov r2, _TIF_SIGPENDING | _TIF_RESTORE_SIGMASK 284 + 2: mov r2, _TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NOTIFY_RESUME 285 285 tst r1, r2 286 286 breq 3f 287 287 unmask_interrupts
+5
arch/avr32/kernel/signal.c
··· 322 322 323 323 if (ti->flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) 324 324 do_signal(regs, &current->blocked, syscall); 325 + 326 + if (ti->flags & _TIF_NOTIFY_RESUME) { 327 + clear_thread_flag(TIF_NOTIFY_RESUME); 328 + tracehook_notify_resume(regs); 329 + } 325 330 }
+5
arch/cris/kernel/ptrace.c
··· 36 36 /* deal with pending signal delivery */ 37 37 if (thread_info_flags & _TIF_SIGPENDING) 38 38 do_signal(canrestart,regs); 39 + 40 + if (thread_info_flags & _TIF_NOTIFY_RESUME) { 41 + clear_thread_flag(TIF_NOTIFY_RESUME); 42 + tracehook_notify_resume(regs); 43 + } 39 44 }
+2
arch/h8300/include/asm/thread_info.h
··· 89 89 TIF_NEED_RESCHED */ 90 90 #define TIF_MEMDIE 4 91 91 #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */ 92 + #define TIF_NOTIFY_RESUME 6 /* callback before returning to user */ 92 93 #define TIF_FREEZE 16 /* is freezing for suspend */ 93 94 94 95 /* as above, but as bit values */ ··· 98 97 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 99 98 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 100 99 #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 100 + #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 101 101 #define _TIF_FREEZE (1<<TIF_FREEZE) 102 102 103 103 #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
+5
arch/h8300/kernel/signal.c
··· 552 552 { 553 553 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) 554 554 do_signal(regs, NULL); 555 + 556 + if (thread_info_flags & _TIF_NOTIFY_RESUME) { 557 + clear_thread_flag(TIF_NOTIFY_RESUME); 558 + tracehook_notify_resume(regs); 559 + } 555 560 }
+2
arch/m32r/include/asm/thread_info.h
··· 149 149 #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 150 150 #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */ 151 151 #define TIF_IRET 4 /* return with iret */ 152 + #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */ 152 153 #define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */ 153 154 #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ 154 155 #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ ··· 161 160 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 162 161 #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 163 162 #define _TIF_IRET (1<<TIF_IRET) 163 + #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 164 164 #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 165 165 #define _TIF_USEDFPU (1<<TIF_USEDFPU) 166 166 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
+5
arch/m32r/kernel/signal.c
··· 408 408 if (thread_info_flags & _TIF_SIGPENDING) 409 409 do_signal(regs,oldset); 410 410 411 + if (thread_info_flags & _TIF_NOTIFY_RESUME) { 412 + clear_thread_flag(TIF_NOTIFY_RESUME); 413 + tracehook_notify_resume(regs); 414 + } 415 + 411 416 clear_thread_flag(TIF_IRET); 412 417 }
+2
arch/mips/include/asm/thread_info.h
··· 115 115 #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 116 116 #define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */ 117 117 #define TIF_SECCOMP 4 /* secure computing */ 118 + #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */ 118 119 #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ 119 120 #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ 120 121 #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ ··· 140 139 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 141 140 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 142 141 #define _TIF_SECCOMP (1<<TIF_SECCOMP) 142 + #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 143 143 #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 144 144 #define _TIF_USEDFPU (1<<TIF_USEDFPU) 145 145 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
+5
arch/mips/kernel/signal.c
··· 700 700 /* deal with pending signal delivery */ 701 701 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) 702 702 do_signal(regs); 703 + 704 + if (thread_info_flags & _TIF_NOTIFY_RESUME) { 705 + clear_thread_flag(TIF_NOTIFY_RESUME); 706 + tracehook_notify_resume(regs); 707 + } 703 708 }
+3 -1
arch/parisc/include/asm/thread_info.h
··· 59 59 #define TIF_MEMDIE 5 60 60 #define TIF_RESTORE_SIGMASK 6 /* restore saved signal mask */ 61 61 #define TIF_FREEZE 7 /* is freezing for suspend */ 62 + #define TIF_NOTIFY_RESUME 8 /* callback before returning to user */ 62 63 63 64 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 64 65 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) ··· 68 67 #define _TIF_32BIT (1 << TIF_32BIT) 69 68 #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 70 69 #define _TIF_FREEZE (1 << TIF_FREEZE) 70 + #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 71 71 72 - #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | \ 72 + #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | \ 73 73 _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK) 74 74 75 75 #endif /* __KERNEL__ */
+1 -1
arch/parisc/kernel/entry.S
··· 948 948 /* As above */ 949 949 mfctl %cr30,%r1 950 950 LDREG TI_FLAGS(%r1),%r19 951 - ldi (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK), %r20 951 + ldi (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK|_TIF_NOTIFY_RESUME), %r20 952 952 and,COND(<>) %r19, %r20, %r0 953 953 b,n intr_restore /* skip past if we've nothing to do */ 954 954
+5
arch/parisc/kernel/signal.c
··· 645 645 if (test_thread_flag(TIF_SIGPENDING) || 646 646 test_thread_flag(TIF_RESTORE_SIGMASK)) 647 647 do_signal(regs, in_syscall); 648 + 649 + if (test_thread_flag(TIF_NOTIFY_RESUME)) { 650 + clear_thread_flag(TIF_NOTIFY_RESUME); 651 + tracehook_notify_resume(regs); 652 + } 648 653 }