Use LSE instructions when __ARM_FEATURE_ATOMICS or RTE_ARM_FEATURE_ATOMICS is defined. Otherwise, check runtime CPU flags before selecting LSE instructions for JIT-generated code.
Signed-off-by: Nick Hudson <[email protected]> --- lib/bpf/bpf_jit_arm64.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bpf/bpf_jit_arm64.c b/lib/bpf/bpf_jit_arm64.c index 4b897dccb8..8e17c21e8f 100644 --- a/lib/bpf/bpf_jit_arm64.c +++ b/lib/bpf/bpf_jit_arm64.c @@ -8,6 +8,7 @@ #include <rte_common.h> #include <rte_byteorder.h> +#include <rte_cpuflags.h> #include <rte_debug.h> #include "bpf_impl.h" @@ -1031,15 +1032,14 @@ emit_stxr(struct a64_jit_ctx *ctx, bool is64, uint8_t rs, uint8_t rt, emit_insn(ctx, insn, check_reg(rs) || check_reg(rt) || check_reg(rn)); } -static int +static bool has_atomics(void) { - int rc = 0; - #if defined(__ARM_FEATURE_ATOMICS) || defined(RTE_ARM_FEATURE_ATOMICS) - rc = 1; + return true; +#else + return rte_cpu_get_flag_enabled(RTE_CPUFLAG_ATOMICS) == 1; #endif - return rc; } static void -- 2.54.0 (Apple Git-157)

