aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-s390/system.h
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2007-10-12 10:11:41 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2007-10-12 10:13:08 -0400
commit210d3a90ce665509e4852977d7a3352654e5e990 (patch)
treedb757ee80cd43e0c083830f9815a86f3a5a4b89c /include/asm-s390/system.h
parentc622498e5c82217cda7f661eebbabdaad0814659 (diff)
[S390] Force link error if xchg/cmpxchg gets called with unsupported size.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'include/asm-s390/system.h')
-rw-r--r--include/asm-s390/system.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/include/asm-s390/system.h b/include/asm-s390/system.h
index 64a3cd05cae1..d866d3385556 100644
--- a/include/asm-s390/system.h
+++ b/include/asm-s390/system.h
@@ -130,6 +130,8 @@ extern void pfault_fini(void);
130 __ret; \ 130 __ret; \
131}) 131})
132 132
133extern void __xchg_called_with_bad_pointer(void);
134
133static inline unsigned long __xchg(unsigned long x, void * ptr, int size) 135static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
134{ 136{
135 unsigned long addr, old; 137 unsigned long addr, old;
@@ -150,8 +152,7 @@ static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
150 : "=&d" (old), "=m" (*(int *) addr) 152 : "=&d" (old), "=m" (*(int *) addr)
151 : "d" (x << shift), "d" (~(255 << shift)), "a" (addr), 153 : "d" (x << shift), "d" (~(255 << shift)), "a" (addr),
152 "m" (*(int *) addr) : "memory", "cc", "0"); 154 "m" (*(int *) addr) : "memory", "cc", "0");
153 x = old >> shift; 155 return old >> shift;
154 break;
155 case 2: 156 case 2:
156 addr = (unsigned long) ptr; 157 addr = (unsigned long) ptr;
157 shift = (2 ^ (addr & 2)) << 3; 158 shift = (2 ^ (addr & 2)) << 3;
@@ -166,8 +167,7 @@ static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
166 : "=&d" (old), "=m" (*(int *) addr) 167 : "=&d" (old), "=m" (*(int *) addr)
167 : "d" (x << shift), "d" (~(65535 << shift)), "a" (addr), 168 : "d" (x << shift), "d" (~(65535 << shift)), "a" (addr),
168 "m" (*(int *) addr) : "memory", "cc", "0"); 169 "m" (*(int *) addr) : "memory", "cc", "0");
169 x = old >> shift; 170 return old >> shift;
170 break;
171 case 4: 171 case 4:
172 asm volatile( 172 asm volatile(
173 " l %0,0(%3)\n" 173 " l %0,0(%3)\n"
@@ -176,8 +176,7 @@ static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
176 : "=&d" (old), "=m" (*(int *) ptr) 176 : "=&d" (old), "=m" (*(int *) ptr)
177 : "d" (x), "a" (ptr), "m" (*(int *) ptr) 177 : "d" (x), "a" (ptr), "m" (*(int *) ptr)
178 : "memory", "cc"); 178 : "memory", "cc");
179 x = old; 179 return old;
180 break;
181#ifdef __s390x__ 180#ifdef __s390x__
182 case 8: 181 case 8:
183 asm volatile( 182 asm volatile(
@@ -187,11 +186,11 @@ static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
187 : "=&d" (old), "=m" (*(long *) ptr) 186 : "=&d" (old), "=m" (*(long *) ptr)
188 : "d" (x), "a" (ptr), "m" (*(long *) ptr) 187 : "d" (x), "a" (ptr), "m" (*(long *) ptr)
189 : "memory", "cc"); 188 : "memory", "cc");
190 x = old; 189 return old;
191 break;
192#endif /* __s390x__ */ 190#endif /* __s390x__ */
193 } 191 }
194 return x; 192 __xchg_called_with_bad_pointer();
193 return x;
195} 194}
196 195
197/* 196/*
@@ -206,6 +205,8 @@ static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
206 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ 205 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
207 (unsigned long)(n),sizeof(*(ptr)))) 206 (unsigned long)(n),sizeof(*(ptr))))
208 207
208extern void __cmpxchg_called_with_bad_pointer(void);
209
209static inline unsigned long 210static inline unsigned long
210__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) 211__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
211{ 212{
@@ -270,7 +271,8 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
270 return prev; 271 return prev;
271#endif /* __s390x__ */ 272#endif /* __s390x__ */
272 } 273 }
273 return old; 274 __cmpxchg_called_with_bad_pointer();
275 return old;
274} 276}
275 277
276/* 278/*