The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c9c7058c319beaaef7538833d8d3f464f71885ad
commit c9c7058c319beaaef7538833d8d3f464f71885ad Author: Konstantin Belousov <k...@freebsd.org> AuthorDate: 2025-05-30 11:25:50 +0000 Commit: Konstantin Belousov <k...@freebsd.org> CommitDate: 2025-06-12 18:02:51 +0000 amd64: set PCB_TLSBASE pcb flag only for new C runtime threads (cherry picked from commit 16ce7f1a3603fce5262cf0656a01c4177c75fa50) --- 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 e069df9a375f..1739c2b57afd 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -62,6 +62,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> @@ -166,6 +167,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; @@ -675,7 +677,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;