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)
Tue, Nov 5, 7:52 PM
Unknown Object (File)
Oct 3 2024, 8:04 PM
Unknown Object (File)
Sep 27 2024, 5:45 AM
Unknown Object (File)
Sep 20 2024, 10:35 PM
Unknown Object (File)
Sep 16 2024, 1:47 AM
Unknown Object (File)
Sep 8 2024, 7:51 PM
Unknown Object (File)
Sep 1 2024, 7:19 PM
Unknown Object (File)
Aug 29 2024, 7:22 AM
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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/libthr/arch/powerpc/powerpc/_umtx_op_err.S
38–41 ↗(On Diff #59731)

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.