]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Fix map_kptr test.
authorAlexei Starovoitov <ast@kernel.org>
Tue, 14 Feb 2023 23:50:51 +0000 (15:50 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:05 +0000 (09:33 +0100)
commit91a16399a44f3a7647db4ffad4ddee67bcc6c29c
tree377d5eb9a3d853d4e7fba259501821d3986a870e
parentd3a61e4f1c2dce9b2008c09bee1e26b2f212c7ab
selftests/bpf: Fix map_kptr test.

[ Upstream commit f631514ef892ec3e57f03a18ea608032313098dc ]

The compiler is optimizing out majority of unref_ptr read/writes, so the test
wasn't testing much. For example, one could delete '__kptr' tag from
'struct prog_test_ref_kfunc __kptr *unref_ptr;' and the test would still "pass".

Convert it to volatile stores. Confirmed by comparing bpf asm before/after.

Fixes: 9bd9e5cb5b64 ("selftests/bpf: Add C tests for kptr")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230214235051.22938-1-alexei.starovoitov@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/progs/map_kptr.c