Skip to content

Commit

Permalink
frv: split ret_from_fork, simplify kernel_thread() a lot
Browse files Browse the repository at this point in the history
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Oct 1, 2012
1 parent d878d6d commit 02ce496
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 100 deletions.
2 changes: 1 addition & 1 deletion arch/frv/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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_thread.o \
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 \
sys_frv.o time.o setup.o frv_ksyms.o \
debug-stub.o irq.o sleep.o uaccess.o
Expand Down
8 changes: 8 additions & 0 deletions arch/frv/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,14 @@ ret_from_fork:
setlos.p #0,gr8
bra __syscall_exit

.globl ret_from_kernel_thread
ret_from_kernel_thread:
lddi.p @(gr28,#REG_GR(8)),gr20
call schedule_tail
or.p gr20,gr20,gr8
calll @(gr21,gr0)
bra sys_exit

###################################################################################################
#
# Return to user mode is not as complex as all this looks,
Expand Down
1 change: 0 additions & 1 deletion arch/frv/kernel/frv_ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ EXPORT_SYMBOL(ip_fast_csum);
EXPORT_SYMBOL(local_irq_count);
EXPORT_SYMBOL(local_bh_count);
#endif
EXPORT_SYMBOL(kernel_thread);

EXPORT_SYMBOL(__res_bus_clock_speed_HZ);
EXPORT_SYMBOL(__page_offset);
Expand Down
77 changes: 0 additions & 77 deletions arch/frv/kernel/kernel_thread.S

This file was deleted.

44 changes: 23 additions & 21 deletions arch/frv/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "local.h"

asmlinkage void ret_from_fork(void);
asmlinkage void ret_from_kernel_thread(void);

#include <asm/pgalloc.h>

Expand Down Expand Up @@ -172,29 +173,21 @@ int copy_thread(unsigned long clone_flags,
unsigned long usp, unsigned long topstk,
struct task_struct *p, struct pt_regs *regs)
{
struct pt_regs *childregs0, *childregs, *regs0;
struct pt_regs *childregs;

regs0 = __kernel_frame0_ptr;
childregs0 = (struct pt_regs *)
childregs = (struct pt_regs *)
(task_stack_page(p) + THREAD_SIZE - FRV_FRAME0_SIZE);
childregs = childregs0;

/* set up the userspace frame (the only place that the USP is stored) */
*childregs0 = *regs0;

childregs0->gr8 = 0;
childregs0->sp = usp;
childregs0->next_frame = NULL;

/* set up the return kernel frame if called from kernel_thread() */
if (regs != regs0) {
childregs--;
*childregs = *regs;
childregs->sp = (unsigned long) childregs0;
childregs->next_frame = childregs0;
childregs->gr15 = (unsigned long) task_thread_info(p);
childregs->gr29 = (unsigned long) p;
}
*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;

Expand All @@ -203,8 +196,7 @@ int copy_thread(unsigned long clone_flags,
p->thread.sp = (unsigned long) childregs;
p->thread.fp = 0;
p->thread.lr = 0;
p->thread.pc = (unsigned long) ret_from_fork;
p->thread.frame0 = childregs0;
p->thread.frame0 = childregs;

/* the new TLS pointer is passed in as arg #5 to sys_clone() */
if (clone_flags & CLONE_SETTLS)
Expand Down Expand Up @@ -347,3 +339,13 @@ 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, &regs, 0, NULL, NULL);
}

0 comments on commit 02ce496

Please sign in to comment.