aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/process.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-09-12 18:32:42 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-09-30 23:31:19 -0400
commit58254e1002a82eb383c5977ad9fd5a451b91fe29 (patch)
treee03b441b252ec3630ceedbe266311c0a24812fd9 /arch/powerpc/kernel/process.c
parentf322220d6159455da2b5a8a596d802c8695fed30 (diff)
powerpc: split ret_from_fork
... and get rid of in-kernel syscalls in kernel_thread() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/powerpc/kernel/process.c')
-rw-r--r--arch/powerpc/kernel/process.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 1a1f2ddfb581..3b06898fa175 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -734,30 +734,39 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
734extern unsigned long dscr_default; /* defined in arch/powerpc/kernel/sysfs.c */ 734extern unsigned long dscr_default; /* defined in arch/powerpc/kernel/sysfs.c */
735 735
736int copy_thread(unsigned long clone_flags, unsigned long usp, 736int copy_thread(unsigned long clone_flags, unsigned long usp,
737 unsigned long unused, struct task_struct *p, 737 unsigned long arg, struct task_struct *p,
738 struct pt_regs *regs) 738 struct pt_regs *regs)
739{ 739{
740 struct pt_regs *childregs, *kregs; 740 struct pt_regs *childregs, *kregs;
741 extern void ret_from_fork(void); 741 extern void ret_from_fork(void);
742 extern void ret_from_kernel_thread(void);
743 void (*f)(void);
742 unsigned long sp = (unsigned long)task_stack_page(p) + THREAD_SIZE; 744 unsigned long sp = (unsigned long)task_stack_page(p) + THREAD_SIZE;
743 745
744 CHECK_FULL_REGS(regs);
745 /* Copy registers */ 746 /* Copy registers */
746 sp -= sizeof(struct pt_regs); 747 sp -= sizeof(struct pt_regs);
747 childregs = (struct pt_regs *) sp; 748 childregs = (struct pt_regs *) sp;
748 *childregs = *regs; 749 if (!regs) {
749 if ((childregs->msr & MSR_PR) == 0) {
750 /* for kernel thread, set `current' and stackptr in new task */ 750 /* for kernel thread, set `current' and stackptr in new task */
751 memset(childregs, 0, sizeof(struct pt_regs));
751 childregs->gpr[1] = sp + sizeof(struct pt_regs); 752 childregs->gpr[1] = sp + sizeof(struct pt_regs);
752#ifdef CONFIG_PPC32 753#ifdef CONFIG_PPC64
753 childregs->gpr[2] = (unsigned long) p; 754 childregs->gpr[14] = *(unsigned long *)usp;
754#else 755 childregs->gpr[2] = ((unsigned long *)usp)[1],
755 clear_tsk_thread_flag(p, TIF_32BIT); 756 clear_tsk_thread_flag(p, TIF_32BIT);
757#else
758 childregs->gpr[14] = usp; /* function */
759 childregs->gpr[2] = (unsigned long) p;
756#endif 760#endif
761 childregs->gpr[15] = arg;
757 p->thread.regs = NULL; /* no user register state */ 762 p->thread.regs = NULL; /* no user register state */
763 f = ret_from_kernel_thread;
758 } else { 764 } else {
765 CHECK_FULL_REGS(regs);
766 *childregs = *regs;
759 childregs->gpr[1] = usp; 767 childregs->gpr[1] = usp;
760 p->thread.regs = childregs; 768 p->thread.regs = childregs;
769 childregs->gpr[3] = 0; /* Result from fork() */
761 if (clone_flags & CLONE_SETTLS) { 770 if (clone_flags & CLONE_SETTLS) {
762#ifdef CONFIG_PPC64 771#ifdef CONFIG_PPC64
763 if (!is_32bit_task()) 772 if (!is_32bit_task())
@@ -766,8 +775,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
766#endif 775#endif
767 childregs->gpr[2] = childregs->gpr[6]; 776 childregs->gpr[2] = childregs->gpr[6];
768 } 777 }
778
779 f = ret_from_fork;
769 } 780 }
770 childregs->gpr[3] = 0; /* Result from fork() */
771 sp -= STACK_FRAME_OVERHEAD; 781 sp -= STACK_FRAME_OVERHEAD;
772 782
773 /* 783 /*
@@ -806,19 +816,17 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
806 p->thread.dscr = current->thread.dscr; 816 p->thread.dscr = current->thread.dscr;
807 } 817 }
808#endif 818#endif
809
810 /* 819 /*
811 * The PPC64 ABI makes use of a TOC to contain function 820 * The PPC64 ABI makes use of a TOC to contain function
812 * pointers. The function (ret_from_except) is actually a pointer 821 * pointers. The function (ret_from_except) is actually a pointer
813 * to the TOC entry. The first entry is a pointer to the actual 822 * to the TOC entry. The first entry is a pointer to the actual
814 * function. 823 * function.
815 */ 824 */
816#ifdef CONFIG_PPC64 825#ifdef CONFIG_PPC64
817 kregs->nip = *((unsigned long *)ret_from_fork); 826 kregs->nip = *((unsigned long *)f);
818#else 827#else
819 kregs->nip = (unsigned long)ret_from_fork; 828 kregs->nip = (unsigned long)f;
820#endif 829#endif
821
822 return 0; 830 return 0;
823} 831}
824 832