aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Libby <rlibby@FreeBSD.org>2021-01-02 20:11:18 +0000
committerRyan Libby <rlibby@FreeBSD.org>2021-01-02 20:13:25 +0000
commit82661227eddfd22e660bad7cd5f1adbb7c691b48 (patch)
treea06da06552b1c73dece799f017e82bfa9c827fd9
parent3630506b9daec9167a89bc4525638ea45a00769e (diff)
downloadsrc-82661227eddfd22e660bad7cd5f1adbb7c691b48.tar.gz
src-82661227eddfd22e660bad7cd5f1adbb7c691b48.zip
arm64: fix mask in atomic_testand{set,clear}_64
These macros generate both the 32- and 64-bit ops, but the mask was hard coded for 32-bit ops, causing the 64-bit ops always to affect only the low 32 bits. PR: 252324 Reported by: gbe, mmel Reviewed by: markj, mmel Tested by: mmel, rwatson Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D27886
-rw-r--r--sys/arm64/include/atomic.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/arm64/include/atomic.h b/sys/arm64/include/atomic.h
index 99dd73d4f85f..9c5d6224f3e2 100644
--- a/sys/arm64/include/atomic.h
+++ b/sys/arm64/include/atomic.h
@@ -409,7 +409,7 @@ _ATOMIC_TEST_OP_PROTO(t, op, _llsc) \
uint##t##_t mask, old, tmp; \
int res; \
\
- mask = 1u << (val & 0x1f); \
+ mask = ((uint##t##_t)1) << (val & (t - 1)); \
__asm __volatile( \
"1: ldxr %"#w"2, [%3]\n" \
" "#llsc_asm_op" %"#w"0, %"#w"2, %"#w"4\n" \
@@ -427,7 +427,7 @@ _ATOMIC_TEST_OP_PROTO(t, op, _lse) \
{ \
uint##t##_t mask, old; \
\
- mask = 1u << (val & 0x1f); \
+ mask = ((uint##t##_t)1) << (val & (t - 1)); \
__asm __volatile( \
".arch_extension lse\n" \
"ld"#lse_asm_op" %"#w"2, %"#w"0, [%1]\n" \