Skip to content

Commit d0420c8

Browse files
dhowellsxjamesmorris
authored andcommitted
KEYS: Extend TIF_NOTIFY_RESUME to (almost) all architectures [try raspberrypi#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>
1 parent 7b1b916 commit d0420c8

18 files changed

Lines changed: 64 additions & 6 deletions

File tree

‎arch/alpha/include/asm/thread_info.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,20 @@ register struct thread_info *__current_thread_info __asm__("$8");
7575
#define TIF_UAC_SIGBUS 7
7676
#define TIF_MEMDIE 8
7777
#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */
78+
#define TIF_NOTIFY_RESUME 10 /* callback before returning to user */
7879
#define TIF_FREEZE 16 /* is freezing for suspend */
7980

8081
#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
8182
#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
8283
#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
8384
#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8485
#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
86+
#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
8587
#define _TIF_FREEZE (1<<TIF_FREEZE)
8688

8789
/* Work to do on interrupt/exception return. */
88-
#define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED)
90+
#define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
91+
_TIF_NOTIFY_RESUME)
8992

9093
/* Work to do on any return to userspace. */
9194
#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \

‎arch/alpha/kernel/signal.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,4 +683,9 @@ do_notify_resume(struct pt_regs *regs, struct switch_stack *sw,
683683
{
684684
if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
685685
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+
}
686691
}

‎arch/arm/include/asm/thread_info.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,13 @@ extern void vfp_sync_state(struct thread_info *thread);
130130
* TIF_SYSCALL_TRACE - syscall trace active
131131
* TIF_SIGPENDING - signal pending
132132
* TIF_NEED_RESCHED - rescheduling necessary
133+
* TIF_NOTIFY_RESUME - callback before returning to user
133134
* TIF_USEDFPU - FPU was used by this task this quantum (SMP)
134135
* TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED
135136
*/
136137
#define TIF_SIGPENDING 0
137138
#define TIF_NEED_RESCHED 1
139+
#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
138140
#define TIF_SYSCALL_TRACE 8
139141
#define TIF_POLLING_NRFLAG 16
140142
#define TIF_USING_IWMMXT 17
@@ -143,6 +145,7 @@ extern void vfp_sync_state(struct thread_info *thread);
143145

144146
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
145147
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
148+
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
146149
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
147150
#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
148151
#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)

‎arch/arm/kernel/entry-common.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fast_work_pending:
5151
work_pending:
5252
tst r1, #_TIF_NEED_RESCHED
5353
bne work_resched
54-
tst r1, #_TIF_SIGPENDING
54+
tst r1, #_TIF_SIGPENDING|_TIF_NOTIFY_RESUME
5555
beq no_work_pending
5656
mov r0, sp @ 'regs'
5757
mov r2, why @ 'syscall'

‎arch/arm/kernel/signal.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,4 +707,9 @@ do_notify_resume(struct pt_regs *regs, unsigned int thread_flags, int syscall)
707707
{
708708
if (thread_flags & _TIF_SIGPENDING)
709709
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+
}
710715
}

‎arch/avr32/include/asm/thread_info.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ static inline struct thread_info *current_thread_info(void)
8484
#define TIF_MEMDIE 6
8585
#define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
8686
#define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
87+
#define TIF_NOTIFY_RESUME 9 /* callback before returning to user */
8788
#define TIF_FREEZE 29
8889
#define TIF_DEBUG 30 /* debugging enabled */
8990
#define TIF_USERSPACE 31 /* true if FS sets userspace */
@@ -96,20 +97,23 @@ static inline struct thread_info *current_thread_info(void)
9697
#define _TIF_MEMDIE (1 << TIF_MEMDIE)
9798
#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
9899
#define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
100+
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
99101
#define _TIF_FREEZE (1 << TIF_FREEZE)
100102

101103
/* Note: The masks below must never span more than 16 bits! */
102104

103105
/* work to do on interrupt/exception return */
104106
#define _TIF_WORK_MASK \
105107
((1 << TIF_SIGPENDING) \
108+
| _TIF_NOTIFY_RESUME \
106109
| (1 << TIF_NEED_RESCHED) \
107110
| (1 << TIF_POLLING_NRFLAG) \
108111
| (1 << TIF_BREAKPOINT) \
109112
| (1 << TIF_RESTORE_SIGMASK))
110113

111114
/* work to do on any return to userspace */
112-
#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | (1 << TIF_SYSCALL_TRACE))
115+
#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | (1 << TIF_SYSCALL_TRACE) | \
116+
_TIF_NOTIFY_RESUME)
113117
/* work to do on return from debug mode */
114118
#define _TIF_DBGWORK_MASK (_TIF_WORK_MASK & ~(1 << TIF_BREAKPOINT))
115119

‎arch/avr32/kernel/entry-avr32b.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ syscall_exit_work:
281281
ld.w r1, r0[TI_flags]
282282
rjmp 1b
283283

284-
2: mov r2, _TIF_SIGPENDING | _TIF_RESTORE_SIGMASK
284+
2: mov r2, _TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NOTIFY_RESUME
285285
tst r1, r2
286286
breq 3f
287287
unmask_interrupts

‎arch/avr32/kernel/signal.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,9 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti)
322322

323323
if (ti->flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
324324
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+
}
325330
}

‎arch/cris/kernel/ptrace.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,9 @@ void do_notify_resume(int canrestart, struct pt_regs *regs,
3636
/* deal with pending signal delivery */
3737
if (thread_info_flags & _TIF_SIGPENDING)
3838
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+
}
3944
}

‎arch/h8300/include/asm/thread_info.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static inline struct thread_info *current_thread_info(void)
8989
TIF_NEED_RESCHED */
9090
#define TIF_MEMDIE 4
9191
#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
92+
#define TIF_NOTIFY_RESUME 6 /* callback before returning to user */
9293
#define TIF_FREEZE 16 /* is freezing for suspend */
9394

9495
/* as above, but as bit values */
@@ -97,6 +98,7 @@ static inline struct thread_info *current_thread_info(void)
9798
#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
9899
#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
99100
#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
101+
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
100102
#define _TIF_FREEZE (1<<TIF_FREEZE)
101103

102104
#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */

0 commit comments

Comments
 (0)