Skip to content

Commit 20bda4e

Browse files
AmanieuChristian Brauner
authored andcommitted
riscv: Implement copy_thread_tls
This is required for clone3 which passes the TLS value through a struct rather than a register. Signed-off-by: Amanieu d'Antras <[email protected]> Cc: [email protected] Cc: <[email protected]> # 5.3.x Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent d2f36c7 commit 20bda4e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ config RISCV
6565
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
6666
select HAVE_ARCH_MMAP_RND_BITS if MMU
6767
select ARCH_HAS_GCOV_PROFILE_ALL
68+
select HAVE_COPY_THREAD_TLS
6869

6970
config ARCH_MMAP_RND_BITS_MIN
7071
default 18 if 64BIT

arch/riscv/kernel/process.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
9999
return 0;
100100
}
101101

102-
int copy_thread(unsigned long clone_flags, unsigned long usp,
103-
unsigned long arg, struct task_struct *p)
102+
int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
103+
unsigned long arg, struct task_struct *p, unsigned long tls)
104104
{
105105
struct pt_regs *childregs = task_pt_regs(p);
106106

@@ -121,7 +121,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
121121
if (usp) /* User fork */
122122
childregs->sp = usp;
123123
if (clone_flags & CLONE_SETTLS)
124-
childregs->tp = childregs->a5;
124+
childregs->tp = tls;
125125
childregs->a0 = 0; /* Return value of fork() */
126126
p->thread.ra = (unsigned long)ret_from_fork;
127127
}

0 commit comments

Comments
 (0)