diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-12 10:49:08 +0900 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-12 10:49:08 +0900 |
commit | 8213a2f3eeafdecf06dd718cb4130372263f6067 (patch) | |
tree | 0d02e3201dac64d1429f8552ee1163d4a1ef1646 /arch/mn10300/kernel | |
parent | 40924754f2cabd5d9af4bcd4dcecc362b5e0baa1 (diff) | |
parent | 12f79be93d94698778ff2b3f921073fc5f6780d6 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
Pull pile 2 of execve and kernel_thread unification work from Al Viro:
"Stuff in there: kernel_thread/kernel_execve/sys_execve conversions for
several more architectures plus assorted signal fixes and cleanups.
There'll be more (in particular, real fixes for the alpha
do_notify_resume() irq mess)..."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal: (43 commits)
alpha: don't open-code trace_report_syscall_{enter,exit}
Uninclude linux/freezer.h
m32r: trim masks
avr32: trim masks
tile: don't bother with SIGTRAP in setup_frame
microblaze: don't bother with SIGTRAP in setup_rt_frame()
mn10300: don't bother with SIGTRAP in setup_frame()
frv: no need to raise SIGTRAP in setup_frame()
x86: get rid of duplicate code in case of CONFIG_VM86
unicore32: remove pointless test
h8300: trim _TIF_WORK_MASK
parisc: decide whether to go to slow path (tracesys) based on thread flags
parisc: don't bother looping in do_signal()
parisc: fix double restarts
bury the rest of TIF_IRET
sanitize tsk_is_polling()
bury _TIF_RESTORE_SIGMASK
unicore32: unobfuscate _TIF_WORK_MASK
mips: NOTIFY_RESUME is not needed in TIF masks
mips: merge the identical "return from syscall" per-ABI code
...
Conflicts:
arch/arm/include/asm/thread_info.h
Diffstat (limited to 'arch/mn10300/kernel')
-rw-r--r-- | arch/mn10300/kernel/Makefile | 4 | ||||
-rw-r--r-- | arch/mn10300/kernel/entry.S | 18 | ||||
-rw-r--r-- | arch/mn10300/kernel/internal.h | 6 | ||||
-rw-r--r-- | arch/mn10300/kernel/kernel_execve.S | 37 | ||||
-rw-r--r-- | arch/mn10300/kernel/kthread.S | 31 | ||||
-rw-r--r-- | arch/mn10300/kernel/process.c | 91 | ||||
-rw-r--r-- | arch/mn10300/kernel/signal.c | 13 |
7 files changed, 44 insertions, 156 deletions
diff --git a/arch/mn10300/kernel/Makefile b/arch/mn10300/kernel/Makefile index d06749173d63..561029f7fa44 100644 --- a/arch/mn10300/kernel/Makefile +++ b/arch/mn10300/kernel/Makefile @@ -7,8 +7,8 @@ fpu-obj-y := fpu-nofpu.o fpu-nofpu-low.o fpu-obj-$(CONFIG_FPU) := fpu.o fpu-low.o obj-y := process.o signal.o entry.o traps.o irq.o \ - ptrace.o setup.o time.o sys_mn10300.o io.o kthread.o \ - switch_to.o mn10300_ksyms.o kernel_execve.o $(fpu-obj-y) \ + ptrace.o setup.o time.o sys_mn10300.o io.o \ + switch_to.o mn10300_ksyms.o $(fpu-obj-y) \ csrc-mn10300.o cevt-mn10300.o obj-$(CONFIG_SMP) += smp.o smp-low.o diff --git a/arch/mn10300/kernel/entry.S b/arch/mn10300/kernel/entry.S index 8e11f9f48999..0c631d34c8d7 100644 --- a/arch/mn10300/kernel/entry.S +++ b/arch/mn10300/kernel/entry.S @@ -55,6 +55,20 @@ ENTRY(ret_from_fork) mov d0,(REG_D0,fp) jmp syscall_exit +ENTRY(ret_from_kernel_thread) + call schedule_tail[],0 + mov (REG_D0,fp),d0 + mov (REG_A0,fp),a0 + calls (a0) + jmp sys_exit + +ENTRY(ret_from_kernel_execve) + add -12,d0 /* pt_regs -> frame */ + mov d0,sp + GET_THREAD_INFO a2 + clr d0 + jmp syscall_exit + ############################################################################### # # system call handler @@ -94,6 +108,10 @@ restore_all: ############################################################################### ALIGN syscall_exit_work: + mov (REG_EPSW,fp),d0 + and EPSW_nSL,d0 + beq resume_kernel # returning to supervisor mode + btst _TIF_SYSCALL_TRACE,d2 beq work_pending LOCAL_IRQ_ENABLE # could let syscall_trace_exit() call diff --git a/arch/mn10300/kernel/internal.h b/arch/mn10300/kernel/internal.h index 2df440105a80..561785581f6c 100644 --- a/arch/mn10300/kernel/internal.h +++ b/arch/mn10300/kernel/internal.h @@ -15,14 +15,10 @@ struct clocksource; struct clock_event_device; /* - * kthread.S - */ -extern int kernel_thread_helper(int); - -/* * entry.S */ extern void ret_from_fork(struct task_struct *) __attribute__((noreturn)); +extern void ret_from_kernel_thread(struct task_struct *) __attribute__((noreturn)); /* * smp-low.S diff --git a/arch/mn10300/kernel/kernel_execve.S b/arch/mn10300/kernel/kernel_execve.S deleted file mode 100644 index 86039f105268..000000000000 --- a/arch/mn10300/kernel/kernel_execve.S +++ /dev/null @@ -1,37 +0,0 @@ -/* MN10300 In-kernel program execution - * - * Copyright (C) 2007 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 Licence - * as published by the Free Software Foundation; either version - * 2 of the Licence, or (at your option) any later version. - */ -#include <linux/linkage.h> -#include <asm/unistd.h> - -############################################################################### -# -# 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: D0/D1/8(SP): arguments to function -# On return: D0: syscall return. -# -############################################################################### - .globl kernel_execve - .type kernel_execve,@function -kernel_execve: - mov a3,a1 - mov d0,a0 - mov (12,sp),a3 - mov +__NR_execve,d0 - syscall 0 - mov a1,a3 - rets - - .size kernel_execve,.-kernel_execve diff --git a/arch/mn10300/kernel/kthread.S b/arch/mn10300/kernel/kthread.S deleted file mode 100644 index b5ae467ac5ec..000000000000 --- a/arch/mn10300/kernel/kthread.S +++ /dev/null @@ -1,31 +0,0 @@ -/* MN10300 Kernel thread trampoline function - * - * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. - * Written by Mark Salter (msalter@redhat.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public Licence - * as published by the Free Software Foundation; either version - * 2 of the Licence, or (at your option) any later version. - */ - .text - -############################################################################### -# -# kernel_thread_helper - trampoline for kernel_thread() -# -# On entry: -# A2 = address of function to call -# D2 = function argument -# -############################################################################### - .globl kernel_thread_helper - .type kernel_thread_helper,@function -kernel_thread_helper: - mov do_exit,d1 - mov d1,(sp) - mov d1,mdr - mov d2,d0 - jmp (a2) - - .size kernel_thread_helper,.-kernel_thread_helper diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c index e9cceba193b6..d0c671b6d9ff 100644 --- a/arch/mn10300/kernel/process.c +++ b/arch/mn10300/kernel/process.c @@ -165,27 +165,6 @@ void show_regs(struct pt_regs *regs) } /* - * create a kernel thread - */ -int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) -{ - struct pt_regs regs; - - memset(®s, 0, sizeof(regs)); - - regs.a2 = (unsigned long) fn; - regs.d2 = (unsigned long) arg; - regs.pc = (unsigned long) kernel_thread_helper; - local_save_flags(regs.epsw); - regs.epsw |= EPSW_IE | EPSW_IM_7; - - /* Ok, create the new process.. */ - return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, - NULL, NULL); -} -EXPORT_SYMBOL(kernel_thread); - -/* * free current thread data structures etc.. */ void exit_thread(void) @@ -230,50 +209,42 @@ int copy_thread(unsigned long clone_flags, struct task_struct *p, struct pt_regs *kregs) { struct thread_info *ti = task_thread_info(p); - struct pt_regs *c_uregs, *c_kregs, *uregs; + struct pt_regs *c_regs; unsigned long c_ksp; - uregs = current->thread.uregs; - c_ksp = (unsigned long) task_stack_page(p) + THREAD_SIZE; /* allocate the userspace exception frame and set it up */ c_ksp -= sizeof(struct pt_regs); - c_uregs = (struct pt_regs *) c_ksp; + c_regs = (struct pt_regs *) c_ksp; + c_ksp -= 12; /* allocate function call ABI slack */ - p->thread.uregs = c_uregs; - *c_uregs = *uregs; - c_uregs->sp = c_usp; - c_uregs->epsw &= ~EPSW_FE; /* my FPU */ + /* set up things up so the scheduler can start the new task */ + p->thread.uregs = c_regs; + ti->frame = c_regs; + p->thread.a3 = (unsigned long) c_regs; + p->thread.sp = c_ksp; + p->thread.wchan = p->thread.pc; + p->thread.usp = c_usp; - c_ksp -= 12; /* allocate function call ABI slack */ + if (unlikely(!kregs)) { + memset(c_regs, 0, sizeof(struct pt_regs)); + c_regs->a0 = c_usp; /* function */ + c_regs->d0 = ustk_size; /* argument */ + local_save_flags(c_regs->epsw); + c_regs->epsw |= EPSW_IE | EPSW_IM_7; + p->thread.pc = (unsigned long) ret_from_kernel_thread; + return 0; + } + *c_regs = *kregs; + c_regs->sp = c_usp; + c_regs->epsw &= ~EPSW_FE; /* my FPU */ /* the new TLS pointer is passed in as arg #5 to sys_clone() */ if (clone_flags & CLONE_SETTLS) - c_uregs->e2 = current_frame()->d3; - - /* set up the return kernel frame if called from kernel_thread() */ - c_kregs = c_uregs; - if (kregs != uregs) { - c_ksp -= sizeof(struct pt_regs); - c_kregs = (struct pt_regs *) c_ksp; - *c_kregs = *kregs; - c_kregs->sp = c_usp; - c_kregs->next = c_uregs; -#ifdef CONFIG_MN10300_CURRENT_IN_E2 - c_kregs->e2 = (unsigned long) p; /* current */ -#endif - - c_ksp -= 12; /* allocate function call ABI slack */ - } + c_regs->e2 = current_frame()->d3; - /* set up things up so the scheduler can start the new task */ - ti->frame = c_kregs; - p->thread.a3 = (unsigned long) c_kregs; - p->thread.sp = c_ksp; p->thread.pc = (unsigned long) ret_from_fork; - p->thread.wchan = (unsigned long) ret_from_fork; - p->thread.usp = c_usp; return 0; } @@ -302,22 +273,6 @@ asmlinkage long sys_vfork(void) current_frame(), 0, NULL, NULL); } -asmlinkage long sys_execve(const char __user *name, - const char __user *const __user *argv, - const char __user *const __user *envp) -{ - char *filename; - int error; - - filename = getname(name); - error = PTR_ERR(filename); - if (IS_ERR(filename)) - return error; - error = do_execve(filename, argv, envp, current_frame()); - putname(filename); - return error; -} - unsigned long get_wchan(struct task_struct *p) { return p->thread.wchan; diff --git a/arch/mn10300/kernel/signal.c b/arch/mn10300/kernel/signal.c index 4d584ae29ae1..f570b3085ef9 100644 --- a/arch/mn10300/kernel/signal.c +++ b/arch/mn10300/kernel/signal.c @@ -317,10 +317,6 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, regs->d0 = sig; regs->d1 = (unsigned long) &frame->sc; - /* the tracer may want to single-step inside the handler */ - if (test_thread_flag(TIF_SINGLESTEP)) - ptrace_notify(SIGTRAP); - #if DEBUG_SIG printk(KERN_DEBUG "SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n", sig, current->comm, current->pid, frame, regs->pc, @@ -398,10 +394,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, regs->d0 = sig; regs->d1 = (long) &frame->info; - /* the tracer may want to single-step inside the handler */ - if (test_thread_flag(TIF_SINGLESTEP)) - ptrace_notify(SIGTRAP); - #if DEBUG_SIG printk(KERN_DEBUG "SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n", sig, current->comm, current->pid, frame, regs->pc, @@ -475,11 +467,6 @@ static void do_signal(struct pt_regs *regs) siginfo_t info; int signr; - /* we want the common case to go fast, which is why we may in certain - * cases get here from kernel mode */ - if (!user_mode(regs)) - return; - signr = get_signal_to_deliver(&info, &ka, regs, NULL); if (signr > 0) { if (handle_signal(signr, &info, &ka, regs) == 0) { |