aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/include
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2012-05-29 04:11:21 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2012-05-30 03:07:57 -0400
commitbf3db85311292eeacc9a9a8f38a0a4065a43a2fc (patch)
tree3061cba9ea7ba20905ebb202a81c6da76debfe6d /arch/s390/include
parent6b894a409e8c0fcbd0ea30f5b013e33b9c4b28a1 (diff)
s390/cmpxchg: fix 1 and 2 byte memory accesses
When accessing a 1 or 2 byte memory operand we cannot use the passed address since the compare and swap instruction only works for 4 byte aligned memory operands. Hence we calculate an aligned address so that compare and swap works correctly. However we don't pass the calculated address to the inline assembly. This results in incorrect memory accesses and in a specification exception if used on non 4 byte aligned memory operands. Since this didn't happen until now, there don't seem to be too many users of cmpxchg on unaligned addresses. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/include')
-rw-r--r--arch/s390/include/asm/cmpxchg.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/s390/include/asm/cmpxchg.h b/arch/s390/include/asm/cmpxchg.h
index 13c8b2eb6983..26f2cb1aa9ff 100644
--- a/arch/s390/include/asm/cmpxchg.h
+++ b/arch/s390/include/asm/cmpxchg.h
@@ -113,9 +113,9 @@ static inline unsigned long __cmpxchg(void *ptr, unsigned long old,
113 " nr %1,%5\n" 113 " nr %1,%5\n"
114 " jnz 0b\n" 114 " jnz 0b\n"
115 "1:" 115 "1:"
116 : "=&d" (prev), "=&d" (tmp), "=Q" (*(int *) ptr) 116 : "=&d" (prev), "=&d" (tmp), "+Q" (*(int *) addr)
117 : "d" (old << shift), "d" (new << shift), 117 : "d" (old << shift), "d" (new << shift),
118 "d" (~(255 << shift)), "Q" (*(int *) ptr) 118 "d" (~(255 << shift))
119 : "memory", "cc"); 119 : "memory", "cc");
120 return prev >> shift; 120 return prev >> shift;
121 case 2: 121 case 2:
@@ -134,9 +134,9 @@ static inline unsigned long __cmpxchg(void *ptr, unsigned long old,
134 " nr %1,%5\n" 134 " nr %1,%5\n"
135 " jnz 0b\n" 135 " jnz 0b\n"
136 "1:" 136 "1:"
137 : "=&d" (prev), "=&d" (tmp), "=Q" (*(int *) ptr) 137 : "=&d" (prev), "=&d" (tmp), "+Q" (*(int *) addr)
138 : "d" (old << shift), "d" (new << shift), 138 : "d" (old << shift), "d" (new << shift),
139 "d" (~(65535 << shift)), "Q" (*(int *) ptr) 139 "d" (~(65535 << shift))
140 : "memory", "cc"); 140 : "memory", "cc");
141 return prev >> shift; 141 return prev >> shift;
142 case 4: 142 case 4: