diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2024-04-05 00:45:36 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2024-04-05 04:31:08 +0300 |
commit | 343ca8131c35ba132d200fd9752b60e65357924d (patch) | |
tree | 46767f1cae8d92aea0b1492ceb2777d42fc872d9 /tools/include | |
parent | 1f2a74b41ea8b902687eb97c4e7e3f558801865b (diff) | |
download | linux-343ca8131c35ba132d200fd9752b60e65357924d.tar.xz |
selftests/bpf: add fp-leaking precise subprog result tests
Add selftests validating that BPF verifier handles precision marking
for SCALAR registers derived from r10 (fp) register correctly.
Given `r0 = (s8)r10;` syntax is not supported by older Clang compilers,
use the raw BPF instruction syntax to maximize compatibility.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20240404214536.3551295-2-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/include')
-rw-r--r-- | tools/include/linux/filter.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/include/linux/filter.h b/tools/include/linux/filter.h index 736bdeccdfe4..65aa8ce142e5 100644 --- a/tools/include/linux/filter.h +++ b/tools/include/linux/filter.h @@ -111,6 +111,24 @@ .off = 0, \ .imm = IMM }) +/* Short form of movsx, dst_reg = (s8,s16,s32)src_reg */ + +#define BPF_MOVSX64_REG(DST, SRC, OFF) \ + ((struct bpf_insn) { \ + .code = BPF_ALU64 | BPF_MOV | BPF_X, \ + .dst_reg = DST, \ + .src_reg = SRC, \ + .off = OFF, \ + .imm = 0 }) + +#define BPF_MOVSX32_REG(DST, SRC, OFF) \ + ((struct bpf_insn) { \ + .code = BPF_ALU | BPF_MOV | BPF_X, \ + .dst_reg = DST, \ + .src_reg = SRC, \ + .off = OFF, \ + .imm = 0 }) + /* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */ #define BPF_MOV64_RAW(TYPE, DST, SRC, IMM) \ |