git: 16ce7f1a3603 - main - amd64: set PCB_TLSBASE pcb flag only for new C runtime threads
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 31 May 2025 14:56:02 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=16ce7f1a3603fce5262cf0656a01c4177c75fa50 commit 16ce7f1a3603fce5262cf0656a01c4177c75fa50 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2025-05-30 11:25:50 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2025-05-31 14:55:24 +0000 amd64: set PCB_TLSBASE pcb flag only for new C runtime threads where the runtime does want the pcb_tlsbase to be set in fsbase in signal handlers. This way, other runtimes that are not aware of pcb_tlsbase get the old behavior of preserving fsbase on calling signal handler. For instance, this fixes Go runtime that wants to handle fsbase in its own way. Reported by: Herbert J. Skuhra <herbert@gojira.at> Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/amd64/amd64/vm_machdep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 275ab1a54e52..c763ff58680e 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -60,6 +60,7 @@ #include <sys/smp.h> #include <sys/sysctl.h> #include <sys/sysent.h> +#include <sys/thr.h> #include <sys/unistd.h> #include <sys/vnode.h> #include <sys/vmmeter.h> @@ -164,6 +165,7 @@ copy_thread(struct thread *td1, struct thread *td2) MPASS((pcb2->pcb_flags & (PCB_KERNFPU | PCB_KERNFPU_THR)) == 0); bcopy(get_pcb_user_save_td(td1), get_pcb_user_save_pcb(pcb2), cpu_max_ext_state_size); + clear_pcb_flags(pcb2, PCB_TLSBASE); } td2->td_frame = (struct trapframe *)td2->td_md.md_stack_base - 1; @@ -663,7 +665,8 @@ cpu_set_user_tls(struct thread *td, void *tls_base, int thr_flags) return (EINVAL); pcb = td->td_pcb; - set_pcb_flags(pcb, PCB_FULL_IRET | PCB_TLSBASE); + set_pcb_flags(pcb, PCB_FULL_IRET | ((thr_flags & + THR_C_RUNTIME) != 0 ? PCB_TLSBASE : 0)); #ifdef COMPAT_FREEBSD32 if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { pcb->pcb_gsbase = (register_t)tls_base;