bpf: Add helper macro bpf_addr_space_cast()
authorAlexei Starovoitov <ast@kernel.org>
Fri, 8 Mar 2024 01:08:09 +0000 (17:08 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 11 Mar 2024 22:43:42 +0000 (15:43 -0700)
commit204c628730c62de5a0b593008549a9b95aa96b01
tree0b9cd27de01c10719f2b7c49b07660652df3d9d9
parent2e7ba4f8fd1fa879b37db0b738c23ba2af8292ee
bpf: Add helper macro bpf_addr_space_cast()

Introduce helper macro bpf_addr_space_cast() that emits:
rX = rX
instruction with off = BPF_ADDR_SPACE_CAST
and encodes dest and src address_space-s into imm32.

It's useful with older LLVM that doesn't emit this insn automatically.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/bpf/20240308010812.89848-12-alexei.starovoitov@gmail.com
tools/testing/selftests/bpf/bpf_experimental.h