diff options
| author | Jenny Guanni Qu <qguanni@gmail.com> | 2026-03-11 01:11:16 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-03-21 13:12:17 -0700 |
| commit | 4ac95c65efeaf0c010199b2b2f5f78b06f28dab6 (patch) | |
| tree | d084cd92f13b4fe6f846dbf832b889d84e49996d /Documentation/console/git@git.tavy.me:linux.git | |
| parent | c77b30bd1dcb61f66c640ff7d2757816210c7cb0 (diff) | |
selftests/bpf: Add tests for sdiv32/smod32 with INT_MIN dividend
Add tests to verify that signed 32-bit division and modulo operations
produce correct results when the dividend is INT_MIN (0x80000000).
The bug fixed in the previous commit only affects the BPF interpreter
path. When JIT is enabled (the default on most architectures), the
native CPU division instruction produces the correct result and these
tests pass regardless. With bpf_jit_enable=0, the interpreter is used
and without the previous fix, INT_MIN / 2 incorrectly returns
0x40000000 instead of 0xC0000000 due to abs(S32_MIN) undefined
behavior, causing these tests to fail.
Test cases:
- SDIV32 INT_MIN / 2 = -1073741824 (imm and reg divisor)
- SMOD32 INT_MIN % 2 = 0 (positive and negative divisor)
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Jenny Guanni Qu <qguanni@gmail.com>
Link: https://lore.kernel.org/r/20260311011116.2108005-3-qguanni@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'Documentation/console/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions
