Skip to content

Commit 7cedd60

Browse files
powerpc: Fix kernel thread creation on ABIv2
Change how we setup registers for ret_from_kernel_thread. In ABIv1, instead of passing a function descriptor in, dereference it and pass the target in directly. Use ppc_global_function_entry to get it right on both ABIv1 and ABIv2. Signed-off-by: Anton Blanchard <anton@samba.org>
1 parent b86206e commit 7cedd60

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

‎arch/powerpc/kernel/entry_64.S‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,11 @@ _GLOBAL(ret_from_fork)
378378
_GLOBAL(ret_from_kernel_thread)
379379
bl schedule_tail
380380
REST_NVGPRS(r1)
381-
ld r14, 0(r14)
382381
mtlr r14
383382
mr r3,r15
383+
#if defined(_CALL_ELF) && _CALL_ELF == 2
384+
mr r12,r14
385+
#endif
384386
blrl
385387
li r3,0
386388
b syscall_exit

‎arch/powerpc/kernel/process.c‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#ifdef CONFIG_PPC64
5555
#include <asm/firmware.h>
5656
#endif
57+
#include <asm/code-patching.h>
5758
#include <linux/kprobes.h>
5859
#include <linux/kdebug.h>
5960

@@ -1108,7 +1109,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
11081109
struct thread_info *ti = (void *)task_stack_page(p);
11091110
memset(childregs, 0, sizeof(struct pt_regs));
11101111
childregs->gpr[1] = sp + sizeof(struct pt_regs);
1111-
childregs->gpr[14] = usp; /* function */
1112+
/* function */
1113+
if (usp)
1114+
childregs->gpr[14] = ppc_function_entry((void *)usp);
11121115
#ifdef CONFIG_PPC64
11131116
clear_tsk_thread_flag(p, TIF_32BIT);
11141117
childregs->softe = 1;
@@ -1187,17 +1190,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
11871190
if (cpu_has_feature(CPU_FTR_HAS_PPR))
11881191
p->thread.ppr = INIT_PPR;
11891192
#endif
1190-
/*
1191-
* The PPC64 ABI makes use of a TOC to contain function
1192-
* pointers. The function (ret_from_except) is actually a pointer
1193-
* to the TOC entry. The first entry is a pointer to the actual
1194-
* function.
1195-
*/
1196-
#ifdef CONFIG_PPC64
1197-
kregs->nip = *((unsigned long *)f);
1198-
#else
1199-
kregs->nip = (unsigned long)f;
1200-
#endif
1193+
kregs->nip = ppc_function_entry(f);
12011194
return 0;
12021195
}
12031196

0 commit comments

Comments
 (0)