From 460dabab73f2f60198c37ed7bf6d192d23eaa286 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 18 Sep 2012 22:25:02 -0400 Subject: frv: switch to generic sys_execve() current_pt_regs() here is simply __frame Acked-by: David Howells Signed-off-by: Al Viro --- arch/frv/include/asm/ptrace.h | 1 + arch/frv/include/asm/unistd.h | 1 + 2 files changed, 2 insertions(+) (limited to 'arch/frv/include') diff --git a/arch/frv/include/asm/ptrace.h b/arch/frv/include/asm/ptrace.h index ef6635ca4ecb..bd534b2d0258 100644 --- a/arch/frv/include/asm/ptrace.h +++ b/arch/frv/include/asm/ptrace.h @@ -76,6 +76,7 @@ register struct pt_regs *__frame asm("gr28"); #define user_mode(regs) (!((regs)->psr & PSR_S)) #define instruction_pointer(regs) ((regs)->pc) #define user_stack_pointer(regs) ((regs)->sp) +#define current_pt_regs() (__frame) extern unsigned long user_stack(const struct pt_regs *); #define profile_pc(regs) ((regs)->pc) diff --git a/arch/frv/include/asm/unistd.h b/arch/frv/include/asm/unistd.h index 67f23a311db6..24b64034866c 100644 --- a/arch/frv/include/asm/unistd.h +++ b/arch/frv/include/asm/unistd.h @@ -372,6 +372,7 @@ #define __ARCH_WANT_SYS_SIGPROCMASK #define __ARCH_WANT_SYS_RT_SIGACTION #define __ARCH_WANT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_EXECVE /* * "Conditional" syscalls -- cgit v1.2.3-59-g8ed1b From 019f96a345b6e23d4e0bc2c136ec5f7500b95834 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 18 Sep 2012 22:33:44 -0400 Subject: frv: switch to generic kernel_execve Acked-by: David Howells Signed-off-by: Al Viro --- arch/frv/include/asm/processor.h | 8 +++----- arch/frv/include/asm/unistd.h | 1 + arch/frv/kernel/Makefile | 2 +- arch/frv/kernel/entry.S | 5 +++++ arch/frv/kernel/kernel_execve.S | 33 --------------------------------- 5 files changed, 10 insertions(+), 39 deletions(-) delete mode 100644 arch/frv/kernel/kernel_execve.S (limited to 'arch/frv/include') diff --git a/arch/frv/include/asm/processor.h b/arch/frv/include/asm/processor.h index dccb9d162318..cc86e07a4119 100644 --- a/arch/frv/include/asm/processor.h +++ b/arch/frv/include/asm/processor.h @@ -92,14 +92,12 @@ extern struct task_struct *__kernel_current_task; /* * do necessary setup to start up a newly executed thread. - * - need to discard the frame stacked by init() invoking the execve syscall */ #define start_thread(_regs, _pc, _usp) \ do { \ - __frame = __kernel_frame0_ptr; \ - __frame->pc = (_pc); \ - __frame->psr &= ~PSR_S; \ - __frame->sp = (_usp); \ + _regs->pc = (_pc); \ + _regs->psr &= ~PSR_S; \ + _regs->sp = (_usp); \ } while(0) /* Free all resources held by a thread. */ diff --git a/arch/frv/include/asm/unistd.h b/arch/frv/include/asm/unistd.h index 24b64034866c..b6b07e55e473 100644 --- a/arch/frv/include/asm/unistd.h +++ b/arch/frv/include/asm/unistd.h @@ -373,6 +373,7 @@ #define __ARCH_WANT_SYS_RT_SIGACTION #define __ARCH_WANT_SYS_RT_SIGSUSPEND #define __ARCH_WANT_SYS_EXECVE +#define __ARCH_WANT_KERNEL_EXECVE /* * "Conditional" syscalls diff --git a/arch/frv/kernel/Makefile b/arch/frv/kernel/Makefile index 7b10bc19106e..3cbb3294b9f9 100644 --- a/arch/frv/kernel/Makefile +++ b/arch/frv/kernel/Makefile @@ -8,7 +8,7 @@ heads-$(CONFIG_MMU) := head-mmu-fr451.o extra-y:= head.o vmlinux.lds obj-y := $(heads-y) entry.o entry-table.o break.o switch_to.o \ - kernel_execve.o process.o traps.o ptrace.o signal.o dma.o \ + process.o traps.o ptrace.o signal.o dma.o \ sys_frv.o time.o setup.o frv_ksyms.o \ debug-stub.o irq.o sleep.o uaccess.o diff --git a/arch/frv/kernel/entry.S b/arch/frv/kernel/entry.S index 7a886130ca10..002732960315 100644 --- a/arch/frv/kernel/entry.S +++ b/arch/frv/kernel/entry.S @@ -871,6 +871,11 @@ ret_from_kernel_thread: calll @(gr21,gr0) bra sys_exit + .globl ret_from_kernel_execve +ret_from_kernel_execve: + ori gr28,0,sp + bra __syscall_exit + ################################################################################################### # # Return to user mode is not as complex as all this looks, diff --git a/arch/frv/kernel/kernel_execve.S b/arch/frv/kernel/kernel_execve.S deleted file mode 100644 index 9b074a16a052..000000000000 --- a/arch/frv/kernel/kernel_execve.S +++ /dev/null @@ -1,33 +0,0 @@ -/* in-kernel program execution - * - * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. - * Written by David Howells (dhowells@redhat.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ - -#include -#include - -############################################################################### -# -# Do a system call from kernel instead of calling sys_execve so we end up with -# proper pt_regs. -# -# int kernel_execve(const char *filename, char *const argv[], char *const envp[]) -# -# On entry: GR8/GR9/GR10: arguments to function -# On return: GR8: syscall return. -# -############################################################################### - .globl kernel_execve - .type kernel_execve,@function -kernel_execve: - setlos __NR_execve,gr7 - tira gr0,#0 - bralr - - .size kernel_execve,.-kernel_execve -- cgit v1.2.3-59-g8ed1b From 49ed3398b75c98c087537a7d5a1a23f86a8c8746 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 22 Sep 2012 18:10:15 -0400 Subject: frv: switch to generic kernel_thread() --- arch/frv/Kconfig | 1 + arch/frv/include/asm/processor.h | 1 - arch/frv/kernel/process.c | 41 +++++++++++++++++++--------------------- 3 files changed, 20 insertions(+), 23 deletions(-) (limited to 'arch/frv/include') diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig index 971c0a19facb..a27a1c6f8457 100644 --- a/arch/frv/Kconfig +++ b/arch/frv/Kconfig @@ -10,6 +10,7 @@ config FRV select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_CPU_DEVICES select ARCH_WANT_IPC_PARSE_VERSION + select GENERIC_KERNEL_THREAD config ZONE_DMA bool diff --git a/arch/frv/include/asm/processor.h b/arch/frv/include/asm/processor.h index cc86e07a4119..a34f309e5801 100644 --- a/arch/frv/include/asm/processor.h +++ b/arch/frv/include/asm/processor.h @@ -105,7 +105,6 @@ static inline void release_thread(struct task_struct *dead_task) { } -extern asmlinkage int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); extern asmlinkage void save_user_regs(struct user_context *target); extern asmlinkage void *restore_user_regs(const struct user_context *target, ...); diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c index 7ff4dbef0567..014f855362b9 100644 --- a/arch/frv/kernel/process.c +++ b/arch/frv/kernel/process.c @@ -170,7 +170,7 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, * set up the kernel stack and exception frames for a new process */ int copy_thread(unsigned long clone_flags, - unsigned long usp, unsigned long topstk, + unsigned long usp, unsigned long arg, struct task_struct *p, struct pt_regs *regs) { struct pt_regs *childregs; @@ -178,17 +178,6 @@ int copy_thread(unsigned long clone_flags, childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE - FRV_FRAME0_SIZE); - /* set up the userspace frame (the only place that the USP is stored) */ - *childregs = *regs; - - childregs->sp = usp; - childregs->next_frame = NULL; - - if (unlikely(!user_mode(regs))) - p->thread.pc = (unsigned long) ret_from_kernel_thread; - else - p->thread.pc = (unsigned long) ret_from_fork; - p->set_child_tid = p->clear_child_tid = NULL; p->thread.frame = childregs; @@ -198,6 +187,24 @@ int copy_thread(unsigned long clone_flags, p->thread.lr = 0; p->thread.frame0 = childregs; + if (unlikely(!regs)) { + memset(childregs, 0, sizeof(struct pt_regs)); + childregs->gr9 = usp; /* function */ + childregs->gr8 = arg; + chilregs->psr = PSR_S; + p->thread.pc = (unsigned long) ret_from_kernel_thread; + save_user_regs(p->thread.user); + return 0; + } + + /* set up the userspace frame (the only place that the USP is stored) */ + *childregs = *regs; + + childregs->sp = usp; + childregs->next_frame = NULL; + + p->thread.pc = (unsigned long) ret_from_fork; + /* the new TLS pointer is passed in as arg #5 to sys_clone() */ if (clone_flags & CLONE_SETTLS) childregs->gr29 = childregs->gr12; @@ -320,13 +327,3 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs) sizeof(current->thread.user->f)); return 1; } - -int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) -{ - struct pt_regs regs = { - .gr8 = (unsigned long)arg; - .gr9 = (unsigned long)fn; - .psr = PSR_S; - }; - return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); -} -- cgit v1.2.3-59-g8ed1b From 8af4efac26e1805c76144ad44118157239308d35 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 1 Jun 2012 14:21:16 -0400 Subject: bury _TIF_RESTORE_SIGMASK never used... Signed-off-by: Al Viro --- arch/alpha/include/asm/thread_info.h | 1 - arch/avr32/include/asm/thread_info.h | 1 - arch/blackfin/include/asm/thread_info.h | 1 - arch/cris/include/asm/thread_info.h | 1 - arch/frv/include/asm/thread_info.h | 1 - arch/h8300/include/asm/thread_info.h | 1 - arch/hexagon/include/asm/thread_info.h | 1 - arch/m32r/include/asm/thread_info.h | 1 - arch/mips/include/asm/thread_info.h | 1 - arch/mn10300/include/asm/thread_info.h | 1 - arch/openrisc/include/asm/thread_info.h | 1 - arch/parisc/include/asm/thread_info.h | 1 - arch/s390/include/asm/thread_info.h | 1 - arch/score/include/asm/thread_info.h | 1 - arch/sparc/include/asm/thread_info_32.h | 1 - arch/unicore32/include/asm/thread_info.h | 1 - arch/xtensa/include/asm/thread_info.h | 1 - 17 files changed, 17 deletions(-) (limited to 'arch/frv/include') diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h index 28335bd40e40..2601c8e338da 100644 --- a/arch/alpha/include/asm/thread_info.h +++ b/arch/alpha/include/asm/thread_info.h @@ -84,7 +84,6 @@ register struct thread_info *__current_thread_info __asm__("$8"); #define _TIF_SIGPENDING (1< Date: Fri, 1 Jun 2012 14:22:01 -0400 Subject: sanitize tsk_is_polling() Make default just return 0. The current default (checking TIF_POLLING_NRFLAG) is taken to architectures that need it; ones that don't do polling in their idle threads don't need to defined TIF_POLLING_NRFLAG at all. ia64 defined both TS_POLLING (used by its tsk_is_polling()) and TIF_POLLING_NRFLAG (not used at all). Killed the latter... Signed-off-by: Al Viro --- arch/alpha/include/asm/thread_info.h | 2 ++ arch/arm/include/asm/thread_info.h | 2 -- arch/avr32/include/asm/thread_info.h | 4 ---- arch/blackfin/include/asm/thread_info.h | 3 --- arch/c6x/include/asm/thread_info.h | 1 - arch/c6x/kernel/asm-offsets.c | 1 - arch/cris/include/asm/thread_info.h | 2 -- arch/frv/include/asm/thread_info.h | 2 -- arch/h8300/include/asm/thread_info.h | 3 --- arch/hexagon/include/asm/thread_info.h | 2 -- arch/ia64/include/asm/thread_info.h | 2 -- arch/m32r/include/asm/thread_info.h | 2 -- arch/microblaze/include/asm/thread_info.h | 1 + arch/mips/include/asm/thread_info.h | 2 -- arch/mn10300/include/asm/thread_info.h | 2 ++ arch/openrisc/include/asm/thread_info.h | 2 ++ arch/parisc/include/asm/thread_info.h | 2 ++ arch/powerpc/include/asm/thread_info.h | 2 ++ arch/s390/include/asm/thread_info.h | 3 --- arch/score/include/asm/thread_info.h | 3 --- arch/sh/include/asm/thread_info.h | 3 +++ arch/sparc/include/asm/thread_info_32.h | 2 ++ arch/sparc/include/asm/thread_info_64.h | 3 +++ arch/um/include/asm/thread_info.h | 3 --- arch/xtensa/include/asm/thread_info.h | 2 -- kernel/sched/core.c | 2 +- 26 files changed, 20 insertions(+), 38 deletions(-) (limited to 'arch/frv/include') diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h index 2601c8e338da..4554ecbff7c6 100644 --- a/arch/alpha/include/asm/thread_info.h +++ b/arch/alpha/include/asm/thread_info.h @@ -116,5 +116,7 @@ register struct thread_info *__current_thread_info __asm__("$8"); (int __user *)(value)); \ }) +#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG) + #endif /* __KERNEL__ */ #endif /* _ALPHA_THREAD_INFO_H */ diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index af7b0bda3355..b2d6b412172d 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -148,7 +148,6 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *, #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 #define TIF_SYSCALL_AUDIT 9 -#define TIF_POLLING_NRFLAG 16 #define TIF_USING_IWMMXT 17 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_RESTORE_SIGMASK 20 @@ -160,7 +159,6 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *, #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) -#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT) #define _TIF_SECCOMP (1 << TIF_SECCOMP) diff --git a/arch/avr32/include/asm/thread_info.h b/arch/avr32/include/asm/thread_info.h index a32c88cb2601..dc0c45721499 100644 --- a/arch/avr32/include/asm/thread_info.h +++ b/arch/avr32/include/asm/thread_info.h @@ -77,8 +77,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ #define TIF_SIGPENDING 1 /* signal pending */ #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ -#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling - TIF_NEED_RESCHED */ #define TIF_BREAKPOINT 4 /* enter monitor mode on return */ #define TIF_SINGLE_STEP 5 /* single step in progress */ #define TIF_MEMDIE 6 /* is terminating due to OOM killer */ @@ -91,7 +89,6 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) -#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) #define _TIF_SINGLE_STEP (1 << TIF_SINGLE_STEP) #define _TIF_MEMDIE (1 << TIF_MEMDIE) #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP) @@ -104,7 +101,6 @@ static inline struct thread_info *current_thread_info(void) ((1 << TIF_SIGPENDING) \ | _TIF_NOTIFY_RESUME \ | (1 << TIF_NEED_RESCHED) \ - | (1 << TIF_POLLING_NRFLAG) \ | (1 << TIF_BREAKPOINT) \ | (1 << TIF_RESTORE_SIGMASK)) diff --git a/arch/blackfin/include/asm/thread_info.h b/arch/blackfin/include/asm/thread_info.h index f9a8731b7e81..3894005337ba 100644 --- a/arch/blackfin/include/asm/thread_info.h +++ b/arch/blackfin/include/asm/thread_info.h @@ -96,8 +96,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ #define TIF_SIGPENDING 1 /* signal pending */ #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ -#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling - TIF_NEED_RESCHED */ #define TIF_MEMDIE 4 /* is terminating due to OOM killer */ #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */ #define TIF_IRQ_SYNC 7 /* sync pipeline stage */ @@ -108,7 +106,6 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_SYSCALL_TRACE (1<status &= ~TS_RESTORE_SIGMASK; return true; } +#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG) #endif #endif /* __KERNEL__ */ diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h index a75a11abf7b0..8debe9e91754 100644 --- a/arch/mips/include/asm/thread_info.h +++ b/arch/mips/include/asm/thread_info.h @@ -103,7 +103,6 @@ register struct thread_info *__current_thread_info __asm__("$28"); #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */ #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ -#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_FIXADE 20 /* Fix address errors in software */ #define TIF_LOGADE 21 /* Log address errors to syslog */ @@ -126,7 +125,6 @@ register struct thread_info *__current_thread_info __asm__("$28"); #define _TIF_SECCOMP (1<status &= ~TS_RESTORE_SIGMASK; return true; } + +#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG) + #endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */ diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h index dd3807599bb9..25849ae3e900 100644 --- a/arch/sparc/include/asm/thread_info_32.h +++ b/arch/sparc/include/asm/thread_info_32.h @@ -132,6 +132,8 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | \ _TIF_SIGPENDING) +#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG) + #endif /* __KERNEL__ */ #endif /* _ASM_THREAD_INFO_H */ diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h index cfa8c38fb9c8..4e2276631081 100644 --- a/arch/sparc/include/asm/thread_info_64.h +++ b/arch/sparc/include/asm/thread_info_64.h @@ -256,6 +256,9 @@ static inline bool test_and_clear_restore_sigmask(void) ti->status &= ~TS_RESTORE_SIGMASK; return true; } + +#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG) + #endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */ diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h index c04e5ab68f56..2c8eeb2df8b4 100644 --- a/arch/um/include/asm/thread_info.h +++ b/arch/um/include/asm/thread_info.h @@ -65,8 +65,6 @@ static inline struct thread_info *current_thread_info(void) #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ #define TIF_SIGPENDING 1 /* signal pending */ #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ -#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling - * TIF_NEED_RESCHED */ #define TIF_RESTART_BLOCK 4 #define TIF_MEMDIE 5 /* is terminating due to OOM killer */ #define TIF_SYSCALL_AUDIT 6 @@ -76,7 +74,6 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) -#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) #define _TIF_MEMDIE (1 << TIF_MEMDIE) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) diff --git a/arch/xtensa/include/asm/thread_info.h b/arch/xtensa/include/asm/thread_info.h index a27bc8ce5eff..214be732b2b2 100644 --- a/arch/xtensa/include/asm/thread_info.h +++ b/arch/xtensa/include/asm/thread_info.h @@ -132,14 +132,12 @@ static inline struct thread_info *current_thread_info(void) #define TIF_MEMDIE 5 /* is terminating due to OOM killer */ #define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ #define TIF_NOTIFY_RESUME 7 /* callback before returning to user */ -#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ #define _TIF_SYSCALL_TRACE (1<