avr32: deal with syscall restarts
PATCH 6/6 avr32: deal with syscall restarts
Currently we both have signals arriving at sigreturn trigger syscall restart when the original handler hadn't been in the syscall at all *and* have multiple pending signals trigger the sitation when %pc is shifted back by more than one insn.
a) take handling of reschedule, signals and keychains into a new helper - work_pending(). All looping is done there now; asm glue calls that if we have anything for it to do.
b) do_signal() gets explicit "may restart" flag as an argument; after the first call during that loop it gets unconditional 0.
c) sigreturn() sets a thread flag - TIF_NORESTART. It is included into the "work_pending() has something to do" mask. work_pending() clears it, clearing its may_restart flag if it had done so.
--- arch/avr32/include/asm/thread_info.h | 3 ++ arch/avr32/kernel/entry-avr32b.S | 45 ++++------------------------ arch/avr32/kernel/signal.c | 55 ++++++++++++++++++++++++---------- 3 files changed, 48 insertions(+), 55 deletions(-)
arch/avr32/include/asm/thread_info.h +3 -0
@@ -85,6 +85,7 @@ static inline struct thread_info *current_thread_info(void)#define TIF_RESTORE_SIGMASK 7/* restore signal mask in do_signal */ #define TIF_CPU_GOING_TO_SLEEP 8/* CPU is entering sleep 0 mode */ #define TIF_NOTIFY_RESUME 9/* callback before returning to user */ +#define TIF_NORESTART 10#define TIF_FREEZE 29#define TIF_DEBUG 30/* debugging enabled */ #define TIF_USERSPACE 31/* true if FS sets userspace */
@@ -98,6 +99,7 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)#define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_NORESTART (1 << TIF_NORESTART)#define _TIF_FREEZE (1 << TIF_FREEZE)/* Note: The masks below must never span more than 16 bits! */
@@ -106,6 +108,7 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_WORK_MASK \ ((1 << TIF_SIGPENDING) \ | _TIF_NOTIFY_RESUME \ + | _TIF_NORESTART \ | (1 << TIF_NEED_RESCHED) \ | (1 << TIF_POLLING_NRFLAG) \ | (1 << TIF_BREAKPOINT) \
arch/avr32/kernel/entry-avr32b.S +6 -39
63 lines not on this page · raw message
arch/avr32/kernel/signal.c +39 -16
79 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Quoted 8 lines · Al Viro
Currently we both have signals arriving at sigreturn trigger syscall restart when the original handler hadn't been in the syscall at all *and* have multiple pending signals trigger the sitation when %pc is shifted back by more than one insn.
a) take handling of reschedule, signals and keychains into a new helper -
work_pending(). All looping is done there now; asm glue calls that if we have anything for it to do.
Am I the only one getting a conflict with the work_pending() function in include/linux/workqueue.h?
Quoted 6 lines
b)
do_signal()gets explicit "may restart" flag as an argument; after the first call during that loop it gets unconditional 0.c)
sigreturn()sets a thread flag -TIF_NORESTART. It is included into the "work_pending()has something to do" mask.work_pending()clears it, clearing itsmay_restartflag if it had done so.
Both sounds and look sane further below.
Quoted 12 lines
Signed-off-by Al Viro <[email protected]>--- arch/avr32/include/asm/thread_info.h | 3 ++ arch/avr32/kernel/entry-avr32b.S | 45 ++++------------------------ arch/avr32/kernel/signal.c | 55 ++++++++++++++++++++++++---------- 3 files changed, 48 insertions(+), 55 deletions(-)arch/avr32/include/asm/thread_info.h +0
-0
arch/avr32/include/asm/thread_info.h static inline struct thread_info *current_thread_info(void) · line 88
Quoted 4 lines
arch/avr32/include/asm/thread_info.h +1
-0@@ -85,6 +85,7 @@ static inline struct thread_info *current_thread_info(void)#define TIF_RESTORE_SIGMASK 7/* restore signal mask in do_signal */ #define TIF_CPU_GOING_TO_SLEEP 8/* CPU is entering sleep 0 mode */ #define TIF_NOTIFY_RESUME 9/* callback before returning to user */ +#define TIF_NORESTART 10
Please add a comment after the define.
<snipp>
arch/avr32/kernel/entry-avr32b.S syscall_exit_work: · line 276
Quoted 11 lines
arch/avr32/kernel/entry-avr32b.S +0
-3@@ -271,28 +271,11 @@ syscall_exit_work: unmask_interrupts call syscall_trace mask_interrupts - ld.w r1, r0[TI_flags] - -1: bld r1, TIF_NEED_RESCHED
Hmmm...
@ line 268syscall_exit_work:
bld r1, TIF_SYSCALL_TRACE
brcc 1f
Which refers to the 1: label you remove here.
arch/avr32/kernel/entry-avr32b.S syscall_exit_work: · line 274
Quoted 12 lines
arch/avr32/kernel/entry-avr32b.S +0
-11- brcc 2f - unmask_interrupts - call schedule - mask_interrupts - ld.w r1, r0[TI_flags] - rjmp 1b - -2: mov r2, _TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NOTIFY_RESUME - tst r1, r2 - breq 3f - unmask_interrupts mov r12, sp
Make a 1: label at this line should do the trick AFAICT.
<snipp>
Quoted 32 lines
arch/avr32/kernel/signal.c +4
-2@@ -45,6 +45,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)/* Always make any pending restarted system calls return -EINTR */ current_thread_info ()->restart_block.fn = do_no_restart_syscall; +set_thread_flag (TIF_NORESTART ); +#define COPY (x) err |= __get_user(regs->x, &sc->x)COPY (sr);COPY (pc);@@ -264,7 +266,7 @@ fail:* doesn't want to handle. Thus you cannot kill init even with a * SIGKILL even by mistake. */ -static void do_signal (struct pt_regs *regs,int syscall) +static void do_signal (struct pt_regs *regs,int may_restart) {siginfo_t info;int signr;@@ -285,7 +287,7 @@ static void do_signal(struct pt_regs *regs, int syscall) oldset = ¤t->blocked; signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (syscall) { +if (may_restart) {switch (regs->r12) {case -ERESTART_RESTARTBLOCK :case -ERESTARTNOHAND :
arch/avr32/kernel/signal.c static void do_signal(struct pt_regs *regs, int syscall) · line 322
Quoted 5 lines
arch/avr32/kernel/signal.c +1
-1@@ -317,20 +319,41 @@ static void do_signal(struct pt_regs *regs, int syscall)handle_signal (signr, &ka, &info, oldset, regs); } -asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti) +asmlinkage int work_pending(struct pt_regs *regs, struct thread_info *ti, int may_restart)
I get a conflict with a similar function declared in include/linux/workqueue.h. Also, please brake it over multiple lines as it is wider than 80 characters.
<snipp>
Signature · 1 line
Hans-Christian Egtvedt