From 18a45f12d746c06b7361b0cce59cf8e8b9e38da6 Mon Sep 17 00:00:00 2001 From: Hou Tao Date: Fri, 19 Jan 2024 18:25:28 +0800 Subject: [PATCH 1/2] bpf, arm64: Enable the inline of bpf_kptr_xchg() ARM64 bpf jit satisfies the following two conditions: 1) support BPF_XCHG() on pointer-sized word. 2) the implementation of xchg is the same as atomic_xchg() on pointer-sized words. Both of these two functions use arch_xchg() to implement the exchange. So enable the inline of bpf_kptr_xchg() for arm64 bpf jit. Signed-off-by: Hou Tao Link: https://lore.kernel.org/r/20240119102529.99581-2-houtao@huaweicloud.com Signed-off-by: Alexei Starovoitov --- arch/arm64/net/bpf_jit_comp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 8955da5c47cf..cfd5434de483 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -2305,3 +2305,8 @@ out: return ret; } + +bool bpf_jit_supports_ptr_xchg(void) +{ + return true; +} From 29f868887a7dd3efc6faecc6fc91b28fc25cf5b0 Mon Sep 17 00:00:00 2001 From: Hou Tao Date: Fri, 19 Jan 2024 18:25:29 +0800 Subject: [PATCH 2/2] selftests/bpf: Enable kptr_xchg_inline test for arm64 Now arm64 bpf jit has enable bpf_jit_supports_ptr_xchg(), so enable the test for arm64 as well. Signed-off-by: Hou Tao Link: https://lore.kernel.org/r/20240119102529.99581-3-houtao@huaweicloud.com Signed-off-by: Alexei Starovoitov --- tools/testing/selftests/bpf/prog_tests/kptr_xchg_inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/kptr_xchg_inline.c b/tools/testing/selftests/bpf/prog_tests/kptr_xchg_inline.c index 5a4bee1cf970..15144943e88b 100644 --- a/tools/testing/selftests/bpf/prog_tests/kptr_xchg_inline.c +++ b/tools/testing/selftests/bpf/prog_tests/kptr_xchg_inline.c @@ -13,7 +13,7 @@ void test_kptr_xchg_inline(void) unsigned int cnt; int err; -#if !defined(__x86_64__) +#if !(defined(__x86_64__) || defined(__aarch64__)) test__skip(); return; #endif