Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356714
b: refs/heads/master
c: b30c7d5
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro committed Feb 3, 2013
1 parent c139e9a commit c493af2
Show file tree
Hide file tree
Showing 18 changed files with 474 additions and 96 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 50150d2bb9033de8a4d94b3feb2dfed81a605ed5
refs/heads/master: b30c7d50af95f7450f877e8172a2341785bce5ab
6 changes: 0 additions & 6 deletions trunk/arch/mips/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ config MIPS
select HAVE_MOD_ARCH_SPECIFIC
select MODULES_USE_ELF_REL if MODULES
select MODULES_USE_ELF_RELA if MODULES && 64BIT
select CLONE_BACKWARDS
select GENERIC_SIGALTSTACK
select GENERIC_COMPAT_RT_SIGACTION
select GENERIC_COMPAT_RT_SIGQUEUEINFO
select GENERIC_COMPAT_RT_SIGPROCMASK
select GENERIC_COMPAT_RT_SIGPENDING

menu "Machine selection"

Expand Down
8 changes: 0 additions & 8 deletions trunk/arch/mips/include/asm/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,6 @@ struct compat_shmid64_ds {
compat_ulong_t __unused2;
};

/* MIPS has unusual order of fields in stack_t */
typedef struct compat_sigaltstack {
compat_uptr_t ss_sp;
compat_size_t ss_size;
int ss_flags;
} compat_stack_t;
#define compat_sigaltstack compat_sigaltstack

static inline int is_compat_task(void)
{
return test_thread_flag(TIF_32BIT_ADDR);
Expand Down
24 changes: 12 additions & 12 deletions trunk/arch/mips/include/asm/sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#define save_static_function(symbol) \
__asm__( \
".text\n\t" \
".globl\t__" #symbol "\n\t" \
".globl\t" #symbol "\n\t" \
".align\t2\n\t" \
".type\t__" #symbol ", @function\n\t" \
".ent\t__" #symbol ", 0\n__" \
".type\t" #symbol ", @function\n\t" \
".ent\t" #symbol ", 0\n" \
#symbol":\n\t" \
".frame\t$29, 0, $31\n\t" \
"sw\t$16,"__str(PT_R16)"($29)\t\t\t# save_static_function\n\t" \
Expand All @@ -35,9 +35,9 @@ __asm__( \
"sw\t$22,"__str(PT_R22)"($29)\n\t" \
"sw\t$23,"__str(PT_R23)"($29)\n\t" \
"sw\t$30,"__str(PT_R30)"($29)\n\t" \
"j\t" #symbol "\n\t" \
".end\t__" #symbol "\n\t" \
".size\t__" #symbol",. - __" #symbol)
"j\t_" #symbol "\n\t" \
".end\t" #symbol "\n\t" \
".size\t" #symbol",. - " #symbol)

#define nabi_no_regargs

Expand All @@ -48,10 +48,10 @@ __asm__( \
#define save_static_function(symbol) \
__asm__( \
".text\n\t" \
".globl\t__" #symbol "\n\t" \
".globl\t" #symbol "\n\t" \
".align\t2\n\t" \
".type\t__" #symbol ", @function\n\t" \
".ent\t__" #symbol ", 0\n__" \
".type\t" #symbol ", @function\n\t" \
".ent\t" #symbol ", 0\n" \
#symbol":\n\t" \
".frame\t$29, 0, $31\n\t" \
"sd\t$16,"__str(PT_R16)"($29)\t\t\t# save_static_function\n\t" \
Expand All @@ -63,9 +63,9 @@ __asm__( \
"sd\t$22,"__str(PT_R22)"($29)\n\t" \
"sd\t$23,"__str(PT_R23)"($29)\n\t" \
"sd\t$30,"__str(PT_R30)"($29)\n\t" \
"j\t" #symbol "\n\t" \
".end\t__" #symbol "\n\t" \
".size\t__" #symbol",. - __" #symbol)
"j\t_" #symbol "\n\t" \
".end\t" #symbol "\n\t" \
".size\t" #symbol",. - " #symbol)

#define nabi_no_regargs \
unsigned long __dummy0, \
Expand Down
2 changes: 0 additions & 2 deletions trunk/arch/mips/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
# ifdef CONFIG_MIPS32_O32
# define __ARCH_WANT_COMPAT_SYS_TIME
# endif
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_CLONE

/* whitelists for checksyscalls */
#define __IGNORE_select
Expand Down
44 changes: 44 additions & 0 deletions trunk/arch/mips/kernel/linux32.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ SYSCALL_DEFINE6(32_pwrite, unsigned int, fd, const char __user *, buf,
return sys_pwrite64(fd, buf, count, merge_64(a4, a5));
}

SYSCALL_DEFINE2(32_sched_rr_get_interval, compat_pid_t, pid,
struct compat_timespec __user *, interval)
{
struct timespec t;
int ret;
mm_segment_t old_fs = get_fs();

set_fs(KERNEL_DS);
ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
set_fs(old_fs);
if (put_user (t.tv_sec, &interval->tv_sec) ||
__put_user(t.tv_nsec, &interval->tv_nsec))
return -EFAULT;
return ret;
}

#ifdef CONFIG_SYSVIPC

SYSCALL_DEFINE6(32_ipc, u32, call, long, first, long, second, long, third,
Expand Down Expand Up @@ -279,6 +295,27 @@ asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_a2,
merge_64(len_a4, len_a5));
}

save_static_function(sys32_clone);
static int noinline __used
_sys32_clone(nabi_no_regargs struct pt_regs regs)
{
unsigned long clone_flags;
unsigned long newsp;
int __user *parent_tidptr, *child_tidptr;

clone_flags = regs.regs[4];
newsp = regs.regs[5];
if (!newsp)
newsp = regs.regs[29];
parent_tidptr = (int __user *) regs.regs[6];

/* Use __dummy4 instead of getting it off the stack, so that
syscall() works. */
child_tidptr = (int __user *) __dummy4;
return do_fork(clone_flags, newsp, 0,
parent_tidptr, child_tidptr);
}

asmlinkage long sys32_lookup_dcookie(u32 a0, u32 a1, char __user *buf,
size_t len)
{
Expand All @@ -291,3 +328,10 @@ SYSCALL_DEFINE6(32_fanotify_mark, int, fanotify_fd, unsigned int, flags,
return sys_fanotify_mark(fanotify_fd, flags, merge_64(a3, a4),
dfd, pathname);
}

SYSCALL_DEFINE6(32_futex, u32 __user *, uaddr, int, op, u32, val,
struct compat_timespec __user *, utime, u32 __user *, uaddr2,
u32, val3)
{
return compat_sys_futex(uaddr, op, val, utime, uaddr2, val3);
}
3 changes: 1 addition & 2 deletions trunk/arch/mips/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
*childregs = *regs;
childregs->regs[7] = 0; /* Clear error flag */
childregs->regs[2] = 0; /* Child gets zero as return value */
if (usp)
childregs->regs[29] = usp;
childregs->regs[29] = usp;
ti->addr_limit = USER_DS;

p->thread.reg29 = (unsigned long) childregs;
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/mips/kernel/scall32-o32.S
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ einval: li v0, -ENOSYS
.macro syscalltable
sys sys_syscall 8 /* 4000 */
sys sys_exit 1
sys __sys_fork 0
sys sys_fork 0
sys sys_read 3
sys sys_write 3
sys sys_open 3 /* 4005 */
Expand Down Expand Up @@ -344,7 +344,7 @@ einval: li v0, -ENOSYS
sys sys_ipc 6
sys sys_fsync 1
sys sys_sigreturn 0
sys __sys_clone 6 /* 4120 */
sys sys_clone 0 /* 4120 */
sys sys_setdomainname 2
sys sys_newuname 1
sys sys_ni_syscall 0 /* sys_modify_ldt */
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/mips/kernel/scall64-64.S
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ sys_call_table:
PTR sys_socketpair
PTR sys_setsockopt
PTR sys_getsockopt
PTR __sys_clone /* 5055 */
PTR __sys_fork
PTR sys_clone /* 5055 */
PTR sys_fork
PTR sys_execve
PTR sys_exit
PTR sys_wait4
Expand Down
20 changes: 10 additions & 10 deletions trunk/arch/mips/kernel/scall64-n32.S
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ EXPORT(sysn32_call_table)
PTR sys_mprotect /* 6010 */
PTR sys_munmap
PTR sys_brk
PTR compat_sys_rt_sigaction
PTR compat_sys_rt_sigprocmask
PTR sys_32_rt_sigaction
PTR sys_32_rt_sigprocmask
PTR compat_sys_ioctl /* 6015 */
PTR sys_pread64
PTR sys_pwrite64
Expand Down Expand Up @@ -159,8 +159,8 @@ EXPORT(sysn32_call_table)
PTR sys_socketpair
PTR compat_sys_setsockopt
PTR sys_getsockopt
PTR __sys_clone /* 6055 */
PTR __sys_fork
PTR sys_clone /* 6055 */
PTR sys_fork
PTR compat_sys_execve
PTR sys_exit
PTR compat_sys_wait4
Expand Down Expand Up @@ -229,11 +229,11 @@ EXPORT(sysn32_call_table)
PTR sys_getsid
PTR sys_capget
PTR sys_capset
PTR compat_sys_rt_sigpending /* 6125 */
PTR sys_32_rt_sigpending /* 6125 */
PTR compat_sys_rt_sigtimedwait
PTR compat_sys_rt_sigqueueinfo
PTR compat_sys_rt_sigsuspend
PTR compat_sys_sigaltstack
PTR sys_32_rt_sigqueueinfo
PTR sysn32_rt_sigsuspend
PTR sys32_sigaltstack
PTR compat_sys_utime /* 6130 */
PTR sys_mknod
PTR sys_32_personality
Expand All @@ -249,7 +249,7 @@ EXPORT(sysn32_call_table)
PTR sys_sched_getscheduler
PTR sys_sched_get_priority_max
PTR sys_sched_get_priority_min
PTR compat_sys_sched_rr_get_interval /* 6145 */
PTR sys_32_sched_rr_get_interval /* 6145 */
PTR sys_mlock
PTR sys_munlock
PTR sys_mlockall
Expand Down Expand Up @@ -298,7 +298,7 @@ EXPORT(sysn32_call_table)
PTR sys_fremovexattr
PTR sys_tkill
PTR sys_ni_syscall
PTR compat_sys_futex
PTR sys_32_futex
PTR compat_sys_sched_setaffinity /* 6195 */
PTR compat_sys_sched_getaffinity
PTR sys_cacheflush
Expand Down
22 changes: 11 additions & 11 deletions trunk/arch/mips/kernel/scall64-o32.S
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ einval: li v0, -ENOSYS
sys_call_table:
PTR sys32_syscall /* 4000 */
PTR sys_exit
PTR __sys_fork
PTR sys_fork
PTR sys_read
PTR sys_write
PTR compat_sys_open /* 4005 */
Expand Down Expand Up @@ -312,7 +312,7 @@ sys_call_table:
PTR sys_32_ipc
PTR sys_fsync
PTR sys32_sigreturn
PTR __sys_clone /* 4120 */
PTR sys32_clone /* 4120 */
PTR sys_setdomainname
PTR sys_newuname
PTR sys_ni_syscall /* sys_modify_ldt */
Expand Down Expand Up @@ -357,7 +357,7 @@ sys_call_table:
PTR sys_sched_yield
PTR sys_sched_get_priority_max
PTR sys_sched_get_priority_min
PTR compat_sys_sched_rr_get_interval /* 4165 */
PTR sys_32_sched_rr_get_interval /* 4165 */
PTR compat_sys_nanosleep
PTR sys_mremap
PTR sys_accept
Expand Down Expand Up @@ -386,19 +386,19 @@ sys_call_table:
PTR sys_getresgid
PTR sys_prctl
PTR sys32_rt_sigreturn
PTR compat_sys_rt_sigaction
PTR compat_sys_rt_sigprocmask /* 4195 */
PTR compat_sys_rt_sigpending
PTR sys_32_rt_sigaction
PTR sys_32_rt_sigprocmask /* 4195 */
PTR sys_32_rt_sigpending
PTR compat_sys_rt_sigtimedwait
PTR compat_sys_rt_sigqueueinfo
PTR compat_sys_rt_sigsuspend
PTR sys_32_rt_sigqueueinfo
PTR sys32_rt_sigsuspend
PTR sys_32_pread /* 4200 */
PTR sys_32_pwrite
PTR sys_chown
PTR sys_getcwd
PTR sys_capget
PTR sys_capset /* 4205 */
PTR compat_sys_sigaltstack
PTR sys32_sigaltstack
PTR sys_32_sendfile
PTR sys_ni_syscall
PTR sys_ni_syscall
Expand Down Expand Up @@ -430,7 +430,7 @@ sys_call_table:
PTR sys_fremovexattr /* 4235 */
PTR sys_tkill
PTR sys_sendfile64
PTR compat_sys_futex
PTR sys_32_futex
PTR compat_sys_sched_setaffinity
PTR compat_sys_sched_getaffinity /* 4240 */
PTR compat_sys_io_setup
Expand Down Expand Up @@ -470,7 +470,7 @@ sys_call_table:
PTR compat_sys_mq_notify /* 4275 */
PTR compat_sys_mq_getsetattr
PTR sys_ni_syscall /* sys_vserver */
PTR compat_sys_waitid
PTR sys_32_waitid
PTR sys_ni_syscall /* available, was setaltroot */
PTR sys_add_key /* 4280 */
PTR sys_request_key
Expand Down
44 changes: 39 additions & 5 deletions trunk/arch/mips/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,31 @@ void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
*/

#ifdef CONFIG_TRAD_SIGNALS
SYSCALL_DEFINE1(sigsuspend, sigset_t __user *, uset)
asmlinkage int sys_sigsuspend(nabi_no_regargs struct pt_regs regs)
{
return sys_rt_sigsuspend(uset, sizeof(sigset_t));
sigset_t newset;
sigset_t __user *uset;

uset = (sigset_t __user *) regs.regs[4];
if (copy_from_user(&newset, uset, sizeof(sigset_t)))
return -EFAULT;
return sigsuspend(&newset);
}
#endif

SYSCALL_DEFINE2(rt_sigsuspend, sigset_t __user *,unewset, size_t, sigsetsize)
{
sigset_t newset;

/* XXX Don't preclude handling different sized sigset_t's. */
if (sigsetsize != sizeof(sigset_t))
return -EINVAL;

if (copy_from_user(&newset, unewset, sizeof(newset)))
return -EFAULT;
return sigsuspend(&newset);
}

#ifdef CONFIG_TRAD_SIGNALS
SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
struct sigaction __user *, oact)
Expand Down Expand Up @@ -294,6 +313,15 @@ SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
}
#endif

asmlinkage int sys_sigaltstack(nabi_no_regargs struct pt_regs regs)
{
const stack_t __user *uss = (const stack_t __user *) regs.regs[4];
stack_t __user *uoss = (stack_t __user *) regs.regs[5];
unsigned long usp = regs.regs[29];

return do_sigaltstack(uss, uoss, usp);
}

#ifdef CONFIG_TRAD_SIGNALS
asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs)
{
Expand Down Expand Up @@ -350,8 +378,9 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
else if (sig)
force_sig(sig, current);

if (restore_altstack(&frame->rs_uc.uc_stack))
goto badframe;
/* It is more difficult to avoid calling this function than to
call it and ignore errors. */
do_sigaltstack(&frame->rs_uc.uc_stack, NULL, regs.regs[29]);

/*
* Don't let your children do this ...
Expand Down Expand Up @@ -428,7 +457,12 @@ static int setup_rt_frame(void *sig_return, struct k_sigaction *ka,
/* Create the ucontext. */
err |= __put_user(0, &frame->rs_uc.uc_flags);
err |= __put_user(NULL, &frame->rs_uc.uc_link);
err |= __save_altstack(&frame->rs_uc.uc_stack, regs->regs[29]);
err |= __put_user((void __user *)current->sas_ss_sp,
&frame->rs_uc.uc_stack.ss_sp);
err |= __put_user(sas_ss_flags(regs->regs[29]),
&frame->rs_uc.uc_stack.ss_flags);
err |= __put_user(current->sas_ss_size,
&frame->rs_uc.uc_stack.ss_size);
err |= setup_sigcontext(regs, &frame->rs_uc.uc_mcontext);
err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));

Expand Down
Loading

0 comments on commit c493af2

Please sign in to comment.