diff options
author | Will Deacon <will.deacon@arm.com> | 2015-05-29 09:44:06 -0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2015-07-27 10:28:54 -0400 |
commit | db26217e6f54647b137a0fe1f2ab346de67d6f3e (patch) | |
tree | 5c839d3429de197f511161be339bcdacb786d471 | |
parent | 6059a7b6e818023436a9058170a4fea1c670dc98 (diff) |
arm64: atomic64_dec_if_positive: fix incorrect branch condition
If we attempt to atomic64_dec_if_positive on INT_MIN, we will underflow
and incorrectly decide that the original parameter was positive.
This patches fixes the broken condition code so that we handle this
corner case correctly.
Reviewed-by: Steve Capper <steve.capper@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r-- | arch/arm64/include/asm/atomic_ll_sc.h | 2 | ||||
-rw-r--r-- | arch/arm64/include/asm/atomic_lse.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/arch/arm64/include/asm/atomic_ll_sc.h b/arch/arm64/include/asm/atomic_ll_sc.h index 5e2d1db3a1db..6671978e60fe 100644 --- a/arch/arm64/include/asm/atomic_ll_sc.h +++ b/arch/arm64/include/asm/atomic_ll_sc.h | |||
@@ -159,7 +159,7 @@ __LL_SC_PREFIX(atomic64_dec_if_positive(atomic64_t *v)) | |||
159 | " prfm pstl1strm, %2\n" | 159 | " prfm pstl1strm, %2\n" |
160 | "1: ldxr %0, %2\n" | 160 | "1: ldxr %0, %2\n" |
161 | " subs %0, %0, #1\n" | 161 | " subs %0, %0, #1\n" |
162 | " b.mi 2f\n" | 162 | " b.lt 2f\n" |
163 | " stlxr %w1, %0, %2\n" | 163 | " stlxr %w1, %0, %2\n" |
164 | " cbnz %w1, 1b\n" | 164 | " cbnz %w1, 1b\n" |
165 | " dmb ish\n" | 165 | " dmb ish\n" |
diff --git a/arch/arm64/include/asm/atomic_lse.h b/arch/arm64/include/asm/atomic_lse.h index 30e5cbcfc707..f873bf61e17b 100644 --- a/arch/arm64/include/asm/atomic_lse.h +++ b/arch/arm64/include/asm/atomic_lse.h | |||
@@ -291,7 +291,7 @@ static inline long atomic64_dec_if_positive(atomic64_t *v) | |||
291 | /* LSE atomics */ | 291 | /* LSE atomics */ |
292 | "1: ldr x30, %[v]\n" | 292 | "1: ldr x30, %[v]\n" |
293 | " subs %[ret], x30, #1\n" | 293 | " subs %[ret], x30, #1\n" |
294 | " b.mi 2f\n" | 294 | " b.lt 2f\n" |
295 | " casal x30, %[ret], %[v]\n" | 295 | " casal x30, %[ret], %[v]\n" |
296 | " sub x30, x30, #1\n" | 296 | " sub x30, x30, #1\n" |
297 | " sub x30, x30, %[ret]\n" | 297 | " sub x30, x30, %[ret]\n" |