Commit 88e127a8 authored by Paul Mackerras's avatar Paul Mackerras

PPC32: add support for restarting syscalls with ERESTART_RESTARTBLOCK

parent d6162f7e
......@@ -1056,7 +1056,7 @@ SYSCALL(waitpid)
.data
.align 4
_GLOBAL(sys_call_table)
.long sys_ni_syscall /* 0 - old "setup()" system call */
.long sys_restart_syscall /* 0 */
.long sys_exit
.long ppc_fork
.long sys_read
......
......@@ -393,8 +393,12 @@ handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset,
if (TRAP(regs) == 0x0C00 /* System Call! */
&& ((int)regs->result == -ERESTARTNOHAND ||
(int)regs->result == -ERESTART_RESTARTBLOCK ||
((int)regs->result == -ERESTARTSYS &&
!(ka->sa.sa_flags & SA_RESTART)))) {
if ((int)regs->result == -ERESTART_RESTARTBLOCK)
current_thread_info()->restart_block.fn
= do_no_restart_syscall;
regs->result = -EINTR;
regs->gpr[3] = EINTR;
regs->ccr |= 0x10000000;
......@@ -494,13 +498,18 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
handle_signal(signr, &info, oldset, regs, &newsp, frame);
}
if (TRAP(regs) == 0x0C00 /* System Call! */ &&
((int)regs->result == -ERESTARTNOHAND ||
if (TRAP(regs) == 0x0C00) { /* System Call! */
if ((int)regs->result == -ERESTARTNOHAND ||
(int)regs->result == -ERESTARTSYS ||
(int)regs->result == -ERESTARTNOINTR)) {
(int)regs->result == -ERESTARTNOINTR) {
regs->gpr[3] = regs->orig_gpr3;
regs->nip -= 4; /* Back up & retry system call */
regs->result = 0;
} else if ((int)regs->result == -ERESTART_RESTARTBLOCK) {
regs->gpr[0] = __NR_restart_syscall;
regs->nip -= 4;
regs->result = 0;
}
}
if (newsp == frame)
......
......@@ -6,12 +6,6 @@
#undef EDEADLOCK
#define EDEADLOCK 58 /* File locking deadlock error */
/* Should never be seen by user programs */
#define ERESTARTSYS 512
#define ERESTARTNOINTR 513
#define ERESTARTNOHAND 514 /* restart if no handler.. */
#define ENOIOCTLCMD 515 /* No ioctl command */
#define _LAST_ERRNO 515
#define _LAST_ERRNO 516
#endif
......@@ -23,6 +23,7 @@ struct thread_info {
unsigned long flags; /* low level flags */
int cpu; /* cpu we're on */
int preempt_count;
struct restart_block restart_block;
};
#define INIT_THREAD_INFO(tsk) \
......@@ -31,7 +32,10 @@ struct thread_info {
.exec_domain = &default_exec_domain, \
.flags = 0, \
.cpu = 0, \
.preempt_count = 1 \
.preempt_count = 1, \
.restart_block = { \
.fn = do_no_restart_syscall, \
}, \
}
#define init_thread_info (init_thread_union.thread_info)
......@@ -70,8 +74,6 @@ static inline struct thread_info *current_thread_info(void)
#define TI_FLAGS 8
#define TI_CPU 12
#define TI_PREEMPT 16
#define TI_SOFTIRQ 20
#define TI_HARDIRQ 24
#define PREEMPT_ACTIVE 0x4000000
......
......@@ -4,7 +4,7 @@
/*
* This file contains the system call numbers.
*/
#define __NR_restart_syscall 0
#define __NR_exit 1
#define __NR_fork 2
#define __NR_read 3
......
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