1995-02-18 01:27:10 +00:00
|
|
|
/* Set thread_state for sighandler, and sigcontext to recover. i386 version.
|
2020-01-01 00:14:33 +00:00
|
|
|
Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
1997-06-23 21:55:26 +00:00
|
|
|
This file is part of the GNU C Library.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1997-06-23 21:55:26 +00:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1997-06-23 21:55:26 +00:00
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
#include <hurd/signal.h>
|
1995-04-02 22:08:59 +00:00
|
|
|
#include <hurd/userlink.h>
|
2005-12-21 22:16:34 +00:00
|
|
|
#include <thread_state.h>
|
2020-12-21 00:41:55 +00:00
|
|
|
#include <mach/exception.h>
|
2008-03-08 21:39:00 +00:00
|
|
|
#include <mach/machine/eflags.h>
|
1995-02-18 01:27:10 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include "hurdfault.h"
|
2005-12-21 22:16:34 +00:00
|
|
|
#include <intr-msg.h>
|
2020-12-21 00:41:55 +00:00
|
|
|
#include <sys/ucontext.h>
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1996-01-04 17:00:45 +00:00
|
|
|
|
2020-12-21 00:41:55 +00:00
|
|
|
/* Fill in a siginfo_t structure for SA_SIGINFO-enabled handlers. */
|
|
|
|
static void fill_siginfo (siginfo_t *si, int signo,
|
|
|
|
const struct hurd_signal_detail *detail,
|
|
|
|
const struct machine_thread_all_state *state)
|
|
|
|
{
|
|
|
|
si->si_signo = signo;
|
|
|
|
si->si_errno = detail->error;
|
|
|
|
si->si_code = detail->code;
|
|
|
|
|
|
|
|
/* XXX We would need a protocol change for sig_post to include
|
|
|
|
* this information. */
|
|
|
|
si->si_pid = -1;
|
|
|
|
si->si_uid = -1;
|
|
|
|
|
|
|
|
/* Address of the faulting instruction or memory access. */
|
|
|
|
if (detail->exc == EXC_BAD_ACCESS)
|
|
|
|
si->si_addr = (void *) detail->exc_subcode;
|
|
|
|
else
|
|
|
|
si->si_addr = (void *) state->basic.eip;
|
|
|
|
|
|
|
|
/* XXX On SIGCHLD, this should be the exit status of the child
|
|
|
|
* process. We would need a protocol change for the proc server
|
|
|
|
* to send this information along with the signal. */
|
|
|
|
si->si_status = 0;
|
|
|
|
|
|
|
|
si->si_band = 0; /* SIGPOLL is not supported yet. */
|
|
|
|
si->si_value.sival_int = 0; /* sigqueue() is not supported yet. */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in a ucontext_t structure SA_SIGINFO-enabled handlers. */
|
|
|
|
static void fill_ucontext (ucontext_t *uc, const struct sigcontext *sc)
|
|
|
|
{
|
|
|
|
uc->uc_flags = 0;
|
|
|
|
uc->uc_link = NULL;
|
|
|
|
uc->uc_sigmask = sc->sc_mask;
|
2020-12-21 02:15:38 +00:00
|
|
|
uc->uc_stack.ss_sp = (__ptr_t) sc->sc_uesp;
|
2020-12-21 00:41:55 +00:00
|
|
|
uc->uc_stack.ss_size = 0;
|
|
|
|
uc->uc_stack.ss_flags = 0;
|
|
|
|
|
|
|
|
/* Registers. */
|
|
|
|
memcpy (&uc->uc_mcontext.gregs[REG_GS], &sc->sc_gs,
|
|
|
|
(REG_TRAPNO - REG_GS) * sizeof (int));
|
|
|
|
uc->uc_mcontext.gregs[REG_TRAPNO] = 0;
|
|
|
|
uc->uc_mcontext.gregs[REG_ERR] = 0;
|
|
|
|
memcpy (&uc->uc_mcontext.gregs[REG_EIP], &sc->sc_eip,
|
|
|
|
(NGREG - REG_EIP) * sizeof (int));
|
|
|
|
|
|
|
|
/* XXX FPU state. */
|
|
|
|
memset (&uc->uc_mcontext.fpregs, 0, sizeof (fpregset_t));
|
|
|
|
}
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
struct sigcontext *
|
2020-12-26 16:57:52 +00:00
|
|
|
_hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action,
|
|
|
|
__sighandler_t handler,
|
Tue May 7 19:00:01 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* string/argz-extract.c: Remove const from decl.
* string/argz.h: Here too.
* Makeconfig (version.mk): Fix regexp in sed cmd.
Depend on $(..)Makeconfig.
* GMP code updated from gmp-2.0 release.
* stdlib/Makefile (mpn-routines): Removed add_1, added inlines.
* sysdeps/generic/add_1.c: File removed.
* stdlib/strtod.c: mp_limb is now mp_limb_t.
* stdlib/fpioconst.c, stdlib/fpioconst.h: Likewise.
* stdio-common/_itoa.c: Likewise.
* stdio-common/printf_fp.c: Likewise.
Don't include ansidecl.h.
* sysdeps/mach/hurd/getcwd.c: Use io_identity instead of io_stat.
* shlib-versions: New file.
* Makerules (soversions.mk): New target, include file generated from
shlib-versions. Moved shared library rules before installation rules.
Rewrote shared library installation rules for versioned libraries.
* math/Makefile (libm.so-version): Variable removed.
* sysdeps/mach/hurd/i386/exc2signal.c: Use struct hurd_signal_detail.
* hurd/report-wait.c (_S_msg_describe_ports): New function.
* configure.in: Add AC_PROG_LN_S check.
* config.make.in (LN_S): New variable.
Sun May 5 03:10:44 1996 Ulrich Drepper <drepper@cygnus.com>
* misc/efgcvt_r.c (ecvt_r): Work aroung gcc bug. gcc does
not know about weak aliases now and optimizes necessary `if'
statement away.
* posix/unistd.h: Add swapoff prototype.
* sysdeps/generic/confname.h: Add even more POSIX.4 symbols.
* sysdeps/posix/fpathconf.c (__fpathconf): Get information
for _PC_PATH_MAX from fstatfs function if available.
* sysdeps/posix/sysconf.c: Add code to handle _SC_AIO_LISTIO_MAX,
_SC_AIO_MAX, _SC_AIO_PRIO_DELTA_MAX, _SC_DELAYTIMER_MAX,
_SC_MQ_OPEN_MAX, _SC_MQ_PRIO_MAX, _SC_RTSIG_MAX,
_SC_SEM_NSEMS_MAX, _SC_SEM_VALUE_MAX, _SC_SIGQUEUE_MAX, and
_SC_TIMER_MAX.
* sysdeps/unix/sysv/sysv4/sysconf.c: Ditto.
* sysdeps/stub/swapoff.c: New file. Stub version for swapoff
function.
* sysdeps/unix/syscalls.list: Add swapoff.
* sysdeps/unix/sysv/linux/Dist: Add sys/acct.h.
* sysdeps/unix/sysv/linux/Makefile [$(subdir) == misc]
(sysdep_routines): Add mount, umount, llseek, setfsgid, setfsuid,
sysinfo, and uselib.
(headers): Add sys/sysinfo.h.
* sysdeps/unix/sysv/linux/gethostid.c: Prevent warning.
* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) == misc]
(sysdep_routines): Add ioperm, iopl, and vm86.
(headers): Add sys/perm.h and sys/vm86.h.
* sysdeps/unix/sysv/linux/i386/sys/perm.h: New file. Contains
prototypes for iopl and ioperm.
* sysdeps/unix/sysv/linux/i386/sys/vm86.h: New file. Contains
prototype for vm86.
* sysdeps/unix/sysv/linux/i386/syscalls.list: New file. Add
vm86 system call.
* sysdeps/unix/sysv/linux/sys/acct.h: New file. Contains
prototypes for acct function.
* sysdeps/unix/sysv/linux/sys/socket.h: Provide real header
file with prototypes.
* sysdeps/unix/sysv/linux/sys/sysinfo.h: New file. Contains
prototype for sysinfo function.
* sysdeps/unix/sysv/linux/syscalls.list: Add flock, ioperm, iopl,
llseek, setfsgid, setfsuid, sysinfo, and uselib.
* sysdeps/unix/sysv/linux/sysconf.c: Instead of duplicating
posix/sysconf.c now only handle cases different to that
implementation.
Tue May 7 15:08:19 1996 Miles Bader <miles@gnu.ai.mit.edu>
* stdio/linewrap.c (__line_wrap_output): Renamed from lwoutput
(all references changed). Now exported.
* stdio/linewrap.c (struct data): Type deleted (moved to linewrap.h).
(wrap_stream, unwrap_stream, lwclose, lwfileno, lwoutput,
line_wrap_stream, line_unwrap_stream): Use struct line_wrap_data
instead of struct data.
(lwoutput, line_wrap_stream, line_unwrap_stream): Rename various
occurences of `wrap' and `wrapmargin' to `wmargin'.
(line_wrapped, line_wrap_lmargin, line_wrap_set_lmargin,
line_wrap_rmargin, line_wrap_set_rmargin, line_wrap_wmargin,
line_wrap_set_wmargin, line_wrap_point): New functions.
* stdio/linewrap.h: New file.
* stdio/Makefile (headers): Add linewrap.h.
Tue May 7 14:19:12 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* sysdeps/unix/sysv/linux/i386/Makefile: File removed.
* stdio/stdio.h: Remove line_wrap_stream, line_unwap_stream decls.
* sysdeps/unix/sysv/linux/schedbits.h: New file.
Tue May 7 13:47:02 1996 Miles Bader <miles@gnu.ai.mit.edu>
* stdio/linewrap.c (struct data): Make margin fields not-pointers.
(lwoutput): Adjust uses acordingly.
* sysdeps/mach/hurd/fdatasync.c: New file.
* sysdeps/mach/hurd/fsync.c: Pass new flag to file_sync.
* sysdeps/mach/hurd/xmknod.c: Pass new flag to dir_link.
* sysdeps/mach/hurd/symlink.c: Likewise.
* sysdeps/mach/hurd/link.c: Likewise.
* sysdeps/mach/hurd/bind.c: Likewise.
* hurd/hurdsig.c (write_corefile): Likewise.
* hurd/hurdsig.c (write_corefile): Pass cttyid port to crash server.
* sysdeps/mach/hurd/fpathconf.c: RPC takes int pointer, not long int.
* sysdeps/mach/hurd/_exit.c (_hurd_exit): Pass sigcode arg to
proc_mark_exit.
* sysdeps/mach/hurd/dl-sysdep.c (_exit): Likewise.
* sysdeps/mach/hurd/wait4.c: Pass sigcode arg to proc_wait.
* sysdeps/mach/hurd/rename.c: Pass new flag to dir_rename.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise): Use struct
hurd_signal_detail.
* hurd/catch-exc.c (_S_catch_exception_raise): Likewise.
* hurd/hurd-raise.c (_hurd_raise_signal): Likewise.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Likewise.
* sysdeps/mach/hurd/setitimer.c (restart_itimer): Likewise.
* hurd/hurd/signal.h: Fix _hurd_exception2signal prototype.
* hurd/hurdsig.c (write_corefile): Take const struct
hurd_signal_detail * arg. Pass all details to crash_dump_task.
(_hurd_internal_post_signal): Pass DETAIL to write_corefile.
(_hurd_internal_post_signal: suspend): Pass code and error to
proc_mark_stop.
* hurd/hurdprio.c (_hurd_priority_which_map): Pass flags arg to
proc_getprocinfo by reference.
1996-05-08 02:07:47 +00:00
|
|
|
int signo, struct hurd_signal_detail *detail,
|
1995-02-18 01:27:10 +00:00
|
|
|
volatile int rpc_wait,
|
|
|
|
struct machine_thread_all_state *state)
|
|
|
|
{
|
1999-07-28 18:19:47 +00:00
|
|
|
void trampoline (void);
|
|
|
|
void rpc_wait_trampoline (void);
|
|
|
|
void firewall (void);
|
1995-08-17 22:55:22 +00:00
|
|
|
extern const void _hurd_intr_rpc_msg_cx_sp;
|
|
|
|
extern const void _hurd_intr_rpc_msg_sp_restored;
|
1995-02-18 01:27:10 +00:00
|
|
|
void *volatile sigsp;
|
|
|
|
struct sigcontext *scp;
|
1996-01-04 17:00:45 +00:00
|
|
|
struct
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
int signo;
|
2020-12-21 00:41:55 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
/* Extra arguments for traditional signal handlers */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
long int sigcode;
|
|
|
|
struct sigcontext *scp; /* Points to ctx, below. */
|
|
|
|
} legacy;
|
|
|
|
|
|
|
|
/* Extra arguments for SA_SIGINFO handlers */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
siginfo_t *siginfop; /* Points to siginfo, below. */
|
|
|
|
ucontext_t *uctxp; /* Points to uctx, below. */
|
|
|
|
} posix;
|
|
|
|
};
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
void *sigreturn_addr;
|
|
|
|
void *sigreturn_returns_here;
|
1995-02-18 01:27:10 +00:00
|
|
|
struct sigcontext *return_scp; /* Same; arg to sigreturn. */
|
2020-12-21 00:41:55 +00:00
|
|
|
|
|
|
|
/* NB: sigreturn assumes link is next to ctx. */
|
1995-02-18 01:27:10 +00:00
|
|
|
struct sigcontext ctx;
|
1995-04-02 22:08:59 +00:00
|
|
|
struct hurd_userlink link;
|
2020-12-21 00:41:55 +00:00
|
|
|
ucontext_t ucontext;
|
|
|
|
siginfo_t siginfo;
|
1995-02-18 01:27:10 +00:00
|
|
|
} *stackframe;
|
|
|
|
|
|
|
|
if (ss->context)
|
|
|
|
{
|
|
|
|
/* We have a previous sigcontext that sigreturn was about
|
|
|
|
to restore when another signal arrived. We will just base
|
|
|
|
our setup on that. */
|
1996-01-04 17:00:45 +00:00
|
|
|
if (! _hurdsig_catch_memory_fault (ss->context))
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
memcpy (&state->basic, &ss->context->sc_i386_thread_state,
|
|
|
|
sizeof (state->basic));
|
|
|
|
memcpy (&state->fpu, &ss->context->sc_i386_float_state,
|
|
|
|
sizeof (state->fpu));
|
2018-03-17 02:17:36 +00:00
|
|
|
state->set |= (1 << i386_REGS_SEGS_STATE) | (1 << i386_FLOAT_STATE);
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
|
|
|
}
|
1995-05-08 09:11:25 +00:00
|
|
|
|
|
|
|
if (! machine_get_basic_state (ss->thread, state))
|
1995-02-18 01:27:10 +00:00
|
|
|
return NULL;
|
|
|
|
|
1995-08-17 22:55:22 +00:00
|
|
|
/* Save the original SP in the gratuitous `esp' slot.
|
|
|
|
We may need to reset the SP (the `uesp' slot) to avoid clobbering an
|
|
|
|
interrupted RPC frame. */
|
|
|
|
state->basic.esp = state->basic.uesp;
|
|
|
|
|
|
|
|
/* This code has intimate knowledge of the special mach_msg system call
|
1996-02-08 02:10:15 +00:00
|
|
|
done in intr-msg.c; that code does (see intr-msg.h):
|
1995-08-17 22:55:22 +00:00
|
|
|
movl %esp, %ecx
|
|
|
|
leal ARGS, %esp
|
|
|
|
_hurd_intr_rpc_msg_cx_sp: movl $-25, %eax
|
|
|
|
_hurd_intr_rpc_msg_do_trap: lcall $7, $0
|
|
|
|
_hurd_intr_rpc_msg_in_trap: movl %ecx, %esp
|
1997-06-23 21:55:26 +00:00
|
|
|
_hurd_intr_rpc_msg_sp_restored:
|
1995-08-17 22:55:22 +00:00
|
|
|
We must check for the window during which %esp points at the
|
|
|
|
mach_msg arguments. The space below until %ecx is used by
|
|
|
|
the _hurd_intr_rpc_mach_msg frame, and must not be clobbered. */
|
2019-12-10 23:23:00 +00:00
|
|
|
if (state->basic.eip >= (int) &_hurd_intr_rpc_msg_cx_sp
|
|
|
|
&& state->basic.eip < (int) &_hurd_intr_rpc_msg_sp_restored)
|
|
|
|
/* The SP now points at the mach_msg args, but there is more stack
|
|
|
|
space used below it. The real SP is saved in %ecx; we must push the
|
|
|
|
new frame below there (if not on the altstack), and restore that value as
|
|
|
|
the SP on sigreturn. */
|
|
|
|
state->basic.uesp = state->basic.ecx;
|
|
|
|
|
hurd: Global signal disposition
This adds _hurd_sigstate_set_global_rcv used by libpthread to enable
POSIX-confirming behavior of signals on a per-thread basis.
This also provides a sigstate destructor _hurd_sigstate_delete, and a
global process signal state, which needs to be locked and check when
global disposition is enabled, thus the addition of _hurd_sigstate_lock
_hurd_sigstate_actions _hurd_sigstate_pending _hurd_sigstate_unlock helpers.
This also updates all the glibc code accordingly.
This also drops support for get_int(INIT_SIGMASK), which did not make sense
any more since we do not have a single signal thread any more.
During fork/spawn, this also reinitializes the child global sigstate's
lock. That cures an issue that would very rarely cause a deadlock in the
child in fork, tries to unlock ss' critical section lock at the end of
fork. This will typically (always?) be observed in /bin/sh, which is not
surprising as that is the foremost caller of fork.
To reproduce an intermediate state, add an endless loop if
_hurd_global_sigstate is locked after __proc_dostop (cast through
volatile); that is, while still being in the fork's parent process.
When that triggers (use the libtool testsuite), the signal thread has
already locked ss (which is _hurd_global_sigstate), and is stuck at
hurdsig.c:685 in post_signal, trying to lock _hurd_siglock (which the
main thread already has locked and keeps locked until after
__task_create). This is the case that ss->thread == MACH_PORT_NULL, that
is, a global signal. In the main thread, between __proc_dostop and
__task_create is the __thread_abort call on the signal thread which would
abort any current kernel operation (but leave ss locked). Later in fork,
in the parent, when _hurd_siglock is unlocked in fork, the parent's
signal thread can proceed and will unlock eventually the global sigstate.
In the client, _hurd_siglock will likewise be unlocked, but the global
sigstate never will be, as the client's signal thread has been configured
to restart execution from _hurd_msgport_receive. Thus, when the child
tries to unlock ss' critical section lock at the end of fork, it will
first lock the global sigstate, will spin trying to lock it, which can
never be successful, and we get our deadlock.
Options seem to be:
* Move the locking of _hurd_siglock earlier in post_signal -- but that
may generally impact performance, if this locking isn't generally
needed anyway?
On the other hand, would it actually make sense to wait here until we
are not any longer in a critical section (which is meant to disable
signal delivery anyway (but not for preempted signals?))?
* Clear the global sigstate in the fork's child with the rationale that
we're anyway restarting the signal thread from a clean state. This
has now been implemented.
Why has this problem not been observed before Jérémie's patches? (Or has
it? Perhaps even more rarely?) In _S_msg_sig_post, the signal is now
posted to a *global receiver thread*, whereas previously it was posted to
the *designated signal-receiving thread*. The latter one was in a
critical section in fork, so didn't try to handle the signal until after
leaving the critical section? (Not completely analyzed and verified.)
Another question is what the signal is that is being received
during/around the time __proc_dostop executes.
2019-12-29 16:59:55 +00:00
|
|
|
if ((action->sa_flags & SA_ONSTACK)
|
2019-12-10 23:23:00 +00:00
|
|
|
&& !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
|
|
|
|
{
|
|
|
|
sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
|
|
|
|
ss->sigaltstack.ss_flags |= SS_ONSTACK;
|
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
else
|
|
|
|
sigsp = (char *) state->basic.uesp;
|
|
|
|
|
|
|
|
/* Push the arguments to call `trampoline' on the stack. */
|
|
|
|
sigsp -= sizeof (*stackframe);
|
|
|
|
stackframe = sigsp;
|
|
|
|
|
1996-01-04 17:00:45 +00:00
|
|
|
if (_hurdsig_catch_memory_fault (stackframe))
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
/* We got a fault trying to write the stack frame.
|
|
|
|
We cannot set up the signal handler.
|
|
|
|
Returning NULL tells our caller, who will nuke us with a SIGILL. */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int ok;
|
|
|
|
|
1995-04-02 22:08:59 +00:00
|
|
|
extern void _hurdsig_longjmp_from_handler (void *, jmp_buf, int);
|
|
|
|
|
|
|
|
/* Add a link to the thread's active-resources list. We mark this as
|
|
|
|
the only user of the "resource", so the cleanup function will be
|
|
|
|
called by any longjmp which is unwinding past the signal frame.
|
|
|
|
The cleanup function (in sigunwind.c) will make sure that all the
|
|
|
|
appropriate cleanups done by sigreturn are taken care of. */
|
|
|
|
stackframe->link.cleanup = &_hurdsig_longjmp_from_handler;
|
|
|
|
stackframe->link.cleanup_data = &stackframe->ctx;
|
|
|
|
stackframe->link.resource.next = NULL;
|
|
|
|
stackframe->link.resource.prevp = NULL;
|
|
|
|
stackframe->link.thread.next = ss->active_resources;
|
|
|
|
stackframe->link.thread.prevp = &ss->active_resources;
|
|
|
|
if (stackframe->link.thread.next)
|
|
|
|
stackframe->link.thread.next->thread.prevp
|
|
|
|
= &stackframe->link.thread.next;
|
|
|
|
ss->active_resources = &stackframe->link;
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
/* Set up the sigcontext from the current state of the thread. */
|
|
|
|
|
2020-12-21 00:41:55 +00:00
|
|
|
scp = &stackframe->ctx;
|
1998-08-08 20:02:34 +00:00
|
|
|
scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
/* struct sigcontext is laid out so that starting at sc_gs mimics a
|
|
|
|
struct i386_thread_state. */
|
|
|
|
memcpy (&scp->sc_i386_thread_state,
|
|
|
|
&state->basic, sizeof (state->basic));
|
|
|
|
|
|
|
|
/* struct sigcontext is laid out so that starting at sc_fpkind mimics
|
|
|
|
a struct i386_float_state. */
|
|
|
|
ok = machine_get_state (ss->thread, state, i386_FLOAT_STATE,
|
|
|
|
&state->fpu, &scp->sc_i386_float_state,
|
|
|
|
sizeof (state->fpu));
|
|
|
|
|
2020-12-21 00:41:55 +00:00
|
|
|
/* Set up the arguments for the signal handler. */
|
|
|
|
stackframe->signo = signo;
|
|
|
|
if (action->sa_flags & SA_SIGINFO)
|
|
|
|
{
|
|
|
|
stackframe->posix.siginfop = &stackframe->siginfo;
|
|
|
|
stackframe->posix.uctxp = &stackframe->ucontext;
|
|
|
|
fill_siginfo (&stackframe->siginfo, signo, detail, state);
|
|
|
|
fill_ucontext (&stackframe->ucontext, scp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (detail->exc)
|
|
|
|
{
|
|
|
|
int nsigno;
|
|
|
|
_hurd_exception2signal_legacy (detail, &nsigno);
|
|
|
|
assert (nsigno == signo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
detail->code = 0;
|
|
|
|
|
|
|
|
stackframe->legacy.sigcode = detail->code;
|
|
|
|
stackframe->legacy.scp = &stackframe->ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up the bottom of the stack. */
|
|
|
|
stackframe->sigreturn_addr = &__sigreturn;
|
|
|
|
stackframe->sigreturn_returns_here = firewall; /* Crash on return. */
|
|
|
|
stackframe->return_scp = &stackframe->ctx;
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
_hurdsig_end_catch_fault ();
|
|
|
|
|
|
|
|
if (! ok)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Modify the thread state to call the trampoline code on the new stack. */
|
|
|
|
if (rpc_wait)
|
|
|
|
{
|
|
|
|
/* The signalee thread was blocked in a mach_msg_trap system call,
|
|
|
|
still waiting for a reply. We will have it run the special
|
|
|
|
trampoline code which retries the message receive before running
|
|
|
|
the signal handler.
|
1996-01-04 17:00:45 +00:00
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
To do this we change the OPTION argument on its stack to enable only
|
|
|
|
message reception, since the request message has already been
|
|
|
|
sent. */
|
|
|
|
|
1995-08-17 22:55:22 +00:00
|
|
|
struct mach_msg_trap_args *args = (void *) state->basic.esp;
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1996-01-04 17:00:45 +00:00
|
|
|
if (_hurdsig_catch_memory_fault (args))
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
|
|
|
/* Faulted accessing ARGS. Bomb. */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert (args->option & MACH_RCV_MSG);
|
|
|
|
/* Disable the message-send, since it has already completed. The
|
|
|
|
calls we retry need only wait to receive the reply message. */
|
|
|
|
args->option &= ~MACH_SEND_MSG;
|
|
|
|
|
1995-08-14 22:49:23 +00:00
|
|
|
/* Limit the time to receive the reply message, in case the server
|
|
|
|
claimed that `interrupt_operation' succeeded but in fact the RPC
|
|
|
|
is hung. */
|
|
|
|
args->option |= MACH_RCV_TIMEOUT;
|
|
|
|
args->timeout = _hurd_interrupted_rpc_timeout;
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
_hurdsig_end_catch_fault ();
|
|
|
|
|
1999-07-28 18:19:47 +00:00
|
|
|
state->basic.eip = (int) rpc_wait_trampoline;
|
1995-02-18 01:27:10 +00:00
|
|
|
/* The reply-receiving trampoline code runs initially on the original
|
|
|
|
user stack. We pass it the signal stack pointer in %ebx. */
|
1995-08-17 22:55:22 +00:00
|
|
|
state->basic.uesp = state->basic.esp; /* Restore mach_msg syscall SP. */
|
1995-02-18 01:27:10 +00:00
|
|
|
state->basic.ebx = (int) sigsp;
|
|
|
|
/* After doing the message receive, the trampoline code will need to
|
|
|
|
update the %eax value to be restored by sigreturn. To simplify
|
|
|
|
the assembly code, we pass the address of its slot in SCP to the
|
|
|
|
trampoline code in %ecx. */
|
|
|
|
state->basic.ecx = (int) &scp->sc_eax;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-28 18:19:47 +00:00
|
|
|
state->basic.eip = (int) trampoline;
|
1995-02-18 01:27:10 +00:00
|
|
|
state->basic.uesp = (int) sigsp;
|
|
|
|
}
|
|
|
|
/* We pass the handler function to the trampoline code in %edx. */
|
|
|
|
state->basic.edx = (int) handler;
|
|
|
|
|
2008-03-08 21:39:00 +00:00
|
|
|
/* The x86 ABI says the DF bit is clear on entry to any function. */
|
|
|
|
state->basic.efl &= ~EFL_DF;
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
return scp;
|
1999-07-28 18:19:47 +00:00
|
|
|
}
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1999-07-28 18:19:47 +00:00
|
|
|
/* The trampoline code follows. This used to be located inside
|
2020-06-08 12:41:57 +00:00
|
|
|
_hurd_setup_sighandler, but was optimized away by gcc 2.95.
|
|
|
|
|
|
|
|
If you modify this, update
|
|
|
|
- in gcc: libgcc/config/i386/gnu-unwind.h x86_gnu_fallback_frame_state,
|
|
|
|
- in gdb: gdb/i386-gnu-tdep.c gnu_sigtramp_code. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1999-07-28 18:19:47 +00:00
|
|
|
asm ("rpc_wait_trampoline:\n");
|
1995-02-18 01:27:10 +00:00
|
|
|
/* This is the entry point when we have an RPC reply message to receive
|
|
|
|
before running the handler. The MACH_MSG_SEND bit has already been
|
|
|
|
cleared in the OPTION argument on our stack. The interrupted user
|
|
|
|
stack pointer has not been changed, so the system call can find its
|
|
|
|
arguments; the signal stack pointer is in %ebx. For our convenience,
|
|
|
|
%ecx points to the sc_eax member of the sigcontext. */
|
1999-07-28 18:19:47 +00:00
|
|
|
asm (/* Retry the interrupted mach_msg system call. */
|
1995-02-18 01:27:10 +00:00
|
|
|
"movl $-25, %eax\n" /* mach_msg_trap */
|
|
|
|
"lcall $7, $0\n"
|
|
|
|
/* When the sigcontext was saved, %eax was MACH_RCV_INTERRUPTED. But
|
|
|
|
now the message receive has completed and the original caller of
|
|
|
|
the RPC (i.e. the code running when the signal arrived) needs to
|
|
|
|
see the final return value of the message receive in %eax. So
|
|
|
|
store the new %eax value into the sc_eax member of the sigcontext
|
|
|
|
(whose address is in %ecx to make this code simpler). */
|
|
|
|
"movl %eax, (%ecx)\n"
|
|
|
|
/* Switch to the signal stack. */
|
|
|
|
"movl %ebx, %esp\n");
|
|
|
|
|
1999-07-28 18:19:47 +00:00
|
|
|
asm ("trampoline:\n");
|
1995-02-18 01:27:10 +00:00
|
|
|
/* Entry point for running the handler normally. The arguments to the
|
|
|
|
handler function are already on the top of the stack:
|
|
|
|
|
|
|
|
0(%esp) SIGNO
|
|
|
|
4(%esp) SIGCODE
|
|
|
|
8(%esp) SCP
|
|
|
|
*/
|
1999-07-28 18:19:47 +00:00
|
|
|
asm ("call *%edx\n" /* Call the handler function. */
|
Thu Mar 16 00:04:41 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/C-ctype.c: New correct data generated by drepper.
* Rules: Don't use $(libc.a).
Parsing of grouped numbers contributed by Ulrich Drepper.
* stdlib/strtol.c (__strtol_internal): Renamed from strtol. Take
new flag arg; if nonzero, parse locale-dependent thousands
grouping and interpret only the prefix that is correctly grouped.
(strtol): Define this to call _strtol_internal with zero for the flag.
Use a weak symbol for the definition.
* stdlib/strtod.c (strtod, __strtod_internal): Likewise.
Check for the exponent of the number overflowing the float format.
* stdlib/stdlib.h (__strtof, __strtold): Declarations removed.
(__strto{f,d,ld,l,ul,q,uq}_internal): Declare these functions.
[__OPTIMIZE__]: Define inline functions calling those.
* stdlib/grouping.h: New file, written by drepper.
* stdlib/Makefile (distribute): Add grouping.h.
* stdio/vfscanf.c: Grok %' modifier to numeric conversions. Call
__strtoX_internal with the grouping flag set iff the modifier is
present.
Wed Mar 15 00:40:54 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/generic/memchr.c: Fix typos: limit.h -> limits.h.
* mach/Machrules: Produce static deps for all object flavors.
[interface-library]: Remove all these variables and rules.
($(interface-library)-routines): Define this variable.
(extra-libs): Append $(interface-library) to this.
* mach/Makefile (interface-library): Omit .a suffix.
* hurd/Makefile: Likewise.
Tue Mar 14 23:40:31 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If !FLUSH_ONLY, don't skip out
early if no new data in buffer after priming.
* Makerules (object-suffixes, libtypes): Move all these variables
to Makeconfig.
* Makeconfig (object-suffixes, libtypes): Moved here from Makerules.
* Makerules (build-extra-lib): New canned sequence.
* sysdeps/mach/hurd/euidaccess.c: Include fcntl.h. Declare ERR;
fix uses of FILE and PORT. Remove bogus weak alias for `access'.
* sysdeps/mach/hurd/dirfd.c: Include hurd/fd.h and errno.h.
Add missing semicolon.
* sysdeps/mach/hurd/opendir.c: Include hurd/fd.h. Use a `struct
hurd_fd *' temp var, since DIRP->__fd is a `void *'.
* sysdeps/mach/hurd/readdir.c: Include hurd/fd.h.
* stdlib/wcstombs.c: #if 0 out code for non-ASCII chars until the
locale data format is implemented.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Pass &__sigreturn on the stack to the trampoline code, so it is
not position-dependent.
* stdio/printf_fp.c (NDEBUG): Define this to disable assert.
Don't include <stdarg.h>.
(__printf_fp): Last arg ARGS is now `const void **const';
dereference ARGS[0] instead of using va_arg.
* locale/setlocale.c: In LC_ALL case, initialize CATEGORY before
loop to install data.
* locale/loadlocale.c (_nl_category_num_items): Use _NL_ITEM_INDEX
to extract number from item code.
(_nl_load_locale): Close the descriptor when finished.
* malloc/realloc.c (_realloc_internal): Call _malloc_internal in
place of malloc.
* time/tzfile.c (__tzfile_default): Initialize RULE_STDOFF to zero.
1995-03-16 05:32:45 +00:00
|
|
|
"addl $12, %esp\n" /* Pop its args. */
|
|
|
|
/* The word at the top of stack is &__sigreturn; following are a dummy
|
|
|
|
word to fill the slot for the address for __sigreturn to return to,
|
|
|
|
and a copy of SCP for __sigreturn's argument. "Return" to calling
|
|
|
|
__sigreturn (SCP); this call never returns. */
|
|
|
|
"ret");
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1999-07-28 18:19:47 +00:00
|
|
|
asm ("firewall:\n"
|
|
|
|
"hlt");
|