Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Jan 2021 20:13:47 GMT
From:      Ryan Libby <rlibby@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 82661227eddf - main - arm64: fix mask in atomic_testand{set, clear}_64
Message-ID:  <202101022013.102KDlU3087632@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by rlibby:

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

commit 82661227eddfd22e660bad7cd5f1adbb7c691b48
Author:     Ryan Libby <rlibby@FreeBSD.org>
AuthorDate: 2021-01-02 20:11:18 +0000
Commit:     Ryan Libby <rlibby@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"			\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101022013.102KDlU3087632>