All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [parisc-linux] sigsetreturn (was utssys?)
@ 1999-08-17 19:20 Cary Coutant
  1999-08-17 19:54 ` Ulrich Drepper
  0 siblings, 1 reply; 3+ messages in thread
From: Cary Coutant @ 1999-08-17 19:20 UTC (permalink / raw)
  To: Matthew Wilcox, parisc-linux

>I also can't find a manual page for sigsetreturn() which I probably need
>to understand more deeply than utssys :-)

When the kernel passes control to a signal handler, it needs to set the 
stack up with a signal context structure and a return address that 
results in the restoration of that context when (and if) the signal 
handler returns. Since the normal BV instruction used for returns can't 
branch across space boundaries, the signal handler can't return directly 
to kernel space, so the kernel needs to supply a return address in user 
space that will implement the restoration of the interrupted context. 
This return address is the sigreturn() system call, found in libc. In 
order for the kernel to know the address of sigreturn, it needs to be 
told in advance; that's what sigsetreturn() does.

The call to sigsetreturn() has been moved around several times in the 
history of HP-UX. At one point, it was in the _start() routine in the C 
library, but that didn't get called for Fortran programs, so it was added 
to several of the signal routines, to make sure it got called before any 
signal handlers could be installed. Ultimately, I think it ended up in 
crt0, where it should have been all along.

Sigsetreturn() also supplies a "cookie" that the kernel can use to 
determine what the vintage is of the running program. For programs build 
for PA 1.0, for example, the cookie tells the kernel to deliver a shorter 
signal context record, since some of those early applications were 
actually dependent on the size and layout of the context record. Someone 
in OS land will probably have to supply you with the detailed meanings of 
the cookies used in this call, if it matters.

Cary Coutant
Runtime Architect

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [parisc-linux] sigsetreturn (was utssys?)
  1999-08-17 19:20 [parisc-linux] sigsetreturn (was utssys?) Cary Coutant
@ 1999-08-17 19:54 ` Ulrich Drepper
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Drepper @ 1999-08-17 19:54 UTC (permalink / raw)
  To: Cary Coutant; +Cc: Matthew Wilcox, parisc-linux

Cary Coutant <cary@cup.hp.com> writes:

> Since the normal BV instruction used for returns can't branch across
> space boundaries, the signal handler can't return directly to kernel
> space, so the kernel needs to supply a return address in user space
> that will implement the restoration of the interrupted context. This
> return address is the sigreturn() system call, found in libc. In
> order for the kernel to know the address of sigreturn, it needs to
> be told in advance; that's what sigsetreturn() does.

This is what Linux uses the sa_restorer in `struct sigaction' for.  I
think it's a better interface then sigsetreturn() so consider
implementing it this way and not provide sigsetreturn.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [parisc-linux] sigsetreturn (was utssys?)
@ 1999-08-17 21:46 Cary Coutant
  0 siblings, 0 replies; 3+ messages in thread
From: Cary Coutant @ 1999-08-17 21:46 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: parisc-linux

>This is what Linux uses the sa_restorer in `struct sigaction' for.  I
>think it's a better interface then sigsetreturn() so consider
>implementing it this way and not provide sigsetreturn.

My Linux manual page for sigaction states that "the sa_restorer element 
is obsolete and should not be used."

Even if it's not obsolete, how would it be used? Is the programmer 
supposed to pass the address of sigreturn() (or equivalent) every time it 
calls sigaction, or is the first time sufficient? Either way, I don't see 
how this is a better interface than sigsetreturn().

Even better would be to dispense with a user-space sigreturn() 
completely. In shared-bound programs, where procedures return either with 
a long return sequence (LDSID, MTSP, BE) or via an export stub, the 
kernel could supply an address in kernel space, and the signal handlers 
would return correctly. This is the approach we take for 64-bit HP-UX, 
where we can assume PA-RISC 2.0 and the use of BVE for returns. This 
approach would also work for a flat address space.

Then the only challenge is to identify the interrupt marker on the stack 
correctly during a stack unwind. On 32-bit HP-UX today, this is done by 
setting a special flag in the stack unwind descriptor for sigreturn(). On 
64-bit HP-UX, the kernel passes the address of a tiny unwind table for 
sigreturn() at program startup, and the runtime loader treats this as if 
sigreturn() were in a shared object of its own.

-cary

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-08-17 21:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-08-17 19:20 [parisc-linux] sigsetreturn (was utssys?) Cary Coutant
1999-08-17 19:54 ` Ulrich Drepper
  -- strict thread matches above, loose matches on Subject: below --
1999-08-17 21:46 Cary Coutant

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.