summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJie Meng <jmeng@fb.com>2026-04-13 20:23:11 +0300
committerAlexei Starovoitov <ast@kernel.org>2026-04-21 03:57:36 +0300
commitc8f0ee969f76277e562e44a20a6ff8bb47acab15 (patch)
tree15feed8c2342b3f13b1ffee9f8fad6d6b2f5e892 /include
parent552ad802cad94bd759f85c170d07cc53f7d5deb9 (diff)
downloadlinux-c8f0ee969f76277e562e44a20a6ff8bb47acab15.tar.xz
bpf: Exhaustive test coverage for signed division and modulo
Extend lib/test_bpf.c to provide comprehensive test coverage for BPF signed division (SDIV) and signed modulo (SMOD) instructions, both 32-bit and 64-bit variants with immediate operands. Introduce F_ALU32 and F_SIGNED flags to replace the less readable bool alu32 and s16 off parameters throughout the test helpers. The BPF instruction 'off' field is derived from flags only at the point of instruction encoding. Changes: - Add enum { F_ALU32 = 1, F_SIGNED = 2 } for readable test flags. - __bpf_alu_result(): take u32 flags instead of separate signed/alu32 parameters. Narrows operands internally for ALU32 (unsigned via u32 cast, signed via s32 cast) before computing the reference result. - __bpf_emit_alu64_imm(), __bpf_emit_alu32_imm(): pass flags through to __bpf_alu_result, derive 'off' for instruction encoding locally. - __bpf_fill_alu_imm_regs(): take u32 flags, use F_ALU32/F_SIGNED for operand setup and single-line __bpf_alu_result() call. - __bpf_fill_alu_shift(), __bpf_fill_alu_shift_same_reg(): convert bool alu32 parameter to u32 flags for consistency. - New test fill functions: bpf_fill_alu{32,64}_{sdiv,smod}_imm() and bpf_fill_alu{32,64}_{sdiv,smod}_imm_regs(), each testing all immediate value magnitudes and all register pair combinations. - All existing unsigned tests updated to use flags (0 or F_ALU32), preserving backward compatibility. 8 new test cases added: ALU64_SDIV_K, ALU64_SMOD_K (immediate magnitudes + register combos) ALU32_SDIV_K, ALU32_SMOD_K (immediate magnitudes + register combos) Test results: test_bpf: Summary: 1061 PASSED, 0 FAILED, [1049/1049 JIT'ed] test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed] test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Jie Meng <jmeng@fb.com> Link: https://lore.kernel.org/r/20260413172311.3918767-1-jmeng@fb.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions