From 995218555433b260b58059802e1c01f35b4cd860 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Oct 2012 22:45:24 -0400 Subject: hexagon: kernel_thread()/kernel_execve() conversion introduce sane current_pt_regs(), use it in syscalls where needed. Signed-off-by: Al Viro --- arch/hexagon/include/asm/processor.h | 1 - arch/hexagon/include/asm/ptrace.h | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'arch/hexagon/include') diff --git a/arch/hexagon/include/asm/processor.h b/arch/hexagon/include/asm/processor.h index e8ea459002a4..8483b49de036 100644 --- a/arch/hexagon/include/asm/processor.h +++ b/arch/hexagon/include/asm/processor.h @@ -34,7 +34,6 @@ struct task_struct; /* this is defined in arch/process.c */ -extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); extern unsigned long thread_saved_pc(struct task_struct *tsk); extern void start_thread(struct pt_regs *, unsigned long, unsigned long); diff --git a/arch/hexagon/include/asm/ptrace.h b/arch/hexagon/include/asm/ptrace.h index 3d2f607cd63c..7e1e3745cb8a 100644 --- a/arch/hexagon/include/asm/ptrace.h +++ b/arch/hexagon/include/asm/ptrace.h @@ -32,4 +32,8 @@ extern int regs_query_register_offset(const char *name); extern const char *regs_query_register_name(unsigned int offset); +#define current_pt_regs() \ + ((struct pt_regs *) \ + ((unsigned long)current_thread_info() + THREAD_SIZE) - 1) + #endif -- cgit v1.2.3 From 27aedbd52fb78bbead55c81a8dd906afd405c3fc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Oct 2012 22:48:18 -0400 Subject: hexagon: switch to generic sys_execve() Signed-off-by: Al Viro --- arch/hexagon/include/asm/unistd.h | 1 + arch/hexagon/kernel/syscall.c | 19 ------------------- 2 files changed, 1 insertion(+), 19 deletions(-) (limited to 'arch/hexagon/include') diff --git a/arch/hexagon/include/asm/unistd.h b/arch/hexagon/include/asm/unistd.h index c0d5565030ae..acbd5adc9814 100644 --- a/arch/hexagon/include/asm/unistd.h +++ b/arch/hexagon/include/asm/unistd.h @@ -27,5 +27,6 @@ */ #define sys_mmap2 sys_mmap_pgoff +#define __ARCH_WANT_SYS_EXECVE #include diff --git a/arch/hexagon/kernel/syscall.c b/arch/hexagon/kernel/syscall.c index 120f1a5e9f3d..e28f4e5a6a7a 100644 --- a/arch/hexagon/kernel/syscall.c +++ b/arch/hexagon/kernel/syscall.c @@ -35,25 +35,6 @@ * See signal.c for signal-related system call wrappers. */ -asmlinkage int sys_execve(char __user *ufilename, - const char __user *const __user *argv, - const char __user *const __user *envp) -{ - struct pt_regs *pregs = current_pt_regs(); - struct filename *filename; - int retval; - - filename = getname(ufilename); - retval = PTR_ERR(filename); - if (IS_ERR(filename)) - return retval; - - retval = do_execve(filename->name, argv, envp, pregs); - putname(filename); - - return retval; -} - asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, unsigned long parent_tidp, unsigned long child_tidp) { -- cgit v1.2.3 From 6b94631f9e8c45a46056cbc6a7a50ecebea4f8da Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 20 Oct 2012 13:32:30 -0400 Subject: consolidate sys_execve() prototype Signed-off-by: Al Viro --- arch/hexagon/include/asm/syscall.h | 3 --- arch/tile/include/asm/syscalls.h | 4 ---- arch/x86/include/asm/syscalls.h | 3 --- arch/xtensa/include/asm/syscall.h | 1 - include/asm-generic/syscalls.h | 7 ------- include/linux/syscalls.h | 3 +++ 6 files changed, 3 insertions(+), 18 deletions(-) (limited to 'arch/hexagon/include') diff --git a/arch/hexagon/include/asm/syscall.h b/arch/hexagon/include/asm/syscall.h index fb0e9d48faa6..ec2ce6792cd6 100644 --- a/arch/hexagon/include/asm/syscall.h +++ b/arch/hexagon/include/asm/syscall.h @@ -25,12 +25,9 @@ typedef long (*syscall_fn)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); -asmlinkage int sys_execve(char __user *ufilename, char __user * __user *argv, - char __user * __user *envp); asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, unsigned long parent_tidp, unsigned long child_tidp); -#define sys_execve sys_execve #define sys_clone sys_clone #include diff --git a/arch/tile/include/asm/syscalls.h b/arch/tile/include/asm/syscalls.h index 369696d63e7b..394c76f2dc76 100644 --- a/arch/tile/include/asm/syscalls.h +++ b/arch/tile/include/asm/syscalls.h @@ -65,13 +65,9 @@ long sys_ftruncate64(unsigned int fd, loff_t length); /* Provide versions of standard syscalls that use current_pt_regs(). */ long sys_clone(unsigned long clone_flags, unsigned long newsp, void __user *parent_tid, void __user *child_tid); -long sys_execve(const char __user *filename, - const char __user *const __user *argv, - const char __user *const __user *envp); long sys_rt_sigreturn(void); long sys_sigaltstack(const stack_t __user *, stack_t __user *); #define sys_clone sys_clone -#define sys_execve sys_execve #define sys_rt_sigreturn sys_rt_sigreturn #define sys_sigaltstack sys_sigaltstack diff --git a/arch/x86/include/asm/syscalls.h b/arch/x86/include/asm/syscalls.h index 2be0b880417e..9e5aef3a2598 100644 --- a/arch/x86/include/asm/syscalls.h +++ b/arch/x86/include/asm/syscalls.h @@ -23,9 +23,6 @@ long sys_iopl(unsigned int, struct pt_regs *); /* kernel/process.c */ int sys_fork(struct pt_regs *); int sys_vfork(struct pt_regs *); -long sys_execve(const char __user *, - const char __user *const __user *, - const char __user *const __user *); long sys_clone(unsigned long, unsigned long, void __user *, void __user *, struct pt_regs *); diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/syscall.h index 124aeee0d381..4e27d76c9612 100644 --- a/arch/xtensa/include/asm/syscall.h +++ b/arch/xtensa/include/asm/syscall.h @@ -10,7 +10,6 @@ struct pt_regs; struct sigaction; -asmlinkage long sys_execve(char*, char**, char**, struct pt_regs*); asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*); asmlinkage long xtensa_ptrace(long, long, long, long); asmlinkage long xtensa_sigreturn(struct pt_regs*); diff --git a/include/asm-generic/syscalls.h b/include/asm-generic/syscalls.h index 7e4fdb649951..77960333b1a1 100644 --- a/include/asm-generic/syscalls.h +++ b/include/asm-generic/syscalls.h @@ -21,13 +21,6 @@ asmlinkage long sys_fork(void); asmlinkage long sys_vfork(void); #endif -#ifndef sys_execve -asmlinkage long sys_execve(const char __user *filename, - const char __user *const __user *argv, - const char __user *const __user *envp, - struct pt_regs *regs); -#endif - #ifndef sys_mmap2 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 727f0cd73921..2779009ceaa3 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -837,6 +837,9 @@ int kernel_execve(const char *filename, const char *const argv[], const char *co current_pt_regs()) #endif +asmlinkage long sys_execve(const char __user *filename, + const char __user *const __user *argv, + const char __user *const __user *envp); asmlinkage long sys_perf_event_open( struct perf_event_attr __user *attr_uptr, -- cgit v1.2.3 From f01aceac61ad5cc9ea463f6bb185c1f72702357f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 26 Oct 2012 19:25:46 -0400 Subject: hexagon: switch to generic clone() Signed-off-by: Al Viro --- arch/hexagon/include/uapi/asm/unistd.h | 1 + arch/hexagon/kernel/Makefile | 3 +-- arch/hexagon/kernel/process.c | 7 ++--- arch/hexagon/kernel/syscall.c | 47 ---------------------------------- 4 files changed, 6 insertions(+), 52 deletions(-) delete mode 100644 arch/hexagon/kernel/syscall.c (limited to 'arch/hexagon/include') diff --git a/arch/hexagon/include/uapi/asm/unistd.h b/arch/hexagon/include/uapi/asm/unistd.h index 26b2e0f909c8..2af81533bd0f 100644 --- a/arch/hexagon/include/uapi/asm/unistd.h +++ b/arch/hexagon/include/uapi/asm/unistd.h @@ -28,5 +28,6 @@ #define sys_mmap2 sys_mmap_pgoff #define __ARCH_WANT_SYS_EXECVE +#define __ARCH_WANT_SYS_CLONE #include diff --git a/arch/hexagon/kernel/Makefile b/arch/hexagon/kernel/Makefile index 536aec093e62..6c19501b487c 100644 --- a/arch/hexagon/kernel/Makefile +++ b/arch/hexagon/kernel/Makefile @@ -3,8 +3,7 @@ extra-y := head.o vmlinux.lds obj-$(CONFIG_SMP) += smp.o topology.o obj-y += setup.o irq_cpu.o traps.o syscalltab.o signal.o time.o -obj-y += process.o syscall.o trampoline.o reset.o ptrace.o -obj-y += vdso.o +obj-y += process.o trampoline.o reset.o ptrace.o vdso.o obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_MODULES) += module.o hexagon_ksyms.o diff --git a/arch/hexagon/kernel/process.c b/arch/hexagon/kernel/process.c index cfbc52bd5227..36dce17ed25c 100644 --- a/arch/hexagon/kernel/process.c +++ b/arch/hexagon/kernel/process.c @@ -88,7 +88,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk) */ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg, struct task_struct *p, - struct pt_regs *regs) + struct pt_regs *unused) { struct thread_info *ti = task_thread_info(p); struct hexagon_switch_stack *ss; @@ -117,10 +117,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, pt_set_kmode(childregs); return 0; } - memcpy(childregs, regs, sizeof(*childregs)); + memcpy(childregs, current_pt_regs(), sizeof(*childregs)); ss->r2524 = 0; - pt_set_rte_sp(childregs, usp); + if (usp) + pt_set_rte_sp(childregs, usp); /* Child sees zero return value */ childregs->r00 = 0; diff --git a/arch/hexagon/kernel/syscall.c b/arch/hexagon/kernel/syscall.c deleted file mode 100644 index d2cc3270af3e..000000000000 --- a/arch/hexagon/kernel/syscall.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Hexagon system calls - * - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * System calls with architecture-specific wrappers. - * See signal.c for signal-related system call wrappers. - */ - -asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, - unsigned long parent_tidp, unsigned long child_tidp) -{ - struct pt_regs *pregs = current_pt_regs(); - - if (!newsp) - newsp = pregs->SP; - return do_fork(clone_flags, newsp, pregs, 0, (int __user *)parent_tidp, - (int __user *)child_tidp); -} -- cgit v1.2.3 From 24465a40ba452bd81fdc9eecb2d75bb903aafdf6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 28 Nov 2012 23:04:26 -0500 Subject: take sys_fork/sys_vfork/sys_clone prototypes to linux/syscalls.h now it can be done... Signed-off-by: Al Viro --- arch/arm64/include/asm/syscalls.h | 8 -------- arch/hexagon/include/asm/syscall.h | 5 ----- arch/microblaze/include/asm/Kbuild | 1 + arch/microblaze/include/asm/syscalls.h | 16 ---------------- arch/s390/kernel/entry.h | 4 ---- arch/tile/include/asm/syscalls.h | 3 --- arch/tile/kernel/compat.c | 1 - arch/tile/kernel/sys.c | 1 - arch/x86/include/asm/syscalls.h | 11 ----------- arch/x86/um/shared/sysdep/syscalls.h | 2 -- include/asm-generic/syscalls.h | 12 ------------ include/linux/syscalls.h | 10 ++++++++++ 12 files changed, 11 insertions(+), 63 deletions(-) delete mode 100644 arch/microblaze/include/asm/syscalls.h (limited to 'arch/hexagon/include') diff --git a/arch/arm64/include/asm/syscalls.h b/arch/arm64/include/asm/syscalls.h index 010ec127dc5b..20d63b290665 100644 --- a/arch/arm64/include/asm/syscalls.h +++ b/arch/arm64/include/asm/syscalls.h @@ -27,14 +27,6 @@ asmlinkage long sys_rt_sigreturn_wrapper(void); asmlinkage long sys_sigaltstack_wrapper(const stack_t __user *uss, stack_t __user *uoss); -/* - * AArch64 sys_clone implementation has a different prototype than the generic - * one (additional TLS value argument). - */ -asmlinkage long sys_clone(unsigned long, unsigned long, void __user *, int, - void __user *); -#define sys_clone sys_clone - #include #endif /* __ASM_SYSCALLS_H */ diff --git a/arch/hexagon/include/asm/syscall.h b/arch/hexagon/include/asm/syscall.h index ec2ce6792cd6..4af9c7b6f13a 100644 --- a/arch/hexagon/include/asm/syscall.h +++ b/arch/hexagon/include/asm/syscall.h @@ -25,11 +25,6 @@ typedef long (*syscall_fn)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); -asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, - unsigned long parent_tidp, unsigned long child_tidp); - -#define sys_clone sys_clone - #include extern void *sys_call_table[]; diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild index 8653072d7e9f..88a758a67922 100644 --- a/arch/microblaze/include/asm/Kbuild +++ b/arch/microblaze/include/asm/Kbuild @@ -3,3 +3,4 @@ include include/asm-generic/Kbuild.asm header-y += elf.h generic-y += clkdev.h generic-y += exec.h +generic-y += syscalls.h diff --git a/arch/microblaze/include/asm/syscalls.h b/arch/microblaze/include/asm/syscalls.h deleted file mode 100644 index 27f2f4c0f39f..000000000000 --- a/arch/microblaze/include/asm/syscalls.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __ASM_MICROBLAZE_SYSCALLS_H - -asmlinkage long microblaze_vfork(struct pt_regs *regs); -asmlinkage long microblaze_clone(int flags, unsigned long stack, - struct pt_regs *regs); -asmlinkage long microblaze_execve(const char __user *filenamei, - const char __user *const __user *argv, - const char __user *const __user *envp, - struct pt_regs *regs); - -asmlinkage long sys_clone(int flags, unsigned long stack, struct pt_regs *regs); -#define sys_clone sys_clone - -#include - -#endif /* __ASM_MICROBLAZE_SYSCALLS_H */ diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h index d0d3f69a7346..d8251b98f17a 100644 --- a/arch/s390/kernel/entry.h +++ b/arch/s390/kernel/entry.h @@ -54,10 +54,6 @@ long sys_s390_fadvise64(int fd, u32 offset_high, u32 offset_low, long sys_s390_fadvise64_64(struct fadvise64_64_args __user *args); long sys_s390_fallocate(int fd, int mode, loff_t offset, u32 len_high, u32 len_low); -long sys_fork(void); -long sys_clone(unsigned long newsp, unsigned long clone_flags, - int __user *parent_tidptr, int __user *child_tidptr); -long sys_vfork(void); long sys_sigsuspend(int history0, int history1, old_sigset_t mask); long sys_sigaction(int sig, const struct old_sigaction __user *act, struct old_sigaction __user *oact); diff --git a/arch/tile/include/asm/syscalls.h b/arch/tile/include/asm/syscalls.h index 394c76f2dc76..4c8462a62cb6 100644 --- a/arch/tile/include/asm/syscalls.h +++ b/arch/tile/include/asm/syscalls.h @@ -63,11 +63,8 @@ long sys_ftruncate64(unsigned int fd, loff_t length); #endif /* Provide versions of standard syscalls that use current_pt_regs(). */ -long sys_clone(unsigned long clone_flags, unsigned long newsp, - void __user *parent_tid, void __user *child_tid); long sys_rt_sigreturn(void); long sys_sigaltstack(const stack_t __user *, stack_t __user *); -#define sys_clone sys_clone #define sys_rt_sigreturn sys_rt_sigreturn #define sys_sigaltstack sys_sigaltstack diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c index a2e805569d5d..9cd7cb6041c0 100644 --- a/arch/tile/kernel/compat.c +++ b/arch/tile/kernel/compat.c @@ -104,7 +104,6 @@ long compat_sys_sched_rr_get_interval(compat_pid_t pid, /* Call the assembly trampolines where necessary. */ #define compat_sys_rt_sigreturn _compat_sys_rt_sigreturn -#undef sys_clone #define sys_clone _sys_clone /* diff --git a/arch/tile/kernel/sys.c b/arch/tile/kernel/sys.c index 02ff5c0ef775..b881a7be24bd 100644 --- a/arch/tile/kernel/sys.c +++ b/arch/tile/kernel/sys.c @@ -109,7 +109,6 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, /* Call the assembly trampolines where necessary. */ #undef sys_rt_sigreturn #define sys_rt_sigreturn _sys_rt_sigreturn -#undef sys_clone #define sys_clone _sys_clone /* diff --git a/arch/x86/include/asm/syscalls.h b/arch/x86/include/asm/syscalls.h index f7252d11416b..2f8374718aa3 100644 --- a/arch/x86/include/asm/syscalls.h +++ b/arch/x86/include/asm/syscalls.h @@ -20,17 +20,6 @@ asmlinkage long sys_ioperm(unsigned long, unsigned long, int); long sys_iopl(unsigned int, struct pt_regs *); -/* kernel/process.c */ -asmlinkage long sys_fork(void); -asmlinkage long sys_vfork(void); -#ifdef CONFIG_CLONE_BACKWARDS -asmlinkage long sys_clone(unsigned long, unsigned long, void __user *, int, - void __user *); -#else -asmlinkage long sys_clone(unsigned long, unsigned long, void __user *, - void __user *, int); -#endif - /* kernel/ldt.c */ asmlinkage int sys_modify_ldt(int, void __user *, unsigned long); diff --git a/arch/x86/um/shared/sysdep/syscalls.h b/arch/x86/um/shared/sysdep/syscalls.h index ca255a805ed9..bd9a89b67e41 100644 --- a/arch/x86/um/shared/sysdep/syscalls.h +++ b/arch/x86/um/shared/sysdep/syscalls.h @@ -1,5 +1,3 @@ -extern long sys_clone(unsigned long clone_flags, unsigned long newsp, - void __user *parent_tid, void __user *child_tid); #ifdef __i386__ #include "syscalls_32.h" #else diff --git a/include/asm-generic/syscalls.h b/include/asm-generic/syscalls.h index 77960333b1a1..58f466ff00d3 100644 --- a/include/asm-generic/syscalls.h +++ b/include/asm-generic/syscalls.h @@ -8,18 +8,6 @@ * Calling conventions for these system calls can differ, so * it's possible to override them. */ -#ifndef sys_clone -asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp, - void __user *parent_tid, void __user *child_tid); -#endif - -#ifndef sys_fork -asmlinkage long sys_fork(void); -#endif - -#ifndef sys_vfork -asmlinkage long sys_vfork(void); -#endif #ifndef sys_mmap2 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 526deb333b91..91835e7f364d 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -836,6 +836,16 @@ int kernel_execve(const char *filename, const char *const argv[], const char *co (const char __user *const __user *)envp) #endif +asmlinkage long sys_fork(void); +asmlinkage long sys_vfork(void); +#ifdef CONFIG_CLONE_BACKWARDS +asmlinkage long sys_clone(unsigned long, unsigned long, int __user *, int, + int __user *); +#else +asmlinkage long sys_clone(unsigned long, unsigned long, int __user *, + int __user *, int); +#endif + asmlinkage long sys_execve(const char __user *filename, const char __user *const __user *argv, const char __user *const __user *envp); -- cgit v1.2.3