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]
Message-ID: <20240816194203.05753edf@kernel.org>
Date: Fri, 16 Aug 2024 19:42:03 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Sean Anderson <sean.anderson@...ux.dev>
Cc: Andrew Lunn <andrew@...n.ch>, Radhey Shyam Pandey
 <radhey.shyam.pandey@....com>, netdev@...r.kernel.org, Simon Horman
 <horms@...nel.org>, Michal Simek <michal.simek@....com>,
 linux-kernel@...r.kernel.org, "David S . Miller" <davem@...emloft.net>,
 Russell King <linux@...linux.org.uk>, linux-arm-kernel@...ts.infradead.org,
 Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net-next v3 2/2] net: xilinx: axienet: Add statistics
 support

On Thu, 15 Aug 2024 10:40:31 -0400 Sean Anderson wrote:
> +	u64 hw_stat_base[STAT_COUNT];
> +	u64 hw_last_counter[STAT_COUNT];

I think hw_last_counter has to be u32..

> +	seqcount_mutex_t hw_stats_seqcount;
> +	struct mutex stats_lock;
> +	struct delayed_work stats_work;
> +	bool reset_in_progress;
> +
>  	struct work_struct dma_err_task;
>  
>  	int tx_irq;
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index b2d7c396e2e3..9353a4f0ab1b 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -519,11 +519,55 @@ static void axienet_setoptions(struct net_device *ndev, u32 options)
>  	lp->options |= options;
>  }
>  
> +static u64 axienet_stat(struct axienet_local *lp, enum temac_stat stat)
> +{
> +	u32 counter;
> +
> +	if (lp->reset_in_progress)
> +		return lp->hw_stat_base[stat];
> +
> +	counter = axienet_ior(lp, XAE_STATS_OFFSET + stat * 8);
> +	return lp->hw_stat_base[stat] + (counter - lp->hw_last_counter[stat]);

.. or you need to cast the (counter - lp->...) result to u32.
Otherwise counter's type is getting bumped to 64 and you're just doing
64b math here.

> +}
> +
> +static void axienet_stats_update(struct axienet_local *lp, bool reset)
> +{
> +	enum temac_stat stat;
> +
> +	write_seqcount_begin(&lp->hw_stats_seqcount);
> +	lp->reset_in_progress = reset;
> +	for (stat = 0; stat < STAT_COUNT; stat++) {
> +		u32 counter = axienet_ior(lp, XAE_STATS_OFFSET + stat * 8);
> +
> +		lp->hw_stat_base[stat] += counter - lp->hw_last_counter[stat];
> +		lp->hw_last_counter[stat] = counter;
> +	}
> +	write_seqcount_end(&lp->hw_stats_seqcount);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ