bpf: Add cond_break macro
authorAlexei Starovoitov <ast@kernel.org>
Wed, 6 Mar 2024 03:19:28 +0000 (19:19 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 6 Mar 2024 23:18:04 +0000 (15:18 -0800)
commit06375801525717173aee790310b7d959bb77879b
tree56f571c37744c55fbab9eb4952875c1725e968e7
parent4f81c16f50baf6d5d8bfa6eef3250dcfa22cbc08
bpf: Add cond_break macro

Use may_goto instruction to implement cond_break macro.
Ideally the macro should be written as:
  asm volatile goto(".byte 0xe5;
                     .byte 0;
                     .short %l[l_break] ...
                     .long 0;
but LLVM doesn't recognize fixup of 2 byte PC relative yet.
Hence use
  asm volatile goto(".byte 0xe5;
                     .byte 0;
                     .long %l[l_break] ...
                     .short 0;
that produces correct asm on little endian.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Tested-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20240306031929.42666-4-alexei.starovoitov@gmail.com
tools/testing/selftests/bpf/bpf_experimental.h