* [PATCH 0/5] x86: signal works for unification
@ 2008-09-05 23:22 Hiroshi Shimamoto
2008-09-05 23:26 ` [PATCH 1/5] x86_32: signal: use syscall_get_nr and error Hiroshi Shimamoto
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Hiroshi Shimamoto @ 2008-09-05 23:22 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel
Hi,
this patch series is for future unification of signal.c.
These patches make common functions similar in signal_32|64.c.
Could you please review them?
thanks,
Hiroshi Shimamoto
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] x86_32: signal: use syscall_get_nr and error
2008-09-05 23:22 [PATCH 0/5] x86: signal works for unification Hiroshi Shimamoto
@ 2008-09-05 23:26 ` Hiroshi Shimamoto
2008-09-05 23:27 ` [PATCH 2/5] x86_32: signal: introduce signal_fault() Hiroshi Shimamoto
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Hiroshi Shimamoto @ 2008-09-05 23:26 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Use asm/syscall.h interfaces that do the same things.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
arch/x86/kernel/signal_32.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index b21070e..3e4a688 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -27,6 +27,7 @@
#include <asm/uaccess.h>
#include <asm/i387.h>
#include <asm/vdso.h>
+#include <asm/syscall.h>
#include <asm/syscalls.h>
#include "sigframe.h"
@@ -507,9 +508,9 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
int ret;
/* Are we from a system call? */
- if ((long)regs->orig_ax >= 0) {
+ if (syscall_get_nr(current, regs) >= 0) {
/* If so, check system call restarting.. */
- switch (regs->ax) {
+ switch (syscall_get_error(current, regs)) {
case -ERESTART_RESTARTBLOCK:
case -ERESTARTNOHAND:
regs->ax = -EINTR;
@@ -623,9 +624,9 @@ static void do_signal(struct pt_regs *regs)
}
/* Did we come from a system call? */
- if ((long)regs->orig_ax >= 0) {
+ if (syscall_get_nr(current, regs) >= 0) {
/* Restart the system call - no handlers present */
- switch (regs->ax) {
+ switch (syscall_get_error(current, regs)) {
case -ERESTARTNOHAND:
case -ERESTARTSYS:
case -ERESTARTNOINTR:
--
1.5.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] x86_32: signal: introduce signal_fault()
2008-09-05 23:22 [PATCH 0/5] x86: signal works for unification Hiroshi Shimamoto
2008-09-05 23:26 ` [PATCH 1/5] x86_32: signal: use syscall_get_nr and error Hiroshi Shimamoto
@ 2008-09-05 23:27 ` Hiroshi Shimamoto
2008-09-05 23:27 ` [PATCH 3/5] x86: signal: make NR_restart_syscall Hiroshi Shimamoto
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Hiroshi Shimamoto @ 2008-09-05 23:27 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
implement signal_fault() for 32bit.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
arch/x86/kernel/signal_32.c | 18 +++++++++++++++++-
include/asm-x86/ptrace.h | 4 ++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index 3e4a688..76d05d7 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -243,7 +243,7 @@ asmlinkage int sys_rt_sigreturn(unsigned long __unused)
return ax;
badframe:
- force_sig(SIGSEGV, current);
+ signal_fault(regs, frame, "rt sigreturn");
return 0;
}
@@ -669,3 +669,19 @@ do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
clear_thread_flag(TIF_IRET);
}
+
+void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
+{
+ struct task_struct *me = current;
+
+ if (show_unhandled_signals && printk_ratelimit()) {
+ printk(KERN_INFO
+ "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx",
+ me->comm, me->pid, where, frame,
+ regs->ip, regs->sp, regs->orig_ax);
+ print_vma_addr(" in ", regs->ip);
+ printk(KERN_CONT "\n");
+ }
+
+ force_sig(SIGSEGV, me);
+}
diff --git a/include/asm-x86/ptrace.h b/include/asm-x86/ptrace.h
index d64a610..4dfce55 100644
--- a/include/asm-x86/ptrace.h
+++ b/include/asm-x86/ptrace.h
@@ -178,10 +178,10 @@ convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
#ifdef CONFIG_X86_32
extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
int error_code);
-#else
-void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
#endif
+void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
+
extern long syscall_trace_enter(struct pt_regs *);
extern void syscall_trace_leave(struct pt_regs *);
--
1.5.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] x86: signal: make NR_restart_syscall
2008-09-05 23:22 [PATCH 0/5] x86: signal works for unification Hiroshi Shimamoto
2008-09-05 23:26 ` [PATCH 1/5] x86_32: signal: use syscall_get_nr and error Hiroshi Shimamoto
2008-09-05 23:27 ` [PATCH 2/5] x86_32: signal: introduce signal_fault() Hiroshi Shimamoto
@ 2008-09-05 23:27 ` Hiroshi Shimamoto
2008-09-05 23:28 ` [PATCH 4/5] x86: signal: split out frame setups Hiroshi Shimamoto
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Hiroshi Shimamoto @ 2008-09-05 23:27 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
make NR_restart_syscall macro for cosmetic unification of handle_signal().
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
arch/x86/kernel/signal_32.c | 3 ++-
arch/x86/kernel/signal_64.c | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index 76d05d7..bd9b650 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -572,6 +572,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
return 0;
}
+#define NR_restart_syscall __NR_restart_syscall
/*
* Note that 'init' is a special process: it doesn't get signals it doesn't
* want to handle. Thus you cannot kill init even with a SIGKILL even by
@@ -635,7 +636,7 @@ static void do_signal(struct pt_regs *regs)
break;
case -ERESTART_RESTARTBLOCK:
- regs->ax = __NR_restart_syscall;
+ regs->ax = NR_restart_syscall;
regs->ip -= 2;
break;
}
diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c
index 823a55b..19e2b91 100644
--- a/arch/x86/kernel/signal_64.c
+++ b/arch/x86/kernel/signal_64.c
@@ -362,6 +362,8 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
return ret;
}
+#define NR_restart_syscall \
+ test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall
/*
* Note that 'init' is a special process: it doesn't get signals it doesn't
* want to handle. Thus you cannot kill init even with a SIGKILL even by
@@ -423,9 +425,7 @@ static void do_signal(struct pt_regs *regs)
regs->ip -= 2;
break;
case -ERESTART_RESTARTBLOCK:
- regs->ax = test_thread_flag(TIF_IA32) ?
- __NR_ia32_restart_syscall :
- __NR_restart_syscall;
+ regs->ax = NR_restart_syscall;
regs->ip -= 2;
break;
}
--
1.5.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] x86: signal: split out frame setups
2008-09-05 23:22 [PATCH 0/5] x86: signal works for unification Hiroshi Shimamoto
` (2 preceding siblings ...)
2008-09-05 23:27 ` [PATCH 3/5] x86: signal: make NR_restart_syscall Hiroshi Shimamoto
@ 2008-09-05 23:28 ` Hiroshi Shimamoto
2008-09-05 23:28 ` [PATCH 5/5] x86_32: signal: move signal number conversion to upper layer Hiroshi Shimamoto
2008-09-06 12:56 ` [PATCH 0/5] x86: signal works for unification Ingo Molnar
5 siblings, 0 replies; 7+ messages in thread
From: Hiroshi Shimamoto @ 2008-09-05 23:28 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Make setup_rt_frame() and split out frame setups from handle_signal().
This is for cosmetic unification of handle_signal().
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
arch/x86/kernel/signal_32.c | 29 ++++++++++++++++++++---------
arch/x86/kernel/signal_64.c | 30 ++++++++++++++++++++----------
2 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index bd9b650..48982f7 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -338,8 +338,8 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
}
static int
-setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
- struct pt_regs *regs)
+__setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
+ struct pt_regs *regs)
{
struct sigframe __user *frame;
void __user *restorer;
@@ -416,8 +416,8 @@ give_sigsegv:
return -EFAULT;
}
-static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
- sigset_t *set, struct pt_regs *regs)
+static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
+ sigset_t *set, struct pt_regs *regs)
{
struct rt_sigframe __user *frame;
void __user *restorer;
@@ -502,6 +502,21 @@ give_sigsegv:
* OK, we're invoking a handler:
*/
static int
+setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
+ sigset_t *set, struct pt_regs *regs)
+{
+ int ret;
+
+ /* Set up the stack frame */
+ if (ka->sa.sa_flags & SA_SIGINFO)
+ ret = __setup_rt_frame(sig, ka, info, set, regs);
+ else
+ ret = __setup_frame(sig, ka, set, regs);
+
+ return ret;
+}
+
+static int
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs)
{
@@ -537,11 +552,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
regs->flags &= ~X86_EFLAGS_TF;
- /* Set up the stack frame */
- if (ka->sa.sa_flags & SA_SIGINFO)
- ret = setup_rt_frame(sig, ka, info, oldset, regs);
- else
- ret = setup_frame(sig, ka, oldset, regs);
+ ret = setup_rt_frame(sig, ka, info, oldset, regs);
if (ret)
return ret;
diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c
index 19e2b91..8fbdd23 100644
--- a/arch/x86/kernel/signal_64.c
+++ b/arch/x86/kernel/signal_64.c
@@ -195,8 +195,8 @@ get_stack(struct k_sigaction *ka, struct pt_regs *regs, unsigned long size)
return (void __user *)round_down(sp - size, 64);
}
-static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
- sigset_t *set, struct pt_regs *regs)
+static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
+ sigset_t *set, struct pt_regs *regs)
{
struct rt_sigframe __user *frame;
void __user *fp = NULL;
@@ -280,6 +280,24 @@ give_sigsegv:
/*
* OK, we're invoking a handler
*/
+static int
+setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
+ sigset_t *set, struct pt_regs *regs)
+{
+ int ret;
+
+#ifdef CONFIG_IA32_EMULATION
+ if (test_thread_flag(TIF_IA32)) {
+ if (ka->sa.sa_flags & SA_SIGINFO)
+ ret = ia32_setup_rt_frame(sig, ka, info, set, regs);
+ else
+ ret = ia32_setup_frame(sig, ka, set, regs);
+ } else
+#endif
+ ret = __setup_rt_frame(sig, ka, info, set, regs);
+
+ return ret;
+}
static int
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
@@ -317,14 +335,6 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
regs->flags &= ~X86_EFLAGS_TF;
-#ifdef CONFIG_IA32_EMULATION
- if (test_thread_flag(TIF_IA32)) {
- if (ka->sa.sa_flags & SA_SIGINFO)
- ret = ia32_setup_rt_frame(sig, ka, info, oldset, regs);
- else
- ret = ia32_setup_frame(sig, ka, oldset, regs);
- } else
-#endif
ret = setup_rt_frame(sig, ka, info, oldset, regs);
if (ret == 0) {
--
1.5.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] x86_32: signal: move signal number conversion to upper layer
2008-09-05 23:22 [PATCH 0/5] x86: signal works for unification Hiroshi Shimamoto
` (3 preceding siblings ...)
2008-09-05 23:28 ` [PATCH 4/5] x86: signal: split out frame setups Hiroshi Shimamoto
@ 2008-09-05 23:28 ` Hiroshi Shimamoto
2008-09-06 12:56 ` [PATCH 0/5] x86: signal works for unification Ingo Molnar
5 siblings, 0 replies; 7+ messages in thread
From: Hiroshi Shimamoto @ 2008-09-05 23:28 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Bring signal number conversion in __setup_frame() and __setup_rt_frame()
up into the common part setup_frame().
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
arch/x86/kernel/signal_32.c | 31 ++++++++++++-------------------
1 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index 48982f7..b668efc 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -344,7 +344,6 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
struct sigframe __user *frame;
void __user *restorer;
int err = 0;
- int usig;
void __user *fpstate = NULL;
frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
@@ -352,13 +351,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto give_sigsegv;
- usig = current_thread_info()->exec_domain
- && current_thread_info()->exec_domain->signal_invmap
- && sig < 32
- ? current_thread_info()->exec_domain->signal_invmap[sig]
- : sig;
-
- err = __put_user(usig, &frame->sig);
+ err = __put_user(sig, &frame->sig);
if (err)
goto give_sigsegv;
@@ -422,7 +415,6 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
struct rt_sigframe __user *frame;
void __user *restorer;
int err = 0;
- int usig;
void __user *fpstate = NULL;
frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
@@ -430,13 +422,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto give_sigsegv;
- usig = current_thread_info()->exec_domain
- && current_thread_info()->exec_domain->signal_invmap
- && sig < 32
- ? current_thread_info()->exec_domain->signal_invmap[sig]
- : sig;
-
- err |= __put_user(usig, &frame->sig);
+ err |= __put_user(sig, &frame->sig);
err |= __put_user(&frame->info, &frame->pinfo);
err |= __put_user(&frame->uc, &frame->puc);
err |= copy_siginfo_to_user(&frame->info, info);
@@ -482,7 +468,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
/* Set up registers for signal handler */
regs->sp = (unsigned long)frame;
regs->ip = (unsigned long)ka->sa.sa_handler;
- regs->ax = (unsigned long)usig;
+ regs->ax = (unsigned long)sig;
regs->dx = (unsigned long)&frame->info;
regs->cx = (unsigned long)&frame->uc;
@@ -506,12 +492,19 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *set, struct pt_regs *regs)
{
int ret;
+ int usig;
+
+ usig = current_thread_info()->exec_domain
+ && current_thread_info()->exec_domain->signal_invmap
+ && sig < 32
+ ? current_thread_info()->exec_domain->signal_invmap[sig]
+ : sig;
/* Set up the stack frame */
if (ka->sa.sa_flags & SA_SIGINFO)
- ret = __setup_rt_frame(sig, ka, info, set, regs);
+ ret = __setup_rt_frame(usig, ka, info, set, regs);
else
- ret = __setup_frame(sig, ka, set, regs);
+ ret = __setup_frame(usig, ka, set, regs);
return ret;
}
--
1.5.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/5] x86: signal works for unification
2008-09-05 23:22 [PATCH 0/5] x86: signal works for unification Hiroshi Shimamoto
` (4 preceding siblings ...)
2008-09-05 23:28 ` [PATCH 5/5] x86_32: signal: move signal number conversion to upper layer Hiroshi Shimamoto
@ 2008-09-06 12:56 ` Ingo Molnar
5 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2008-09-06 12:56 UTC (permalink / raw)
To: Hiroshi Shimamoto
Cc: Thomas Gleixner, H. Peter Anvin, linux-kernel, Roland McGrath
* Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> wrote:
> Hi,
>
> this patch series is for future unification of signal.c.
> These patches make common functions similar in signal_32|64.c.
>
> Could you please review them?
looks good to me - it's fairly safely structured and also in small,
single-purpose steps. If there's a problem with them bisection should
give a very good clue about exactly where.
So i've created a new tip/x86/signal topic for them and applied them -
lets see how it goes. Thanks,
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-09-06 12:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-05 23:22 [PATCH 0/5] x86: signal works for unification Hiroshi Shimamoto
2008-09-05 23:26 ` [PATCH 1/5] x86_32: signal: use syscall_get_nr and error Hiroshi Shimamoto
2008-09-05 23:27 ` [PATCH 2/5] x86_32: signal: introduce signal_fault() Hiroshi Shimamoto
2008-09-05 23:27 ` [PATCH 3/5] x86: signal: make NR_restart_syscall Hiroshi Shimamoto
2008-09-05 23:28 ` [PATCH 4/5] x86: signal: split out frame setups Hiroshi Shimamoto
2008-09-05 23:28 ` [PATCH 5/5] x86_32: signal: move signal number conversion to upper layer Hiroshi Shimamoto
2008-09-06 12:56 ` [PATCH 0/5] x86: signal works for unification Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox