diff options
author | Roland McGrath <roland@redhat.com> | 2008-04-19 17:26:54 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-26 11:35:47 -0400 |
commit | 8b9c5ff380aa4f10658171ed2b9abc1e0861b770 (patch) | |
tree | 25cc707163471e593274a16fe3623801b6f0a7a6 /arch | |
parent | f7f17a67c589f031c567d9fdc809dee7c5868c8a (diff) |
x86 signals: lift flags diddling code
This lifts the code diddling the TF and DF bits for signal handler setup
out of the several places copying the same code into the one place that
calls them all. There is no change in what it does.
I also separated the recently-added DF bit clearing from the TF diddling.
The compiler turns them back into one instruction anyway. The tossing
in of DF to the same line of code with no new comments was a bit more
arcane than seems wise.
Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/ia32/ia32_signal.c | 6 | ||||
-rw-r--r-- | arch/x86/kernel/signal_32.c | 35 | ||||
-rw-r--r-- | arch/x86/kernel/signal_64.c | 19 |
3 files changed, 30 insertions, 30 deletions
diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index 05e155d3fb6c..0866104f684c 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c | |||
@@ -500,9 +500,6 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka, | |||
500 | regs->ss = __USER32_DS; | 500 | regs->ss = __USER32_DS; |
501 | 501 | ||
502 | set_fs(USER_DS); | 502 | set_fs(USER_DS); |
503 | regs->flags &= ~(X86_EFLAGS_TF | X86_EFLAGS_DF); | ||
504 | if (test_thread_flag(TIF_SINGLESTEP)) | ||
505 | ptrace_notify(SIGTRAP); | ||
506 | 503 | ||
507 | #if DEBUG_SIG | 504 | #if DEBUG_SIG |
508 | printk(KERN_DEBUG "SIG deliver (%s:%d): sp=%p pc=%lx ra=%u\n", | 505 | printk(KERN_DEBUG "SIG deliver (%s:%d): sp=%p pc=%lx ra=%u\n", |
@@ -600,9 +597,6 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
600 | regs->ss = __USER32_DS; | 597 | regs->ss = __USER32_DS; |
601 | 598 | ||
602 | set_fs(USER_DS); | 599 | set_fs(USER_DS); |
603 | regs->flags &= ~(X86_EFLAGS_TF | X86_EFLAGS_DF); | ||
604 | if (test_thread_flag(TIF_SINGLESTEP)) | ||
605 | ptrace_notify(SIGTRAP); | ||
606 | 600 | ||
607 | #if DEBUG_SIG | 601 | #if DEBUG_SIG |
608 | printk(KERN_DEBUG "SIG deliver (%s:%d): sp=%p pc=%lx ra=%u\n", | 602 | printk(KERN_DEBUG "SIG deliver (%s:%d): sp=%p pc=%lx ra=%u\n", |
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c index f1b117930837..8e05e7f7bd40 100644 --- a/arch/x86/kernel/signal_32.c +++ b/arch/x86/kernel/signal_32.c | |||
@@ -413,16 +413,6 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | |||
413 | regs->ss = __USER_DS; | 413 | regs->ss = __USER_DS; |
414 | regs->cs = __USER_CS; | 414 | regs->cs = __USER_CS; |
415 | 415 | ||
416 | /* | ||
417 | * Clear TF when entering the signal handler, but | ||
418 | * notify any tracer that was single-stepping it. | ||
419 | * The tracer may want to single-step inside the | ||
420 | * handler too. | ||
421 | */ | ||
422 | regs->flags &= ~(X86_EFLAGS_TF | X86_EFLAGS_DF); | ||
423 | if (test_thread_flag(TIF_SINGLESTEP)) | ||
424 | ptrace_notify(SIGTRAP); | ||
425 | |||
426 | return 0; | 416 | return 0; |
427 | 417 | ||
428 | give_sigsegv: | 418 | give_sigsegv: |
@@ -501,16 +491,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
501 | regs->ss = __USER_DS; | 491 | regs->ss = __USER_DS; |
502 | regs->cs = __USER_CS; | 492 | regs->cs = __USER_CS; |
503 | 493 | ||
504 | /* | ||
505 | * Clear TF when entering the signal handler, but | ||
506 | * notify any tracer that was single-stepping it. | ||
507 | * The tracer may want to single-step inside the | ||
508 | * handler too. | ||
509 | */ | ||
510 | regs->flags &= ~(X86_EFLAGS_TF | X86_EFLAGS_DF); | ||
511 | if (test_thread_flag(TIF_SINGLESTEP)) | ||
512 | ptrace_notify(SIGTRAP); | ||
513 | |||
514 | return 0; | 494 | return 0; |
515 | 495 | ||
516 | give_sigsegv: | 496 | give_sigsegv: |
@@ -566,6 +546,21 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
566 | if (ret) | 546 | if (ret) |
567 | return ret; | 547 | return ret; |
568 | 548 | ||
549 | /* | ||
550 | * Clear the direction flag as per the ABI for function entry. | ||
551 | */ | ||
552 | regs->flags &= ~X86_EFLAGS_DF; | ||
553 | |||
554 | /* | ||
555 | * Clear TF when entering the signal handler, but | ||
556 | * notify any tracer that was single-stepping it. | ||
557 | * The tracer may want to single-step inside the | ||
558 | * handler too. | ||
559 | */ | ||
560 | regs->flags &= ~X86_EFLAGS_TF; | ||
561 | if (test_thread_flag(TIF_SINGLESTEP)) | ||
562 | ptrace_notify(SIGTRAP); | ||
563 | |||
569 | spin_lock_irq(¤t->sighand->siglock); | 564 | spin_lock_irq(¤t->sighand->siglock); |
570 | sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask); | 565 | sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask); |
571 | if (!(ka->sa.sa_flags & SA_NODEFER)) | 566 | if (!(ka->sa.sa_flags & SA_NODEFER)) |
diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c index 827179c5b32a..3a76702dc3f1 100644 --- a/arch/x86/kernel/signal_64.c +++ b/arch/x86/kernel/signal_64.c | |||
@@ -289,10 +289,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
289 | see include/asm-x86_64/uaccess.h for details. */ | 289 | see include/asm-x86_64/uaccess.h for details. */ |
290 | set_fs(USER_DS); | 290 | set_fs(USER_DS); |
291 | 291 | ||
292 | regs->flags &= ~(X86_EFLAGS_TF | X86_EFLAGS_DF); | ||
293 | if (test_thread_flag(TIF_SINGLESTEP)) | ||
294 | ptrace_notify(SIGTRAP); | ||
295 | |||
296 | return 0; | 292 | return 0; |
297 | 293 | ||
298 | give_sigsegv: | 294 | give_sigsegv: |
@@ -380,6 +376,21 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
380 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | 376 | ret = setup_rt_frame(sig, ka, info, oldset, regs); |
381 | 377 | ||
382 | if (ret == 0) { | 378 | if (ret == 0) { |
379 | /* | ||
380 | * Clear the direction flag as per the ABI for function entry. | ||
381 | */ | ||
382 | regs->flags &= ~X86_EFLAGS_DF; | ||
383 | |||
384 | /* | ||
385 | * Clear TF when entering the signal handler, but | ||
386 | * notify any tracer that was single-stepping it. | ||
387 | * The tracer may want to single-step inside the | ||
388 | * handler too. | ||
389 | */ | ||
390 | regs->flags &= ~X86_EFLAGS_TF; | ||
391 | if (test_thread_flag(TIF_SINGLESTEP)) | ||
392 | ptrace_notify(SIGTRAP); | ||
393 | |||
383 | spin_lock_irq(¤t->sighand->siglock); | 394 | spin_lock_irq(¤t->sighand->siglock); |
384 | sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); | 395 | sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); |
385 | if (!(ka->sa.sa_flags & SA_NODEFER)) | 396 | if (!(ka->sa.sa_flags & SA_NODEFER)) |