From nobody Sun Dec 01 04:57:27 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Y1F5h3Fttz5gDCd; Sun, 01 Dec 2024 04:57:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y1F5h11G1z4B3d; Sun, 1 Dec 2024 04:57:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733029048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RnUnamxfCrx3CpvUKo23uXrkm99BUWXmQ0TMhhWTdMk=; b=NsUSIGl2+2q7zWCkMk3v+vRpppGk8M9j8gaQEhqunZeiBFGFdulUv/3GyOVJavP5JFmZjG 00T7Vvd10Igy4T8IHOq2dPrYjHQqoMow5o0T5g4PM5c4h+coMIcIFkvrXWAw9VLItdoR58 gCIUUCQeY+UKkpGI6d2RVsPu6y2ed2UprVyjinQFmgILO+QDD2JSzu74Dv6v+CExJ7xSLa i6CPgjM0VLfEOlt1gfH3LhfJcNiN/UFlZLcsaPNsdFj4+Hv9L89cz5D8ZsMmfsENMEIs9v 9RqjA/cDu4zKh7IUJ6NkAN7Yq93mtCVDh8Z+eYjXJHpbmGMQfBOWQJXkJuc4hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733029048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RnUnamxfCrx3CpvUKo23uXrkm99BUWXmQ0TMhhWTdMk=; b=uz9NFtULrrfzYB/3GXq4XzOUHdswDZlqkgN2mJFNXmCjf2eU2ZeuKcIP9rdDLSl9pP59WR 2pZuMDKy4aThArY0pL8Wg67drJVbKAZay4Yj/t8M8pfReHm2a1QkWF7RtEMJX5d755o/sT bm8oSyJTrTIL4Lpz5ASeoYR3gcTfrxKOhHYpXaovu4qYsxhbaapzuYLfBL2TYJGPFyslWp xMbTX3mqywu1W+l9GyhTNtmrJfQdGX7EnYyN29Xis9RBW8uioIBj3JuyXBU7TtrOYGxMQr 42aXB4r4Gj8epZEtjhDikO+0lpTLpHSSKr/TH91lKmEtdNRmnnXiE35PRaZfWQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733029048; a=rsa-sha256; cv=none; b=f/sAhOkpTGXIRXMbSA5QXMG51YDzpAMocgkRnHEUH8zvwy/LPGajSGJW1+C1ODldyI8IAh OF6ph0oI+F7nl2syVhrEuwTOw69GDRc+sb+HQN69s2xJqNv+nOwptqKvQMPOrVo4//0/PL zYXUsCO1NL/yzelR8WD99N8avIFWIP9l22RlFpjrsYsMBtUeh/1m6pCneGG1JJuocDLq1U lc+3QZCV4OCt8UdhcC/0qWFPholEg8qdo/b+6fssoUAfkXB+pQU+MHXsDdILhP4yz5L7Jm 53rSJOo/NISI5SeGF/rDrargsFOK5q2SpLsdLS8BvZb1xfkO3exB/TaR3psDgA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Y1F5g7325zfLL; Sun, 1 Dec 2024 04:57:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4B14vROS096002; Sun, 1 Dec 2024 04:57:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B14vR4Z095999; Sun, 1 Dec 2024 04:57:27 GMT (envelope-from git) Date: Sun, 1 Dec 2024 04:57:27 GMT Message-Id: <202412010457.4B14vR4Z095999@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: b291c7168a78 - stable/14 - atomic(9): Implement atomic_testand(clear|set)_ptr List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: b291c7168a7840a74c4e976a91dec21ff0f1e4ce Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b291c7168a7840a74c4e976a91dec21ff0f1e4ce commit b291c7168a7840a74c4e976a91dec21ff0f1e4ce Author: John Baldwin AuthorDate: 2024-11-19 15:24:50 +0000 Commit: John Baldwin CommitDate: 2024-12-01 02:46:08 +0000 atomic(9): Implement atomic_testand(clear|set)_ptr For current architectures, these are just aliases for the existing operation on the relevant scalar integer. Reviewed by: imp, kib Obtained from: CheriBSD Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D47631 (cherry picked from commit a80b9ee15aa0f2da9f9f0c48e13324e0e5f2e840) --- share/man/man9/atomic.9 | 1 + sys/amd64/include/atomic.h | 2 ++ sys/arm/include/atomic.h | 2 ++ sys/arm64/include/atomic.h | 2 ++ sys/i386/include/atomic.h | 4 ++++ sys/kern/subr_asan.c | 2 ++ sys/kern/subr_csan.c | 2 -- sys/kern/subr_msan.c | 2 ++ sys/powerpc/include/atomic.h | 10 ++++++++++ sys/riscv/include/atomic.h | 2 ++ 10 files changed, 27 insertions(+), 2 deletions(-) diff --git a/share/man/man9/atomic.9 b/share/man/man9/atomic.9 index 436cfb7ee225..581aac9878c8 100644 --- a/share/man/man9/atomic.9 +++ b/share/man/man9/atomic.9 @@ -481,6 +481,7 @@ and functions are only implemented for the types .Dq Li int , .Dq Li long , +.Dq ptr , .Dq Li 32 , and .Dq Li 64 diff --git a/sys/amd64/include/atomic.h b/sys/amd64/include/atomic.h index e5f21b2efd05..8eb3fddb0478 100644 --- a/sys/amd64/include/atomic.h +++ b/sys/amd64/include/atomic.h @@ -589,6 +589,8 @@ atomic_swap_long(volatile u_long *p, u_long v) #define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long #define atomic_swap_ptr atomic_swap_long #define atomic_readandclear_ptr atomic_readandclear_long +#define atomic_testandset_ptr atomic_testandset_long +#define atomic_testandclear_ptr atomic_testandclear_long #endif /* !WANT_FUNCTIONS */ diff --git a/sys/arm/include/atomic.h b/sys/arm/include/atomic.h index f39de8eaabdf..73e769885f71 100644 --- a/sys/arm/include/atomic.h +++ b/sys/arm/include/atomic.h @@ -1082,6 +1082,8 @@ atomic_thread_fence_seq_cst(void) #define atomic_load_acq_ptr atomic_load_acq_32 #define atomic_store_rel_ptr atomic_store_rel_32 #define atomic_swap_ptr atomic_swap_32 +#define atomic_testandset_ptr atomic_testandset_32 +#define atomic_testandclear_ptr atomic_testandclear_32 #define atomic_add_int atomic_add_32 #define atomic_add_acq_int atomic_add_acq_32 diff --git a/sys/arm64/include/atomic.h b/sys/arm64/include/atomic.h index c7aaa76d9de9..f7018f2f9e0b 100644 --- a/sys/arm64/include/atomic.h +++ b/sys/arm64/include/atomic.h @@ -609,6 +609,8 @@ _ATOMIC_STORE_REL_IMPL(64, , ) #define atomic_set_ptr atomic_set_64 #define atomic_swap_ptr atomic_swap_64 #define atomic_subtract_ptr atomic_subtract_64 +#define atomic_testandclear_ptr atomic_testandclear_64 +#define atomic_testandset_ptr atomic_testandset_64 #define atomic_add_acq_long atomic_add_acq_64 #define atomic_fcmpset_acq_long atomic_fcmpset_acq_64 diff --git a/sys/i386/include/atomic.h b/sys/i386/include/atomic.h index 5aca9fb15181..71aa09c57007 100644 --- a/sys/i386/include/atomic.h +++ b/sys/i386/include/atomic.h @@ -865,6 +865,10 @@ atomic_swap_long(volatile u_long *p, u_long v) atomic_swap_int((volatile u_int *)(p), (u_int)(v)) #define atomic_readandclear_ptr(p) \ atomic_readandclear_int((volatile u_int *)(p)) +#define atomic_testandclear_ptr(p, val) \ + atomic_testandclear_int((volatile u_int *)(p), (val)) +#define atomic_testandset_ptr(p, val) \ + atomic_testandset_int((volatile u_int *)(p), (val)) #endif /* !WANT_FUNCTIONS */ diff --git a/sys/kern/subr_asan.c b/sys/kern/subr_asan.c index c3664d9cf6c2..bd143a816932 100644 --- a/sys/kern/subr_asan.c +++ b/sys/kern/subr_asan.c @@ -817,11 +817,13 @@ ASAN_ATOMIC_FUNC_TESTANDCLEAR(32, uint32_t); ASAN_ATOMIC_FUNC_TESTANDCLEAR(64, uint64_t); ASAN_ATOMIC_FUNC_TESTANDCLEAR(int, u_int); ASAN_ATOMIC_FUNC_TESTANDCLEAR(long, u_long); +ASAN_ATOMIC_FUNC_TESTANDCLEAR(ptr, uintptr_t); ASAN_ATOMIC_FUNC_TESTANDSET(32, uint32_t); ASAN_ATOMIC_FUNC_TESTANDSET(64, uint64_t); ASAN_ATOMIC_FUNC_TESTANDSET(int, u_int); ASAN_ATOMIC_FUNC_TESTANDSET(long, u_long); +ASAN_ATOMIC_FUNC_TESTANDSET(ptr, uintptr_t); ASAN_ATOMIC_FUNC_SWAP(32, uint32_t); ASAN_ATOMIC_FUNC_SWAP(64, uint64_t); diff --git a/sys/kern/subr_csan.c b/sys/kern/subr_csan.c index 0c238bf9684a..368f8b6ba981 100644 --- a/sys/kern/subr_csan.c +++ b/sys/kern/subr_csan.c @@ -659,10 +659,8 @@ CSAN_ATOMIC_FUNC_SET(ptr, uintptr_t) CSAN_ATOMIC_FUNC_SUBTRACT(ptr, uintptr_t) CSAN_ATOMIC_FUNC_STORE(ptr, uintptr_t) CSAN_ATOMIC_FUNC_SWAP(ptr, uintptr_t) -#if 0 CSAN_ATOMIC_FUNC_TESTANDCLEAR(ptr, uintptr_t) CSAN_ATOMIC_FUNC_TESTANDSET(ptr, uintptr_t) -#endif #define CSAN_ATOMIC_FUNC_THREAD_FENCE(name) \ void kcsan_atomic_thread_fence_##name(void) \ diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c index ef3c6c10b0ba..029c5ed8df96 100644 --- a/sys/kern/subr_msan.c +++ b/sys/kern/subr_msan.c @@ -1289,11 +1289,13 @@ MSAN_ATOMIC_FUNC_TESTANDCLEAR(32, uint32_t); MSAN_ATOMIC_FUNC_TESTANDCLEAR(64, uint64_t); MSAN_ATOMIC_FUNC_TESTANDCLEAR(int, u_int); MSAN_ATOMIC_FUNC_TESTANDCLEAR(long, u_long); +MSAN_ATOMIC_FUNC_TESTANDCLEAR(ptr, uintptr_t); MSAN_ATOMIC_FUNC_TESTANDSET(32, uint32_t); MSAN_ATOMIC_FUNC_TESTANDSET(64, uint64_t); MSAN_ATOMIC_FUNC_TESTANDSET(int, u_int); MSAN_ATOMIC_FUNC_TESTANDSET(long, u_long); +MSAN_ATOMIC_FUNC_TESTANDSET(ptr, uintptr_t); MSAN_ATOMIC_FUNC_SWAP(32, uint32_t); MSAN_ATOMIC_FUNC_SWAP(64, uint64_t); diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h index 47fd9ce30fd6..0c3a57698342 100644 --- a/sys/powerpc/include/atomic.h +++ b/sys/powerpc/include/atomic.h @@ -1093,6 +1093,16 @@ atomic_testandset_acq_long(volatile u_long *p, u_int v) return (a); } +#ifdef __powerpc64__ +#define atomic_testandclear_ptr atomic_testandclear_long +#define atomic_testandset_ptr atomic_testandset_long +#else +#define atomic_testandclear_ptr(p,v) \ + atomic_testandclear_32((volatile u_int *)(p), v) +#define atomic_testandset_ptr(p,v) \ + atomic_testandset_32((volatile u_int *)(p), v) +#endif + static __inline void atomic_thread_fence_acq(void) { diff --git a/sys/riscv/include/atomic.h b/sys/riscv/include/atomic.h index be4137cb0df4..fee82e6a6bc9 100644 --- a/sys/riscv/include/atomic.h +++ b/sys/riscv/include/atomic.h @@ -530,6 +530,8 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val) #define atomic_set_ptr atomic_set_64 #define atomic_subtract_ptr atomic_subtract_64 #define atomic_swap_ptr atomic_swap_64 +#define atomic_testandclear_ptr atomic_testandclear_64 +#define atomic_testandset_ptr atomic_testandset_64 ATOMIC_ACQ_REL(set, 64) ATOMIC_ACQ_REL(clear, 64)