Alexandre Julliard (@julliard) commented about dlls/ntdll/unix/signal_x86_64.c:
/* When on the kernel stack, use %r13 instead of %gs to access the TEB. * (on macOS, signal handlers set gsbase to pthread_teb when on the kernel stack). */
-#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) "testl $4,%r14d\n\t" /* SYSCALL_HAVE_PTHREAD_TEB */ "jz 2f\n\t" +# ifdef __FreeBSD__
"movq $0x13,%rsi\n\t" /* GSEL(GUFS32_SEL, SEL_UPL) */
"movq %rsi,%fs\n\t"
+# endif "movq 0x320(%r13),%rsi\n\t" /* amd64_thread_data()->pthread_teb */
Please keep the Linux and FreeBSD case separate, unless they are truly identical.