Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 2 | #ifndef _ASM_X86_SIGNAL_H |
| 3 | #define _ASM_X86_SIGNAL_H |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 4 | |
| 5 | #ifndef __ASSEMBLY__ |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 6 | #include <linux/linkage.h> |
| 7 | |
| 8 | /* Most things should be clean enough to redefine this at will, if care |
| 9 | is taken to make libc match. */ |
| 10 | |
| 11 | #define _NSIG 64 |
| 12 | |
| 13 | #ifdef __i386__ |
| 14 | # define _NSIG_BPW 32 |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 15 | #else |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 16 | # define _NSIG_BPW 64 |
| 17 | #endif |
| 18 | |
| 19 | #define _NSIG_WORDS (_NSIG / _NSIG_BPW) |
| 20 | |
| 21 | typedef unsigned long old_sigset_t; /* at least 32 bits */ |
| 22 | |
| 23 | typedef struct { |
| 24 | unsigned long sig[_NSIG_WORDS]; |
| 25 | } sigset_t; |
| 26 | |
Dmitry Safonov | 6846351 | 2016-09-05 16:33:08 +0300 | [diff] [blame] | 27 | /* non-uapi in-kernel SA_FLAGS for those indicates ABI for a signal frame */ |
| 28 | #define SA_IA32_ABI 0x02000000u |
| 29 | #define SA_X32_ABI 0x01000000u |
| 30 | |
Suresh Siddha | 050902c | 2012-07-24 16:05:27 -0700 | [diff] [blame] | 31 | #ifndef CONFIG_COMPAT |
Arnd Bergmann | 1a33b18 | 2021-07-22 16:28:58 +0200 | [diff] [blame] | 32 | #define compat_sigset_t compat_sigset_t |
Suresh Siddha | 050902c | 2012-07-24 16:05:27 -0700 | [diff] [blame] | 33 | typedef sigset_t compat_sigset_t; |
| 34 | #endif |
| 35 | |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 36 | #endif /* __ASSEMBLY__ */ |
David Howells | af170c5 | 2012-12-14 22:37:13 +0000 | [diff] [blame] | 37 | #include <uapi/asm/signal.h> |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 38 | #ifndef __ASSEMBLY__ |
Al Viro | 574c486 | 2012-11-25 22:24:19 -0500 | [diff] [blame] | 39 | |
| 40 | #define __ARCH_HAS_SA_RESTORER |
| 41 | |
Uros Bizjak | 26e609e | 2018-08-14 18:59:51 +0200 | [diff] [blame] | 42 | #include <asm/asm.h> |
Ingo Molnar | decb4c4 | 2015-09-05 09:32:43 +0200 | [diff] [blame] | 43 | #include <uapi/asm/sigcontext.h> |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 44 | |
Herton Ronaldo Krzesinski | 723edb5 | 2008-07-14 17:40:23 -0300 | [diff] [blame] | 45 | #ifdef __i386__ |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 46 | |
| 47 | #define __HAVE_ARCH_SIG_BITOPS |
| 48 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 49 | #define sigaddset(set,sig) \ |
Herton Ronaldo Krzesinski | 723edb5 | 2008-07-14 17:40:23 -0300 | [diff] [blame] | 50 | (__builtin_constant_p(sig) \ |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 51 | ? __const_sigaddset((set), (sig)) \ |
| 52 | : __gen_sigaddset((set), (sig))) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 53 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 54 | static inline void __gen_sigaddset(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 55 | { |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 56 | asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 57 | } |
| 58 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 59 | static inline void __const_sigaddset(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 60 | { |
| 61 | unsigned long sig = _sig - 1; |
| 62 | set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW); |
| 63 | } |
| 64 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 65 | #define sigdelset(set, sig) \ |
| 66 | (__builtin_constant_p(sig) \ |
| 67 | ? __const_sigdelset((set), (sig)) \ |
| 68 | : __gen_sigdelset((set), (sig))) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 69 | |
| 70 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 71 | static inline void __gen_sigdelset(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 72 | { |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 73 | asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 74 | } |
| 75 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 76 | static inline void __const_sigdelset(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 77 | { |
| 78 | unsigned long sig = _sig - 1; |
| 79 | set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW)); |
| 80 | } |
| 81 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 82 | static inline int __const_sigismember(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 83 | { |
| 84 | unsigned long sig = _sig - 1; |
| 85 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); |
| 86 | } |
| 87 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 88 | static inline int __gen_sigismember(sigset_t *set, int _sig) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 89 | { |
Uros Bizjak | 26e609e | 2018-08-14 18:59:51 +0200 | [diff] [blame] | 90 | bool ret; |
| 91 | asm("btl %2,%1" CC_SET(c) |
| 92 | : CC_OUT(c) (ret) : "m"(*set), "Ir"(_sig-1)); |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 93 | return ret; |
| 94 | } |
| 95 | |
Joe Perches | 9551b12 | 2008-03-23 01:03:28 -0700 | [diff] [blame] | 96 | #define sigismember(set, sig) \ |
| 97 | (__builtin_constant_p(sig) \ |
| 98 | ? __const_sigismember((set), (sig)) \ |
| 99 | : __gen_sigismember((set), (sig))) |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 100 | |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 101 | struct pt_regs; |
| 102 | |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 103 | #else /* __i386__ */ |
| 104 | |
| 105 | #undef __HAVE_ARCH_SIG_BITOPS |
| 106 | |
Roland McGrath | e1f2877 | 2008-01-30 13:30:50 +0100 | [diff] [blame] | 107 | #endif /* !__i386__ */ |
| 108 | |
Thomas Gleixner | 33185c5 | 2007-10-23 22:37:24 +0200 | [diff] [blame] | 109 | #endif /* __ASSEMBLY__ */ |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 110 | #endif /* _ASM_X86_SIGNAL_H */ |