Re: [0/5] lib: resync lib/div64.c and <linux/math64.h> with Linux v7.1

Simon Glass <[email protected]> Wed, 5 Aug 2026 18:53:01 -0600
Newsgroups gmane.comp.boot-loaders.u-boot
Message-ID <CAFLszTjKpeJZZ=6Nv31zKh6QQ6-9s72dZTGQiG7wiwNg+Ws8dA__33473.0072690704$1785977612$gmane$org@mail.gmail.com>
Hi Alexey,

On 2026-07-30T18:40:37, Alexey Charkov <[email protected]> wrote:

> While auditing the header, two bugs turned up in lib/div64.c, so this
> series starts with those. Both are 32-bit only:

Thanks for looking at this!

> - div64_u64() and div64_u64_rem() shifted by 1 + fls(high) instead of
>   fls(high), losing a bit of the divisor. Linux fixed this in 2019, while
>   U-Boot never picked it up.

Since patch 1 has such a nice reproducer, how about adding a small
self-test under test/lib/ for div64_u64() and div64_s64() as part of
this series? It would guard against future regressions on 32-bit and
give the sync patches some cover. A handful of the
divisor-just-above-2^32 cases plus the div64_s64() truncation case
would be plenty.

Regards,
Simon