Bug 202391
Summary: | 32-bit kernel implementation of div64_u64_rem contains error | ||
---|---|---|---|
Product: | Other | Reporter: | Siarhei Volkau (lis8215) |
Component: | Other | Assignee: | other_other |
Status: | CLOSED PATCH_ALREADY_AVAILABLE | ||
Severity: | high | CC: | jwrdegoede, lis8215, stf_xl |
Priority: | P1 | ||
Hardware: | Other | ||
OS: | Linux | ||
Kernel Version: | 3.12.x and above | Subsystem: | |
Regression: | Yes | Bisected commit-id: | |
Attachments: |
Sample driver code to showcase the bug
test_div64.c test_div64.c test_script.sh improved testcase from hackersdelight |
Description
Siarhei Volkau
2019-01-23 07:21:52 UTC
Created attachment 280795 [details]
test_div64.c
I copied your module to user space program for easier testing and playing with the code. Issue is reproducible even on 64 bit platform and looks like changing
int n = 1 + fls(high);
to
int n = fls(high);
make the results correct. But this change require verification on other numbers.
Created attachment 280799 [details]
test_div64.c
Testcase version for script.
Created attachment 280801 [details]
test_script.sh
Test script for testing.
For me verification on random numbers seems to work. Could you verify the change on your 32 bit platform ? (In reply to Stanislaw Gruszka from comment #4) I not perform random test you mention, but i perform tests presented in the reference implementation: Buggy div64_u64_rem pass all of them :) Then i add 0x100000003 to testcases and now it fail 11 tests. Your fixed version pass all tests. > For me verification on random numbers seems to work. Could you verify the > change on your 32 bit platform ? It works, thank you. Assume, bug will be fixed soon in upstream. Created attachment 280805 [details]
improved testcase from hackersdelight
There are my testcase
Assume its a regression, see this commit: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/lib/div64.c?id=658716d19f8f155c67d4677ba68034b8e492dfbe Link to another thread, where i post this bug earlier, may contain useful info. https://bugzilla.redhat.com/show_bug.cgi?id=1668164 I'll to post the fix upstream. I think we also need to fix div64_u64 . Patch was posted. https://lkml.org/lkml/2019/1/28/493 |