Skip to content

Commit e8bb2a2

Browse files
Kars-de-Jonggeertu
authored andcommitted
m68k: Wire up clone3() syscall
Wire up the clone3() syscall for m68k. The special entry point is done in assembler as was done for clone() as well. This is needed because all registers need to be saved. The C wrapper then calls the generic sys_clone3() with the correct arguments. Tested on A1200 using the simple test program from: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Kars de Jong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 46cf053 commit e8bb2a2

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

arch/m68k/include/asm/unistd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
#define __ARCH_WANT_SYS_SIGPROCMASK
3131
#define __ARCH_WANT_SYS_FORK
3232
#define __ARCH_WANT_SYS_VFORK
33+
#define __ARCH_WANT_SYS_CLONE3
3334

3435
#endif /* _ASM_M68K_UNISTD_H_ */

arch/m68k/kernel/entry.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ ENTRY(__sys_vfork)
6969
lea %sp@(24),%sp
7070
rts
7171

72+
ENTRY(__sys_clone3)
73+
SAVE_SWITCH_STACK
74+
pea %sp@(SWITCH_STACK_SIZE)
75+
jbsr m68k_clone3
76+
lea %sp@(28),%sp
77+
rts
78+
7279
ENTRY(sys_sigreturn)
7380
SAVE_SWITCH_STACK
7481
movel %sp,%sp@- | switch_stack pointer

arch/m68k/kernel/process.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
#include <linux/init_task.h>
3131
#include <linux/mqueue.h>
3232
#include <linux/rcupdate.h>
33-
33+
#include <linux/syscalls.h>
3434
#include <linux/uaccess.h>
35+
3536
#include <asm/traps.h>
3637
#include <asm/machdep.h>
3738
#include <asm/setup.h>
@@ -119,6 +120,16 @@ asmlinkage int m68k_clone(struct pt_regs *regs)
119120
(int __user *)regs->d3, (int __user *)regs->d4);
120121
}
121122

123+
/*
124+
* Because extra registers are saved on the stack after the sys_clone3()
125+
* arguments, this C wrapper extracts them from pt_regs * and then calls the
126+
* generic sys_clone3() implementation.
127+
*/
128+
asmlinkage int m68k_clone3(struct pt_regs *regs)
129+
{
130+
return sys_clone3((struct clone_args __user *)regs->d1, regs->d2);
131+
}
132+
122133
int copy_thread(unsigned long clone_flags, unsigned long usp,
123134
unsigned long arg, struct task_struct *p)
124135
{

arch/m68k/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,4 @@
434434
432 common fsmount sys_fsmount
435435
433 common fspick sys_fspick
436436
434 common pidfd_open sys_pidfd_open
437-
# 435 reserved for clone3
437+
435 common clone3 __sys_clone3

0 commit comments

Comments
 (0)