public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Ratheesh Kannoth <rkannoth@marvell.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	sgoutham@marvell.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch
Subject: Re: [PATCH net-next v4 07/13] octeontx2-af: npc: cn20k: Prepare for new SoC
Date: Thu, 22 Jan 2026 08:36:10 +0000	[thread overview]
Message-ID: <aXHhekHJSpTZzHXy@horms.kernel.org> (raw)
In-Reply-To: <20260113101658.4144610-8-rkannoth@marvell.com>

On Tue, Jan 13, 2026 at 03:46:52PM +0530, Ratheesh Kannoth wrote:

...

> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
> index 508233876fc1..d73e447bedca 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
> @@ -903,11 +903,12 @@ static int npc_check_unsupported_flows(struct rvu *rvu, u64 features, u8 intf)
>   * dont care.
>   */
>  void npc_update_entry(struct rvu *rvu, enum key_fields type,
> -		      struct mcam_entry *entry, u64 val_lo,
> +		      struct mcam_entry_mdata *mdata, u64 val_lo,
>  		      u64 val_hi, u64 mask_lo, u64 mask_hi, u8 intf)
>  {
>  	struct npc_mcam *mcam = &rvu->hw->mcam;
>  	struct mcam_entry dummy = { {0} };
> +	u64 *kw, *kw_mask, *val, *mask;
>  	struct npc_key_field *field;
>  	u64 kw1, kw2, kw3;
>  	int i, max_kw;
> @@ -920,10 +921,9 @@ void npc_update_entry(struct rvu *rvu, enum key_fields type,
>  	if (!field->nr_kws)
>  		return;
>  
> -	if (is_cn20k(rvu->pdev))
> -		max_kw = NPC_MAX_KWS_IN_KEY;
> -	else
> -		max_kw = NPC_MAX_KWS_IN_KEY - 1;
> +	max_kw = NPC_MAX_KWS_IN_KEY;
> +	kw = dummy.kw;
> +	kw_mask = dummy.kw_mask;
>  
>  	for (i = 0; i < max_kw; i++) {
>  		if (!field->kw_mask[i])
> @@ -932,10 +932,10 @@ void npc_update_entry(struct rvu *rvu, enum key_fields type,
>  		shift = __ffs64(field->kw_mask[i]);
>  		/* update entry value */
>  		kw1 = (val_lo << shift) & field->kw_mask[i];
> -		dummy.kw[i] = kw1;
> +		kw[i] = kw1;
>  		/* update entry mask */
>  		kw1 = (mask_lo << shift) & field->kw_mask[i];
> -		dummy.kw_mask[i] = kw1;
> +		kw_mask[i] = kw1;
>  
>  		if (field->nr_kws == 1)
>  			break;
> @@ -945,12 +945,12 @@ void npc_update_entry(struct rvu *rvu, enum key_fields type,
>  			kw2 = shift ? val_lo >> (64 - shift) : 0;
>  			kw2 |= (val_hi << shift);
>  			kw2 &= field->kw_mask[i + 1];
> -			dummy.kw[i + 1] = kw2;
> +			kw[i + 1] = kw2;

Hi Ratheesh,

It's not a problem introduced by this patch.
But it seems that this could overrun kw if i is max_kw - 1.
Likewise elsewhere in this loop.

Flagged by Smatch.

>  			/* update entry mask */
>  			kw2 = shift ? mask_lo >> (64 - shift) : 0;
>  			kw2 |= (mask_hi << shift);
>  			kw2 &= field->kw_mask[i + 1];
> -			dummy.kw_mask[i + 1] = kw2;
> +			kw_mask[i + 1] = kw2;
>  			break;
>  		}
>  		/* place remaining bits of key value in kw[x + 1], kw[x + 2] */
> @@ -961,34 +961,40 @@ void npc_update_entry(struct rvu *rvu, enum key_fields type,
>  			kw2 &= field->kw_mask[i + 1];
>  			kw3 = shift ? val_hi >> (64 - shift) : 0;
>  			kw3 &= field->kw_mask[i + 2];
> -			dummy.kw[i + 1] = kw2;
> -			dummy.kw[i + 2] = kw3;
> +			kw[i + 1] = kw2;
> +			kw[i + 2] = kw3;
>  			/* update entry mask */
>  			kw2 = shift ? mask_lo >> (64 - shift) : 0;
>  			kw2 |= (mask_hi << shift);
>  			kw2 &= field->kw_mask[i + 1];
>  			kw3 = shift ? mask_hi >> (64 - shift) : 0;
>  			kw3 &= field->kw_mask[i + 2];
> -			dummy.kw_mask[i + 1] = kw2;
> -			dummy.kw_mask[i + 2] = kw3;
> +			kw_mask[i + 1] = kw2;
> +			kw_mask[i + 2] = kw3;
>  			break;
>  		}
>  	}

...

  reply	other threads:[~2026-01-22  8:36 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13 10:16 [PATCH net-next v4 00/13] NPC HW block support for cn20k Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 01/13] octeontx2-af: npc: cn20k: Index management Ratheesh Kannoth
2026-01-18  0:39   ` Jakub Kicinski
2026-01-19  4:04     ` Ratheesh Kannoth
2026-01-18  0:40   ` [net-next,v4,01/13] " Jakub Kicinski
2026-01-19  4:00     ` Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 02/13] octeontx2-af: npc: cn20k: KPM profile changes Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 03/13] octeontx2-af: npc: cn20k: Add default profile Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 04/13] ocetontx2-af: npc: cn20k: MKEX profile support Ratheesh Kannoth
2026-01-18  0:40   ` [net-next,v4,04/13] " Jakub Kicinski
2026-01-19  4:17     ` Ratheesh Kannoth
2026-01-20  3:24     ` Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 05/13] octeontx2-af: npc: cn20k: Allocate default MCAM indexes Ratheesh Kannoth
2026-01-18  0:40   ` [net-next,v4,05/13] " Jakub Kicinski
2026-01-19  3:42     ` Ratheesh Kannoth
2026-01-19 17:32       ` Jakub Kicinski
2026-01-20  1:37         ` Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 06/13] octeontx2-af: npc: cn20k: Use common APIs Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 07/13] octeontx2-af: npc: cn20k: Prepare for new SoC Ratheesh Kannoth
2026-01-22  8:36   ` Simon Horman [this message]
2026-01-23 15:39     ` Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 08/13] octeontx2-af: npc: cn20k: Add new mailboxes for CN20K silicon Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 09/13] octeontx2-af: npc: cn20k: virtual index support Ratheesh Kannoth
2026-01-18  0:40   ` [net-next,v4,09/13] " Jakub Kicinski
2026-01-19  3:39     ` Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 10/13] octeontx2-af: npc: cn20k: Allocate MCAM entry for flow installation Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 11/13] octeontx2-pf: cn20k: Add TC rules support Ratheesh Kannoth
2026-01-18  0:40   ` [net-next,v4,11/13] " Jakub Kicinski
2026-01-19  3:39     ` Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 12/13] octeontx2-af: npc: cn20k: add debugfs support Ratheesh Kannoth
2026-01-13 10:16 ` [PATCH net-next v4 13/13] octeontx2-af: npc: Use common structures Ratheesh Kannoth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aXHhekHJSpTZzHXy@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rkannoth@marvell.com \
    --cc=sgoutham@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox