diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/siginfo.h | 2 | ||||
-rw-r--r-- | include/asm-parisc/siginfo.h | 5 | ||||
-rw-r--r-- | include/asm-x86/ptrace.h | 6 | ||||
-rw-r--r-- | include/asm-x86/spinlock.h | 60 | ||||
-rw-r--r-- | include/asm-x86/traps.h | 12 |
5 files changed, 42 insertions, 43 deletions
diff --git a/include/asm-generic/siginfo.h b/include/asm-generic/siginfo.h index 8786e01e0db8..969570167e9e 100644 --- a/include/asm-generic/siginfo.h +++ b/include/asm-generic/siginfo.h | |||
@@ -199,6 +199,8 @@ typedef struct siginfo { | |||
199 | */ | 199 | */ |
200 | #define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ | 200 | #define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ |
201 | #define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ | 201 | #define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ |
202 | #define TRAP_BRANCH (__SI_FAULT|3) /* process taken branch trap */ | ||
203 | #define TRAP_HWBKPT (__SI_FAULT|4) /* hardware breakpoint/watchpoint */ | ||
202 | #define NSIGTRAP 2 | 204 | #define NSIGTRAP 2 |
203 | 205 | ||
204 | /* | 206 | /* |
diff --git a/include/asm-parisc/siginfo.h b/include/asm-parisc/siginfo.h index d4909f55fe35..d7034728f377 100644 --- a/include/asm-parisc/siginfo.h +++ b/include/asm-parisc/siginfo.h | |||
@@ -3,11 +3,6 @@ | |||
3 | 3 | ||
4 | #include <asm-generic/siginfo.h> | 4 | #include <asm-generic/siginfo.h> |
5 | 5 | ||
6 | /* | ||
7 | * SIGTRAP si_codes | ||
8 | */ | ||
9 | #define TRAP_BRANCH (__SI_FAULT|3) /* process taken branch trap */ | ||
10 | #define TRAP_HWBKPT (__SI_FAULT|4) /* hardware breakpoint or watchpoint */ | ||
11 | #undef NSIGTRAP | 6 | #undef NSIGTRAP |
12 | #define NSIGTRAP 4 | 7 | #define NSIGTRAP 4 |
13 | 8 | ||
diff --git a/include/asm-x86/ptrace.h b/include/asm-x86/ptrace.h index d64a61097165..ac578f11c1c5 100644 --- a/include/asm-x86/ptrace.h +++ b/include/asm-x86/ptrace.h | |||
@@ -177,11 +177,11 @@ convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs); | |||
177 | 177 | ||
178 | #ifdef CONFIG_X86_32 | 178 | #ifdef CONFIG_X86_32 |
179 | extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, | 179 | extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, |
180 | int error_code); | 180 | int error_code, int si_code); |
181 | #else | ||
182 | void signal_fault(struct pt_regs *regs, void __user *frame, char *where); | ||
183 | #endif | 181 | #endif |
184 | 182 | ||
183 | void signal_fault(struct pt_regs *regs, void __user *frame, char *where); | ||
184 | |||
185 | extern long syscall_trace_enter(struct pt_regs *); | 185 | extern long syscall_trace_enter(struct pt_regs *); |
186 | extern void syscall_trace_leave(struct pt_regs *); | 186 | extern void syscall_trace_leave(struct pt_regs *); |
187 | 187 | ||
diff --git a/include/asm-x86/spinlock.h b/include/asm-x86/spinlock.h index 8badab09146b..157ff7fab97a 100644 --- a/include/asm-x86/spinlock.h +++ b/include/asm-x86/spinlock.h | |||
@@ -21,8 +21,10 @@ | |||
21 | 21 | ||
22 | #ifdef CONFIG_X86_32 | 22 | #ifdef CONFIG_X86_32 |
23 | # define LOCK_PTR_REG "a" | 23 | # define LOCK_PTR_REG "a" |
24 | # define REG_PTR_MODE "k" | ||
24 | #else | 25 | #else |
25 | # define LOCK_PTR_REG "D" | 26 | # define LOCK_PTR_REG "D" |
27 | # define REG_PTR_MODE "q" | ||
26 | #endif | 28 | #endif |
27 | 29 | ||
28 | #if defined(CONFIG_X86_32) && \ | 30 | #if defined(CONFIG_X86_32) && \ |
@@ -54,19 +56,7 @@ | |||
54 | * much between them in performance though, especially as locks are out of line. | 56 | * much between them in performance though, especially as locks are out of line. |
55 | */ | 57 | */ |
56 | #if (NR_CPUS < 256) | 58 | #if (NR_CPUS < 256) |
57 | static inline int __ticket_spin_is_locked(raw_spinlock_t *lock) | 59 | #define TICKET_SHIFT 8 |
58 | { | ||
59 | int tmp = ACCESS_ONCE(lock->slock); | ||
60 | |||
61 | return (((tmp >> 8) & 0xff) != (tmp & 0xff)); | ||
62 | } | ||
63 | |||
64 | static inline int __ticket_spin_is_contended(raw_spinlock_t *lock) | ||
65 | { | ||
66 | int tmp = ACCESS_ONCE(lock->slock); | ||
67 | |||
68 | return (((tmp >> 8) - tmp) & 0xff) > 1; | ||
69 | } | ||
70 | 60 | ||
71 | static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock) | 61 | static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock) |
72 | { | 62 | { |
@@ -89,19 +79,17 @@ static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock) | |||
89 | 79 | ||
90 | static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock) | 80 | static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock) |
91 | { | 81 | { |
92 | int tmp; | 82 | int tmp, new; |
93 | short new; | ||
94 | 83 | ||
95 | asm volatile("movw %2,%w0\n\t" | 84 | asm volatile("movzwl %2, %0\n\t" |
96 | "cmpb %h0,%b0\n\t" | 85 | "cmpb %h0,%b0\n\t" |
86 | "leal 0x100(%" REG_PTR_MODE "0), %1\n\t" | ||
97 | "jne 1f\n\t" | 87 | "jne 1f\n\t" |
98 | "movw %w0,%w1\n\t" | ||
99 | "incb %h1\n\t" | ||
100 | LOCK_PREFIX "cmpxchgw %w1,%2\n\t" | 88 | LOCK_PREFIX "cmpxchgw %w1,%2\n\t" |
101 | "1:" | 89 | "1:" |
102 | "sete %b1\n\t" | 90 | "sete %b1\n\t" |
103 | "movzbl %b1,%0\n\t" | 91 | "movzbl %b1,%0\n\t" |
104 | : "=&a" (tmp), "=Q" (new), "+m" (lock->slock) | 92 | : "=&a" (tmp), "=&q" (new), "+m" (lock->slock) |
105 | : | 93 | : |
106 | : "memory", "cc"); | 94 | : "memory", "cc"); |
107 | 95 | ||
@@ -116,19 +104,7 @@ static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock) | |||
116 | : "memory", "cc"); | 104 | : "memory", "cc"); |
117 | } | 105 | } |
118 | #else | 106 | #else |
119 | static inline int __ticket_spin_is_locked(raw_spinlock_t *lock) | 107 | #define TICKET_SHIFT 16 |
120 | { | ||
121 | int tmp = ACCESS_ONCE(lock->slock); | ||
122 | |||
123 | return (((tmp >> 16) & 0xffff) != (tmp & 0xffff)); | ||
124 | } | ||
125 | |||
126 | static inline int __ticket_spin_is_contended(raw_spinlock_t *lock) | ||
127 | { | ||
128 | int tmp = ACCESS_ONCE(lock->slock); | ||
129 | |||
130 | return (((tmp >> 16) - tmp) & 0xffff) > 1; | ||
131 | } | ||
132 | 108 | ||
133 | static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock) | 109 | static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock) |
134 | { | 110 | { |
@@ -146,7 +122,7 @@ static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock) | |||
146 | /* don't need lfence here, because loads are in-order */ | 122 | /* don't need lfence here, because loads are in-order */ |
147 | "jmp 1b\n" | 123 | "jmp 1b\n" |
148 | "2:" | 124 | "2:" |
149 | : "+Q" (inc), "+m" (lock->slock), "=r" (tmp) | 125 | : "+r" (inc), "+m" (lock->slock), "=&r" (tmp) |
150 | : | 126 | : |
151 | : "memory", "cc"); | 127 | : "memory", "cc"); |
152 | } | 128 | } |
@@ -160,13 +136,13 @@ static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock) | |||
160 | "movl %0,%1\n\t" | 136 | "movl %0,%1\n\t" |
161 | "roll $16, %0\n\t" | 137 | "roll $16, %0\n\t" |
162 | "cmpl %0,%1\n\t" | 138 | "cmpl %0,%1\n\t" |
139 | "leal 0x00010000(%" REG_PTR_MODE "0), %1\n\t" | ||
163 | "jne 1f\n\t" | 140 | "jne 1f\n\t" |
164 | "addl $0x00010000, %1\n\t" | ||
165 | LOCK_PREFIX "cmpxchgl %1,%2\n\t" | 141 | LOCK_PREFIX "cmpxchgl %1,%2\n\t" |
166 | "1:" | 142 | "1:" |
167 | "sete %b1\n\t" | 143 | "sete %b1\n\t" |
168 | "movzbl %b1,%0\n\t" | 144 | "movzbl %b1,%0\n\t" |
169 | : "=&a" (tmp), "=r" (new), "+m" (lock->slock) | 145 | : "=&a" (tmp), "=&q" (new), "+m" (lock->slock) |
170 | : | 146 | : |
171 | : "memory", "cc"); | 147 | : "memory", "cc"); |
172 | 148 | ||
@@ -182,6 +158,20 @@ static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock) | |||
182 | } | 158 | } |
183 | #endif | 159 | #endif |
184 | 160 | ||
161 | static inline int __ticket_spin_is_locked(raw_spinlock_t *lock) | ||
162 | { | ||
163 | int tmp = ACCESS_ONCE(lock->slock); | ||
164 | |||
165 | return !!(((tmp >> TICKET_SHIFT) ^ tmp) & ((1 << TICKET_SHIFT) - 1)); | ||
166 | } | ||
167 | |||
168 | static inline int __ticket_spin_is_contended(raw_spinlock_t *lock) | ||
169 | { | ||
170 | int tmp = ACCESS_ONCE(lock->slock); | ||
171 | |||
172 | return (((tmp >> TICKET_SHIFT) - tmp) & ((1 << TICKET_SHIFT) - 1)) > 1; | ||
173 | } | ||
174 | |||
185 | #ifdef CONFIG_PARAVIRT | 175 | #ifdef CONFIG_PARAVIRT |
186 | /* | 176 | /* |
187 | * Define virtualization-friendly old-style lock byte lock, for use in | 177 | * Define virtualization-friendly old-style lock byte lock, for use in |
diff --git a/include/asm-x86/traps.h b/include/asm-x86/traps.h index 2ccebc6fb0b0..7a692baa51ae 100644 --- a/include/asm-x86/traps.h +++ b/include/asm-x86/traps.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef ASM_X86__TRAPS_H | 1 | #ifndef ASM_X86__TRAPS_H |
2 | #define ASM_X86__TRAPS_H | 2 | #define ASM_X86__TRAPS_H |
3 | 3 | ||
4 | #include <asm/debugreg.h> | ||
5 | |||
4 | /* Common in X86_32 and X86_64 */ | 6 | /* Common in X86_32 and X86_64 */ |
5 | asmlinkage void divide_error(void); | 7 | asmlinkage void divide_error(void); |
6 | asmlinkage void debug(void); | 8 | asmlinkage void debug(void); |
@@ -36,6 +38,16 @@ void do_invalid_op(struct pt_regs *, long); | |||
36 | void do_general_protection(struct pt_regs *, long); | 38 | void do_general_protection(struct pt_regs *, long); |
37 | void do_nmi(struct pt_regs *, long); | 39 | void do_nmi(struct pt_regs *, long); |
38 | 40 | ||
41 | static inline int get_si_code(unsigned long condition) | ||
42 | { | ||
43 | if (condition & DR_STEP) | ||
44 | return TRAP_TRACE; | ||
45 | else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) | ||
46 | return TRAP_HWBKPT; | ||
47 | else | ||
48 | return TRAP_BRKPT; | ||
49 | } | ||
50 | |||
39 | extern int panic_on_unrecovered_nmi; | 51 | extern int panic_on_unrecovered_nmi; |
40 | extern int kstack_depth_to_print; | 52 | extern int kstack_depth_to_print; |
41 | 53 | ||