selftests/bpf: Test the inlining of bpf_kptr_xchg()
authorHou Tao <houtao1@huawei.com>
Fri, 5 Jan 2024 10:48:19 +0000 (18:48 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 23 Jan 2024 22:40:21 +0000 (14:40 -0800)
commit17bda53e43bc41d881ca6a02b3c6f5376c55b3d3
tree5bcce9245203d486367b3b41f121cb9ee14b8ab7
parentb4b7a4099b8ccea224577003fcf9d321bf0817b7
selftests/bpf: Test the inlining of bpf_kptr_xchg()

The test uses bpf_prog_get_info_by_fd() to obtain the xlated
instructions of the program first. Since these instructions have
already been rewritten by the verifier, the tests then checks whether
the rewritten instructions are as expected. And to ensure LLVM generates
code exactly as expected, use inline assembly and a naked function.

Suggested-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20240105104819.3916743-4-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/kptr_xchg_inline.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/kptr_xchg_inline.c [new file with mode: 0644]