lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 9 Feb 2022 20:11:01 +0100
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Qing Wang <wangqing@...o.com>,
        Derek Chickles <dchickles@...vell.com>,
        Satanand Burla <sburla@...vell.com>,
        Felix Manlunas <fmanlunas@...vell.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: ethernet: cavium: use div64_u64() instead of
 do_div()

Le 09/02/2022 à 09:39, Qing Wang a écrit :
> From: Wang Qing <wangqing@...o.com>
> 
> do_div() does a 64-by-32 division.
> When the divisor is u64, do_div() truncates it to 32 bits, this means it
> can test non-zero and be truncated to zero for division.
> 
> fix do_div.cocci warning:
> do_div() does a 64-by-32 division, please consider using div64_u64 instead.
> 
> Signed-off-by: Wang Qing <wangqing@...o.com>
> ---
>   drivers/net/ethernet/cavium/liquidio/lio_main.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> index ba28aa4..8e07192
> --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
> +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> @@ -1539,7 +1539,7 @@ static int liquidio_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
>   	 * compute the delta in terms of coprocessor clocks.
>   	 */
>   	delta = (u64)ppb << 32;
> -	do_div(delta, oct->coproc_clock_rate);
> +	div64_u64(delta, oct->coproc_clock_rate);
>   
>   	spin_lock_irqsave(&lio->ptp_lock, flags);
>   	comp = lio_pci_readq(oct, CN6XXX_MIO_PTP_CLOCK_COMP);
> @@ -1672,7 +1672,7 @@ static void liquidio_ptp_init(struct octeon_device *oct)
>   	u64 clock_comp, cfg;
>   
>   	clock_comp = (u64)NSEC_PER_SEC << 32;
> -	do_div(clock_comp, oct->coproc_clock_rate);
> +	div64_u64(clock_comp, oct->coproc_clock_rate);
>   	lio_pci_writeq(oct, clock_comp, CN6XXX_MIO_PTP_CLOCK_COMP);
>   
>   	/* Enable */

I think that all your recent patches about such conversions are broken.

See [1] were it was already reported that do_div() and div64_u64() don't 
have the same calling convention.

Looks that div64_u64() and div64_ul() works the same way.


CJ

[1]: 
https://lore.kernel.org/linux-kernel/20211117112559.jix3hmx7uwqmuryg@pengutronix.de/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ