Alexandre Julliard (@julliard) commented about dlls/ntdll/unix/signal_x86_64.c:
__ASM_CFI(".cfi_remember_state\n\t") __ASM_CFI_CFA_IS_AT2(rcx, 0xa8, 0x01) /* frame->syscall_cfa */ "leaq 0x70(%rcx),%rsp\n\t" /* %rsp > frame means no longer inside syscall */
-#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) "testl $4,%r14d\n\t" /* SYSCALL_HAVE_PTHREAD_TEB */ "jz 1f\n\t" "movw 0x338(%r13),%fs\n" /* amd64_thread_data()->fs */ +# ifdef __FreeBSD__
/* reset %ss (after sysret) for AMD */
"movw $0x3b,%r14w\n\t" /* GSEL(GUDATA_SEL, SEL_UPL) */
"movw %r14w,%ss\n\t"
+# endif
I don't think you should be changing %r14 here. It's also not clear why resetting %ss is necessary, where does it get cleared?