git: 82661227eddf - main - arm64: fix mask in atomic_testand{set, clear}_64

Ryan Libby rlibby at FreeBSD.org
Sat Jan 2 20:13:47 UTC 2021


The branch main has been updated by rlibby:

URL: https://cgit.FreeBSD.org/src/commit/?id=82661227eddfd22e660bad7cd5f1adbb7c691b48

commit 82661227eddfd22e660bad7cd5f1adbb7c691b48
Author:     Ryan Libby <rlibby at FreeBSD.org>
AuthorDate: 2021-01-02 20:11:18 +0000
Commit:     Ryan Libby <rlibby at FreeBSD.org>
CommitDate: 2021-01-02 20:13:25 +0000

    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
---
 sys/arm64/include/atomic.h | 4 ++--
 1 file 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"			\


More information about the dev-commits-src-all mailing list