Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

lm32: Some signal handling cleanups

Use some of the new helper functions for signal handling recently introduced.

Hopefully this wont introduce new regressions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
  • Loading branch information...
commit 94e85eb799d38351d1e2e841537edc32aa358d64 1 parent 6b3e3a9
Lars-Peter Clausen authored August 24, 2012

Showing 1 changed file with 18 additions and 37 deletions. Show diff stats Hide diff stats

  1. 55  arch/lm32/kernel/signal.c
55  arch/lm32/kernel/signal.c
@@ -86,11 +86,7 @@ asmlinkage int _sys_rt_sigreturn(struct pt_regs *regs)
86 86
 	if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
87 87
 		goto badframe;
88 88
 
89  
-	sigdelsetmask(&set, SIG_KERNEL_ONLY_MASK);
90  
-	spin_lock_irq(&current->sighand->siglock);
91  
-	current->blocked = set;
92  
-	recalc_sigpending();
93  
-	spin_unlock_irq(&current->sighand->siglock);
  89
+	set_current_blocked(&set);
94 90
 
95 91
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
96 92
 		goto badframe;
@@ -128,11 +124,11 @@ static inline void __user *get_sigframe(struct k_sigaction *ka,
128 124
 {
129 125
 	unsigned long sp = regs->sp;
130 126
 
131  
-	if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && !sas_ss_flags(sp))
  127
+	if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp))
132 128
 		/* use stack set by sigaltstack */
133 129
 		sp = current->sas_ss_sp + current->sas_ss_size;
134 130
 
135  
-	return (void __user *)((sp - frame_size) & -8UL);
  131
+	return (void __user *)((sp - frame_size) & ~7UL);
136 132
 }
137 133
 
138 134
 static int setup_rt_frame(int sig, struct k_sigaction *ka,
@@ -202,16 +198,12 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka,
202 198
 }
203 199
 
204 200
 static void handle_signal(unsigned long sig, siginfo_t *info,
205  
-		struct k_sigaction *ka, sigset_t *oldset, struct pt_regs *regs)
  201
+		struct k_sigaction *ka, struct pt_regs *regs)
206 202
 {
207  
-	setup_rt_frame(sig, ka, oldset, regs);
  203
+	sigset_t *oldset = sigmask_to_save();
208 204
 
209  
-	spin_lock_irq(&current->sighand->siglock);
210  
-	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
211  
-	if (!(ka->sa.sa_flags & SA_NODEFER))
212  
-		sigaddset(&current->blocked, sig);
213  
-	recalc_sigpending();
214  
-	spin_unlock_irq(&current->sighand->siglock);
  205
+	setup_rt_frame(sig, ka, oldset, regs);
  206
+	signal_delivered(sig, info, ka, regs, 0);
215 207
 }
216 208
 
217 209
 /*
@@ -228,7 +220,6 @@ static int do_signal(int retval, struct pt_regs *regs)
228 220
 	siginfo_t info;
229 221
 	int signr;
230 222
 	struct k_sigaction ka;
231  
-	sigset_t *oldset;
232 223
 
233 224
 	/*
234 225
 	 * We want the common case to go fast, which
@@ -239,43 +230,33 @@ static int do_signal(int retval, struct pt_regs *regs)
239 230
 	if (!user_mode(regs))
240 231
 		return 0;
241 232
 
242  
-	if (try_to_freeze()) 
  233
+	if (try_to_freeze())
243 234
 		goto no_signal;
244 235
 
245  
-	if (test_thread_flag(TIF_RESTORE_SIGMASK))
246  
-		oldset = &current->saved_sigmask;
247  
-	else
248  
-		oldset = &current->blocked;
249  
-
250 236
 	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
251 237
 
252 238
 	if (signr > 0) {
253 239
 		/* Whee!  Actually deliver the signal.  */
254  
-		handle_signal(signr, &info, &ka, oldset, regs);
255  
-		if (test_thread_flag(TIF_RESTORE_SIGMASK))
256  
-			clear_thread_flag(TIF_RESTORE_SIGMASK);
  240
+		handle_signal(signr, &info, &ka, regs);
257 241
 		return signr;
258 242
 	}
259 243
 
260 244
 no_signal:
261 245
 	/* Did we come from a system call? */
262 246
 	if (regs->r8) {
263  
-		/* Restart the system call - no handlers present */
264  
-		if (retval == -ERESTARTNOHAND
265  
-		    || retval == -ERESTARTSYS
266  
-		    || retval == -ERESTARTNOINTR)
267  
-		{
268  
-			regs->ea -= 4; /* Size of scall insn.  */
269  
-		}
270  
-		else if (retval == -ERESTART_RESTARTBLOCK) {
  247
+		switch (retval) {
  248
+		case -ERESTART_RESTARTBLOCK:
271 249
 			regs->r8 = __NR_restart_syscall;
  250
+		case -ERESTARTNOHAND:
  251
+		case -ERESTARTSYS:
  252
+		case -ERESTARTNOINTR:
272 253
 			regs->ea -= 4; /* Size of scall insn.  */
  254
+			break;
  255
+		default:
  256
+			break;
273 257
 		}
274 258
 	}
275  
-	if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
276  
-		clear_thread_flag(TIF_RESTORE_SIGMASK);
277  
-		sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
278  
-	}
  259
+	restore_saved_sigmask();
279 260
 
280 261
 	return retval;
281 262
 }

0 notes on commit 94e85eb

Please sign in to comment.
Something went wrong with that request. Please try again.