Alex S reported that Proton (which is Wine distribution integrated with Steam) depends on functionality mentioned at https://github.com/freebsd/freebsd/blob/8989bc4581101acb0dda31d9c4f9b6ec4732c5cf/sys/i386/linux/linux_machdep.c#L582: /* * Semantics of Linux version: every thread in the system has array of * 3 tls descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. This * syscall loads one of the selected tls decriptors with a value and * also loads GDT descriptors 6, 7 and 8 with the content of the * per-thread descriptors. * * Semantics of FreeBSD version: I think we can ignore that Linux has 3 * per-thread descriptors and use just the 1st one. The tls_array[] * is used only in set/get-thread_area() syscalls and for loading the * GDT descriptors. In FreeBSD we use just one GDT descriptor for TLS * so we will load just one. * * XXX: this doesn't work when a user space process tries to use more * than 1 TLS segment. Comment in the Linux sources says wine might do * this. */
Created attachment 248191 [details] comment cleanup I should probably use Phab instead, but, just in case I forget about it, here is a good-enough-for-me patch.
Created attachment 248228 [details] comment cleanup (v2) Removed TODO. I'd say linux_set_cloned_tls (in linux32) could use a bit of cleanup, but there is no conflict with this patch.
Created attachment 248297 [details] comment cleanup (v3) The slot counter was adjusted not to reset on forking.
Created attachment 248298 [details] set-thread-area-ubuntu.txt My actual test case (for people wondering wtf the patch is supposed to improve).
Created attachment 248299 [details] comment cleanup (v4) Make the patch actually apply to current (main?).
https://reviews.freebsd.org/D43814