Commit 03f07876 authored by Paul Mundt's avatar Paul Mundt

sh: Fix up spurious syscall restarting.

The T-bit manipulation for syscall error checking had the side effect of
spuriously returning ERESTART* errno values over EINTR. So, we simplify
the error checking a bit and leave the T-bit alone.
Reported-by: default avatarKaz Kojima <kkojima@rr.iij4u.or.jp>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 0f6dee23
...@@ -21,23 +21,10 @@ static inline void syscall_rollback(struct task_struct *task, ...@@ -21,23 +21,10 @@ static inline void syscall_rollback(struct task_struct *task,
*/ */
} }
static inline bool syscall_has_error(struct pt_regs *regs)
{
return (regs->sr & 0x1) ? true : false;
}
static inline void syscall_set_error(struct pt_regs *regs)
{
regs->sr |= 0x1;
}
static inline void syscall_clear_error(struct pt_regs *regs)
{
regs->sr &= ~0x1;
}
static inline long syscall_get_error(struct task_struct *task, static inline long syscall_get_error(struct task_struct *task,
struct pt_regs *regs) struct pt_regs *regs)
{ {
return syscall_has_error(regs) ? regs->regs[0] : 0; return IS_ERR_VALUE(regs->regs[0]) ? regs->regs[0] : 0;
} }
static inline long syscall_get_return_value(struct task_struct *task, static inline long syscall_get_return_value(struct task_struct *task,
...@@ -50,13 +37,10 @@ static inline void syscall_set_return_value(struct task_struct *task, ...@@ -50,13 +37,10 @@ static inline void syscall_set_return_value(struct task_struct *task,
struct pt_regs *regs, struct pt_regs *regs,
int error, long val) int error, long val)
{ {
if (error) { if (error)
syscall_set_error(regs);
regs->regs[0] = -error; regs->regs[0] = -error;
} else { else
syscall_clear_error(regs);
regs->regs[0] = val; regs->regs[0] = val;
}
} }
static inline void syscall_get_arguments(struct task_struct *task, static inline void syscall_get_arguments(struct task_struct *task,
......
...@@ -21,23 +21,10 @@ static inline void syscall_rollback(struct task_struct *task, ...@@ -21,23 +21,10 @@ static inline void syscall_rollback(struct task_struct *task,
*/ */
} }
static inline bool syscall_has_error(struct pt_regs *regs)
{
return (regs->sr & 0x1) ? true : false;
}
static inline void syscall_set_error(struct pt_regs *regs)
{
regs->sr |= 0x1;
}
static inline void syscall_clear_error(struct pt_regs *regs)
{
regs->sr &= ~0x1;
}
static inline long syscall_get_error(struct task_struct *task, static inline long syscall_get_error(struct task_struct *task,
struct pt_regs *regs) struct pt_regs *regs)
{ {
return syscall_has_error(regs) ? regs->regs[9] : 0; return IS_ERR_VALUE(regs->regs[9]) ? regs->regs[9] : 0;
} }
static inline long syscall_get_return_value(struct task_struct *task, static inline long syscall_get_return_value(struct task_struct *task,
...@@ -50,13 +37,10 @@ static inline void syscall_set_return_value(struct task_struct *task, ...@@ -50,13 +37,10 @@ static inline void syscall_set_return_value(struct task_struct *task,
struct pt_regs *regs, struct pt_regs *regs,
int error, long val) int error, long val)
{ {
if (error) { if (error)
syscall_set_error(regs);
regs->regs[9] = -error; regs->regs[9] = -error;
} else { else
syscall_clear_error(regs);
regs->regs[9] = val; regs->regs[9] = val;
}
} }
static inline void syscall_get_arguments(struct task_struct *task, static inline void syscall_get_arguments(struct task_struct *task,
......
...@@ -510,7 +510,6 @@ handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs, ...@@ -510,7 +510,6 @@ handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs,
case -ERESTARTNOHAND: case -ERESTARTNOHAND:
no_system_call_restart: no_system_call_restart:
regs->regs[0] = -EINTR; regs->regs[0] = -EINTR;
regs->sr |= 1;
break; break;
case -ERESTARTSYS: case -ERESTARTSYS:
...@@ -589,8 +588,7 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0) ...@@ -589,8 +588,7 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
if (regs->sr & 1) handle_syscall_restart(save_r0, regs, &ka.sa);
handle_syscall_restart(save_r0, regs, &ka.sa);
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(signr, &ka, &info, oldset, if (handle_signal(signr, &ka, &info, oldset,
......
...@@ -60,7 +60,6 @@ handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) ...@@ -60,7 +60,6 @@ handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa)
case -ERESTARTNOHAND: case -ERESTARTNOHAND:
no_system_call_restart: no_system_call_restart:
regs->regs[REG_RET] = -EINTR; regs->regs[REG_RET] = -EINTR;
regs->sr |= 1;
break; break;
case -ERESTARTSYS: case -ERESTARTSYS:
...@@ -109,8 +108,7 @@ static int do_signal(struct pt_regs *regs, sigset_t *oldset) ...@@ -109,8 +108,7 @@ static int do_signal(struct pt_regs *regs, sigset_t *oldset)
signr = get_signal_to_deliver(&info, &ka, regs, 0); signr = get_signal_to_deliver(&info, &ka, regs, 0);
if (signr > 0) { if (signr > 0) {
if (regs->sr & 1) handle_syscall_restart(regs, &ka.sa);
handle_syscall_restart(regs, &ka.sa);
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment