Skip to content

Commit 6aabc1f

Browse files
committed
m68k: Implement copy_thread_tls()
This is required for clone3(), which passes the TLS value through a struct rather than a register. As do_fork() is only available if CONFIG_HAVE_COPY_THREAD_TLS is set, m68k_clone() must be changed to call _do_fork() directly. Signed-off-by: Geert Uytterhoeven <[email protected]> Acked-by: Christian Brauner <[email protected]> Acked-by: Greg Ungerer <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent bfc7931 commit 6aabc1f

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

arch/m68k/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ config M68K
1414
select HAVE_AOUT if MMU
1515
select HAVE_ASM_MODVERSIONS
1616
select HAVE_DEBUG_BUGVERBOSE
17+
select HAVE_COPY_THREAD_TLS
1718
select GENERIC_IRQ_SHOW
1819
select GENERIC_ATOMIC64
1920
select HAVE_UID16

arch/m68k/kernel/process.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,28 @@ void flush_thread(void)
108108
* on top of pt_regs, which means that sys_clone() arguments would be
109109
* buried. We could, of course, copy them, but it's too costly for no
110110
* good reason - generic clone() would have to copy them *again* for
111-
* do_fork() anyway. So in this case it's actually better to pass pt_regs *
112-
* and extract arguments for do_fork() from there. Eventually we might
113-
* go for calling do_fork() directly from the wrapper, but only after we
114-
* are finished with do_fork() prototype conversion.
111+
* _do_fork() anyway. So in this case it's actually better to pass pt_regs *
112+
* and extract arguments for _do_fork() from there. Eventually we might
113+
* go for calling _do_fork() directly from the wrapper, but only after we
114+
* are finished with _do_fork() prototype conversion.
115115
*/
116116
asmlinkage int m68k_clone(struct pt_regs *regs)
117117
{
118118
/* regs will be equal to current_pt_regs() */
119-
return do_fork(regs->d1, regs->d2, 0,
120-
(int __user *)regs->d3, (int __user *)regs->d4);
119+
struct kernel_clone_args args = {
120+
.flags = regs->d1 & ~CSIGNAL,
121+
.pidfd = (int __user *)regs->d3,
122+
.child_tid = (int __user *)regs->d4,
123+
.parent_tid = (int __user *)regs->d3,
124+
.exit_signal = regs->d1 & CSIGNAL,
125+
.stack = regs->d2,
126+
.tls = regs->d5,
127+
};
128+
129+
if (!legacy_clone_args_valid(&args))
130+
return -EINVAL;
131+
132+
return _do_fork(&args);
121133
}
122134

123135
/*
@@ -130,8 +142,9 @@ asmlinkage int m68k_clone3(struct pt_regs *regs)
130142
return sys_clone3((struct clone_args __user *)regs->d1, regs->d2);
131143
}
132144

133-
int copy_thread(unsigned long clone_flags, unsigned long usp,
134-
unsigned long arg, struct task_struct *p)
145+
int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
146+
unsigned long arg, struct task_struct *p,
147+
unsigned long tls)
135148
{
136149
struct fork_frame {
137150
struct switch_stack sw;
@@ -166,7 +179,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
166179
p->thread.usp = usp ?: rdusp();
167180

168181
if (clone_flags & CLONE_SETTLS)
169-
task_thread_info(p)->tp_value = frame->regs.d5;
182+
task_thread_info(p)->tp_value = tls;
170183

171184
#ifdef CONFIG_FPU
172185
if (!FPU_IS_EMU) {

0 commit comments

Comments
 (0)