Commit 13fdecf3 authored by Peilin Ye's avatar Peilin Ye Committed by Alexei Starovoitov
Browse files

selftests/bpf: Use CAN_USE_LOAD_ACQ_STORE_REL when appropriate



Instead of open-coding the conditions, use
'#ifdef CAN_USE_LOAD_ACQ_STORE_REL' to guard the following tests:

  verifier_precision/bpf_load_acquire
  verifier_precision/bpf_store_release
  verifier_store_release/*

Note that, for the first two tests in verifier_precision.c, switching to
'#ifdef CAN_USE_LOAD_ACQ_STORE_REL' means also checking if
'__clang_major__ >= 18', which has already been guaranteed by the outer
'#if' check.

Acked-by: default avatarBjörn Töpel <bjorn@kernel.org>
Reviewed-by: default avatarPu Lehui <pulehui@huawei.com>
Tested-by: Björn Töpel <bjorn@rivosinc.com> # QEMU/RVA23
Signed-off-by: default avatarPeilin Ye <yepeilin@google.com>
Link: https://lore.kernel.org/r/45d7e025f6e390a8ff36f08fc51e31705ac896bd.1746588351.git.yepeilin@google.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent db7a3822
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -91,8 +91,7 @@ __naked int bpf_end_bswap(void)
		::: __clobber_all);
}

#if defined(ENABLE_ATOMICS_TESTS) && \
	(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86))
#ifdef CAN_USE_LOAD_ACQ_STORE_REL

SEC("?raw_tp")
__success __log_level(2)
@@ -138,7 +137,7 @@ __naked int bpf_store_release(void)
	: __clobber_all);
}

#endif /* load-acquire, store-release */
#endif /* CAN_USE_LOAD_ACQ_STORE_REL */
#endif /* v4 instruction */

SEC("?raw_tp")
+3 −4
Original line number Diff line number Diff line
@@ -6,8 +6,7 @@
#include "../../../include/linux/filter.h"
#include "bpf_misc.h"

#if __clang_major__ >= 18 && defined(ENABLE_ATOMICS_TESTS) && \
	(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86))
#ifdef CAN_USE_LOAD_ACQ_STORE_REL

SEC("socket")
__description("store-release, 8-bit")
@@ -271,7 +270,7 @@ __naked void store_release_with_invalid_reg(void)
	: __clobber_all);
}

#else
#else /* CAN_USE_LOAD_ACQ_STORE_REL */

SEC("socket")
__description("Clang version < 18, ENABLE_ATOMICS_TESTS not defined, and/or JIT doesn't support store-release, use a dummy test")
@@ -281,6 +280,6 @@ int dummy_test(void)
	return 0;
}

#endif
#endif /* CAN_USE_LOAD_ACQ_STORE_REL */

char _license[] SEC("license") = "GPL";