Use of sigreturn(2) in longjmp(3).
Konstantin Belousov
kostikbel at gmail.com
Thu May 22 15:54:31 UTC 2014
On Thu, May 22, 2014 at 11:25:32AM -0400, Benjamin Kaduk wrote:
> On Thu, 22 May 2014, Keno Fischer wrote:
>
> > Hello,
> >
> > The sigreturn manpage states:
> >
> > "This system call is used by the trampoline code and longjmp(3) when
> > returning from a signal to the previously executing program".
> >
> > Now, I saw the system call in sigtramp.s, but I looked at setjmp.s can't
> > find how longjmp does this. Am I missing something totally obvious?
>
> I expect this is just stale documentation.
> Unfortunately, some quick poking at the svn log for
> sys/i386/i386/support.s does not make it immediately clear when the code
> changed to not match the documentation.
support.s is not related to the issue discussed.
Theoretically, sigreturn(2) might be required on some architectures,
where the raw access to the usermode CPU state requires supervisor CPU
state. AFAIK all architectures FreeBSD runs on either do not have this
quirk, or limit the state saved and restored in the setjmp/longjmp
functions, to the state accessible to the usermode.
For instance, even on x86, the TLS base is not saved and consequently
not restored by *jmp(3), and cannot be accessed directly by usermode,
while sigreturn(2) allows to perform full context modification, including
TLS base.
Some implementations of longjmp(3)-like functionality, e.g. the one
provided by libunwind, do utilize sigreturn(2) to unwind over the signal
frame.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20140522/71176da9/attachment.sig>
More information about the freebsd-hackers
mailing list