Page MenuHomeFreeBSD

Bypass errno handling in _umtx_op_err on powerpc
ClosedPublic

Authored by bdragon on Jul 13 2019, 8:28 PM.
Referenced Files
Unknown Object (File)
Jan 29 2024, 4:08 AM
Unknown Object (File)
Jan 8 2024, 6:19 PM
Unknown Object (File)
Dec 21 2023, 8:49 AM
Unknown Object (File)
Dec 20 2023, 6:51 AM
Unknown Object (File)
Dec 14 2023, 10:03 PM
Unknown Object (File)
Dec 2 2023, 10:26 PM
Unknown Object (File)
Nov 14 2023, 3:12 AM
Unknown Object (File)
Oct 28 2023, 1:18 PM
Subscribers

Details

Summary

This was implemented previously in i386/amd64 (r177853) and sparc64 (r223228).

The original log message was:

Replace function _umtx_op with _umtx_op_err, the later function directly
returns errno, because errno can be mucked by user's signal handler and
most of pthread api heavily depends on errno to be correct, this change
should improve stability of the thread library.


This version of my patch does additional cleanup that might not be necessary. i386/amd64 and sparc64 don't check for this. It's possible (but I haven't figured out how to prove) that the contract with the kernel means that r3 will always be 0 on return to userspace for the non error condition, but since the same register (along with r4) is also used for aux returns as per cpu_set_syscall_retval(), I figured better safe than sorry. If that's not applicable to _umtx_op (i.e. if those never use the aux return stuff), I can take that back out and just blr after the sc.

Test Plan

Unknown. I'd like to have some sort of test that attempts to trip this up by messing with errno from a signal handler, but I don't know enough about threading and signal handlers to write one off the top of my head.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

lib/libthr/arch/powerpc/powerpc/_umtx_op_err.S
39–42

This is unnecessary. On success %r3 will always be 0 (see exec_machdep.c:916-925, and trap.c:691), so there's no need for the safety belt here.

removing belt&suspenders bit.

This revision is now accepted and ready to land.Aug 8 2019, 7:40 PM
This revision was automatically updated to reflect the committed changes.