提交 db26217e 编写于 作者: W Will Deacon

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: NSteve Capper <steve.capper@arm.com>
Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: NWill Deacon <will.deacon@arm.com>
上级 6059a7b6
...@@ -159,7 +159,7 @@ __LL_SC_PREFIX(atomic64_dec_if_positive(atomic64_t *v)) ...@@ -159,7 +159,7 @@ __LL_SC_PREFIX(atomic64_dec_if_positive(atomic64_t *v))
" prfm pstl1strm, %2\n" " prfm pstl1strm, %2\n"
"1: ldxr %0, %2\n" "1: ldxr %0, %2\n"
" subs %0, %0, #1\n" " subs %0, %0, #1\n"
" b.mi 2f\n" " b.lt 2f\n"
" stlxr %w1, %0, %2\n" " stlxr %w1, %0, %2\n"
" cbnz %w1, 1b\n" " cbnz %w1, 1b\n"
" dmb ish\n" " dmb ish\n"
......
...@@ -291,7 +291,7 @@ static inline long atomic64_dec_if_positive(atomic64_t *v) ...@@ -291,7 +291,7 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
/* LSE atomics */ /* LSE atomics */
"1: ldr x30, %[v]\n" "1: ldr x30, %[v]\n"
" subs %[ret], x30, #1\n" " subs %[ret], x30, #1\n"
" b.mi 2f\n" " b.lt 2f\n"
" casal x30, %[ret], %[v]\n" " casal x30, %[ret], %[v]\n"
" sub x30, x30, #1\n" " sub x30, x30, #1\n"
" sub x30, x30, %[ret]\n" " sub x30, x30, %[ret]\n"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册