git: 552c230a570b - stable/13 - linux: implement set_cloned_tls() on arm64

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Thu, 17 Feb 2022 15:53:51 UTC
The branch stable/13 has been updated by trasz:

URL: https://cgit.FreeBSD.org/src/commit/?id=552c230a570b7e28e863fc2ab4598e88f13c3bba

commit 552c230a570b7e28e863fc2ab4598e88f13c3bba
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-06-16 09:34:06 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-14 00:08:19 +0000

    linux: implement set_cloned_tls() on arm64
    
    This fixes random segfaults on "git commit --amend".
    
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D30508
    
    (cherry picked from commit a397b5508320e757274bc652b43ccb2e1a702933)
---
 sys/arm64/linux/linux_machdep.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/arm64/linux/linux_machdep.c b/sys/arm64/linux/linux_machdep.c
index 80597a2922a7..8e10fc9d26a1 100644
--- a/sys/arm64/linux/linux_machdep.c
+++ b/sys/arm64/linux/linux_machdep.c
@@ -55,7 +55,6 @@ LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
 LIN_SDT_PROBE_DEFINE0(machdep, linux_mmap2, todo);
 LIN_SDT_PROBE_DEFINE0(machdep, linux_rt_sigsuspend, todo);
 LIN_SDT_PROBE_DEFINE0(machdep, linux_sigaltstack, todo);
-LIN_SDT_PROBE_DEFINE0(machdep, linux_set_cloned_tls, todo);
 
 /*
  * LINUXTODO: deduplicate; linux_execve is common across archs, except that on
@@ -141,11 +140,12 @@ linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
 	return (EDOOFUS);
 }
 
-/* LINUXTODO: implement arm64 linux_set_cloned_tls */
 int
 linux_set_cloned_tls(struct thread *td, void *desc)
 {
 
-	LIN_SDT_PROBE0(machdep, linux_set_cloned_tls, todo);
-	return (EDOOFUS);
+	if ((uint64_t)desc >= VM_MAXUSER_ADDRESS)
+		return (EPERM);
+
+	return (cpu_set_user_tls(td, desc));
 }