From 803cade3fed2ac226542314064b95ad3648cf568 Mon Sep 17 00:00:00 2001 From: christos Date: Sat, 14 Nov 2015 13:29:35 +0000 Subject: [PATCH] PR/50428: Rin Okuyama: support SA_RESTORER flag for rt_sigaction(2) in the ports that support it. --- sys/compat/linux/arch/alpha/linux_signal.h | 5 ++--- sys/compat/linux/arch/amd64/linux_signal.h | 10 +++++----- sys/compat/linux/arch/mips/linux_signal.h | 7 +++---- sys/compat/linux/common/linux_signal.c | 17 ++++++++--------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/sys/compat/linux/arch/alpha/linux_signal.h b/sys/compat/linux/arch/alpha/linux_signal.h index dca3a8e9a3c8..2f5e26c1ff08 100644 --- a/sys/compat/linux/arch/alpha/linux_signal.h +++ b/sys/compat/linux/arch/alpha/linux_signal.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.h,v 1.9 2008/04/28 20:23:42 martin Exp $ */ +/* $NetBSD: linux_signal.h,v 1.10 2015/11/14 13:29:35 christos Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -92,13 +92,12 @@ #define LINUX_SA_RESETHAND 0x00000010 #define LINUX_SA_NOCLDWAIT 0x00000020 #define LINUX_SA_SIGINFO 0x00000040 -#define LINUX_SA_RESTORER 0x04000000 #define LINUX_SA_NOMASK LINUX_SA_NODEFER #define LINUX_SA_ONESHOT LINUX_SA_RESETHAND #define LINUX_SA_INTERRUPT 0x20000000 /* Ignore this */ -#define LINUX_SA_ALLBITS 0x2400007f +#define LINUX_SA_ALLBITS 0x2000007f #define LINUX_SIG_BLOCK 1 #define LINUX_SIG_UNBLOCK 2 diff --git a/sys/compat/linux/arch/amd64/linux_signal.h b/sys/compat/linux/arch/amd64/linux_signal.h index 21130bd54e09..f164adba7977 100644 --- a/sys/compat/linux/arch/amd64/linux_signal.h +++ b/sys/compat/linux/arch/amd64/linux_signal.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.h,v 1.4 2005/12/11 12:20:14 christos Exp $ */ +/* $NetBSD: linux_signal.h,v 1.5 2015/11/14 13:29:35 christos Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -103,24 +103,24 @@ typedef void (*linux_handler_t)(int); /* struct old_sigaction32 in Linux; uses a 32 bit pointer for handlers */ struct linux_compat_old_sigaction { - int linux_sa_handler; + linux_handler_t linux_sa_handler; linux_old_sigset_t linux_sa_mask; unsigned int linux_sa_flags; - int linux_sa_restorer; + void (*linux_sa_restorer)(void); }; /* Dummy declaration to avoid errors, unused */ struct linux_old_sigaction { linux_handler_t linux_sa_handler; unsigned long linux_sa_flags; - linux_handler_t linux_sa_restorer; + void (*linux_sa_restorer)(void); linux_sigset_t linux_sa_mask; }; struct linux_sigaction { linux_handler_t linux_sa_handler; unsigned long linux_sa_flags; - linux_handler_t linux_sa_restorer; + void (*linux_sa_restorer)(void); linux_sigset_t linux_sa_mask; }; diff --git a/sys/compat/linux/arch/mips/linux_signal.h b/sys/compat/linux/arch/mips/linux_signal.h index 9afe5580cb9d..3325cb03d7a5 100644 --- a/sys/compat/linux/arch/mips/linux_signal.h +++ b/sys/compat/linux/arch/mips/linux_signal.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.h,v 1.13 2008/04/28 20:23:43 martin Exp $ */ +/* $NetBSD: linux_signal.h,v 1.14 2015/11/14 13:29:35 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2001 The NetBSD Foundation, Inc. @@ -104,15 +104,14 @@ struct linux_pt_regs { #define LINUX_SA_NOCLDSTOP 0x00000001 #define LINUX_SA_SIGINFO 0x00000008 #define LINUX_SA_NOCLDWAIT 0x00010000 -#define LINUX_SA_RESTORER 0x04000000 #define LINUX_SA_ONSTACK 0x08000000 #define LINUX_SA_RESTART 0x10000000 -#define LINUX_SA_INTERRUPT 0x20000000 #define LINUX_SA_NODEFER 0x40000000 #define LINUX_SA_RESETHAND 0x80000000 #define LINUX_SA_NOMASK LINUX_SA_NODEFER #define LINUX_SA_ONESHOT LINUX_SA_RESETHAND -#define LINUX_SA_ALLBITS 0xfc010009 /* XXX from i386, not in mips. */ +#define LINUX_SA_ALLBITS 0xd8010009 +/* XXX LINUX_SA_RESTORER has been deprecated; not used any version of glibc */ #define LINUX_MINSIGSTKSZ 2048 diff --git a/sys/compat/linux/common/linux_signal.c b/sys/compat/linux/common/linux_signal.c index 4d290c39a5d4..f3074fc8b21d 100644 --- a/sys/compat/linux/common/linux_signal.c +++ b/sys/compat/linux/common/linux_signal.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.c,v 1.76 2014/11/09 17:48:08 maxv Exp $ */ +/* $NetBSD: linux_signal.c,v 1.77 2015/11/14 13:29:35 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.76 2014/11/09 17:48:08 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.77 2015/11/14 13:29:35 christos Exp $"); #define COMPAT_LINUX 1 @@ -331,7 +331,7 @@ linux_sys_rt_sigaction(struct lwp *l, const struct linux_sys_rt_sigaction_args * int error, sig; void *tramp = NULL; int vers = 0; -#if defined __amd64__ +#ifdef LINUX_SA_RESTORER struct sigacts *ps = l->l_proc->p_sigacts; #endif @@ -354,11 +354,10 @@ linux_sys_rt_sigaction(struct lwp *l, const struct linux_sys_rt_sigaction_args * sigemptyset(&obsa.sa_mask); obsa.sa_flags = 0; } else { -#if defined __amd64__ - if (nlsa.linux_sa_flags & LINUX_SA_RESTORER) { - if ((tramp = nlsa.linux_sa_restorer) != NULL) - vers = 2; /* XXX arch dependent */ - } +#ifdef LINUX_SA_RESTORER + if ((nlsa.linux_sa_flags & LINUX_SA_RESTORER) && + (tramp = nlsa.linux_sa_restorer) != NULL) + vers = 2; #endif error = sigaction1(l, linux_to_native_signo[sig], @@ -371,7 +370,7 @@ linux_sys_rt_sigaction(struct lwp *l, const struct linux_sys_rt_sigaction_args * if (SCARG(uap, osa)) { native_to_linux_sigaction(&olsa, &obsa); -#if defined __amd64__ +#ifdef LINUX_SA_RESTORER if (ps->sa_sigdesc[sig].sd_vers != 0) { olsa.linux_sa_restorer = ps->sa_sigdesc[sig].sd_tramp; olsa.linux_sa_flags |= LINUX_SA_RESTORER;