Page MenuHomeFreeBSD

Bypass errno handling in _umtx_op_err on powerpc
ClosedPublic

Authored by bdragon on Jul 13 2019, 8:28 PM.
Referenced Files
F105755491: D20946.diff
Fri, Dec 20, 5:19 AM
Unknown Object (File)
Nov 19 2024, 1:27 PM
Unknown Object (File)
Nov 17 2024, 9:48 AM
Unknown Object (File)
Nov 17 2024, 7:53 AM
Unknown Object (File)
Nov 5 2024, 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
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.