From: Simon Horman <horms@kernel.org>
To: Ratheesh Kannoth <rkannoth@marvell.com>
Cc: cjubran@nvidia.com, matttbe@kernel.org, chuck.lever@oracle.com,
shshitrit@nvidia.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, sgoutham@marvell.com, jiri@resnulli.us,
davem@davemloft.net, saeedm@nvidia.com, kuba@kernel.org,
edumazet@google.com, pabeni@redhat.com, donald.hunter@gmail.com
Subject: Re: [v3,net-next,5/5] octeontx2-af: Add support for loading custom KPU profile from filesystem
Date: Wed, 11 Mar 2026 10:14:50 +0000 [thread overview]
Message-ID: <20260311101450.GR461701@kernel.org> (raw)
In-Reply-To: <abDeXLpMMxp7G1v3@rkannoth-OptiPlex-7090>
On Wed, Mar 11, 2026 at 08:45:40AM +0530, Ratheesh Kannoth wrote:
> On 2026-03-10 at 22:51:00, Simon Horman (horms@kernel.org) wrote:
> > This is an AI-generated review of your patch. The human sending this
> > email has considered the AI review valid, or at least plausible.
> >
> > For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
> > ---
> > octeontx2-af: Add support for loading custom KPU profile from filesystem
> >
> > This commit adds functionality to load custom KPU (Key Parse Unit)
> > profiles from the filesystem at module load time, providing an
> > alternative to flashing updated firmware on deployed devices.
> >
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc.h b/drivers/net/ethernet/marvell/octeontx2/af/npc.h
> > > index cefc5d70f3e4..5928c4d3cc8b 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/af/npc.h
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/af/npc.h
> >
> > [ ... ]
> >
> > > @@ -290,6 +303,7 @@ struct npc_kpu_profile {
> > > int action_entries;
> > > struct npc_kpu_profile_cam *cam;
> > > struct npc_kpu_profile_action *action;
> > > + struct npc_kpu_profile_cam2 *cam2;
> > > };
> >
> > [ ... ]
> >
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> > > index a466181cf908..1efc53b63b67 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
> >
> > [ ... ]
> >
> > > @@ -553,8 +553,8 @@ struct npc_kpu_profile_adapter {
> > > const char *name;
> > > u64 version;
> > > const struct npc_lt_def_cfg *lt_def;
> > > - const struct npc_kpu_profile_action *ikpu; /* array[pkinds] */
> > > - const struct npc_kpu_profile *kpu; /* array[kpus] */
> > > + struct npc_kpu_profile_action *ikpu; /* array[pkinds] */
> > > + struct npc_kpu_profile *kpu; /* array[kpus] */
> >
> > [ ... ]
> >
> > > @@ -564,6 +564,7 @@ struct npc_kpu_profile_adapter {
> > > bool custom;
> > > size_t pkinds;
> > > size_t kpus;
> > > + bool from_fs;
> > > };
> >
> > [ ... ]
> >
> > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> > > index 352dc5f1d5b9..05aabe26f030 100644
> > > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> > > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> >
> > [ ... ]
> >
> > > @@ -1610,6 +1622,7 @@ u64 npc_enable_mask(int count)
> > > static void npc_program_kpu_profile(struct rvu *rvu, int blkaddr, int kpu,
> > > const struct npc_kpu_profile *profile)
> > > {
> > > + struct npc_kpu_profile_adapter *adapter = &rvu->kpu;
> > > int entry, num_entries, max_entries;
> > > u64 entry_mask;
> > >
> > > @@ -1621,10 +1634,15 @@ static void npc_program_kpu_profile(struct rvu *rvu, int blkaddr, int kpu,
> > >
> > > max_entries = rvu->hw->npc_kpu_entries;
> > >
> > > + WARN(profile->cam_entries > max_entries,
> > > + "KPU%u: err: hw max entries=%u, input entries=%u\n",
> > > + kpu, rvu->hw->npc_kpu_entries, profile->cam_entries);
> > > +
> > > /* Program CAM match entries for previous KPU extracted data */
> > > num_entries = min_t(int, profile->cam_entries, max_entries);
> > > for (entry = 0; entry < num_entries; entry++)
> > > npc_config_kpucam(rvu, blkaddr,
> > > + adapter->from_fs ? (void *)&profile->cam2[entry] :
> > > &profile->cam[entry], kpu, entry);
> >
> > Can this dereference NULL when from_fs is true for KPUs not covered by
> > the filesystem firmware?
> >
> > Looking at the filesystem loading path in npc_apply_custom_kpu:
> >
> > for (kpu = 0; kpu < fw->kpus; kpu++) {
> > ...
> > ret = npc_alloc_kpu_cam2_n_action(rvu, kpu, entries);
> > ...
> > for (entry = 0; entry < entries; entry++) {
> > profile->kpu[kpu].cam2[entry] = cam2[entry];
> > ...
> > }
> > }
> >
> > The code allocates cam2 and populates entries only for the first
> > fw->kpus KPUs found in the firmware blob.
> >
> > However, npc_program_kpu_profile is later called for all KPUs in
> > npc_parser_profile_init:
> >
> > for (idx = 0; idx < num_kpus; idx++)
> > npc_program_kpu_profile(rvu, blkaddr, idx, &rvu->kpu.kpu[idx]);
> >
> > Since adapter->from_fs is a global flag (not per-KPU), when idx >=
> > fw->kpus, profile->cam2 remains NULL (the default npc_kpu_profiles[]
> > static initializer doesn't include cam2), causing &profile->cam2[entry]
> > to compute an invalid pointer.
> >
> > Shouldn't there be a check to verify cam2 is non-NULL before
> > dereferencing it, or allocate cam2 for all KPUs when from_fs is true?
>
> The filsystem binary contains entries for all KPUs. So we can ignore this
> case.
Maybe it is just me. But I don't think it is entirely satisfactory for
the kernel to rely on data supplied from the filesystem being well formed.
E.g. what if it is corrupted?
I think all the points in the AI generated review hinge on this.
So let's try and agree on the basic principles and move on from there.
...
next prev parent reply other threads:[~2026-03-11 10:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 2:46 [PATCH v3 net-next 0/5] octeontx2-af: npc: Enhancements Ratheesh Kannoth
2026-03-09 2:46 ` [PATCH v3 net-next 1/5] octeontx2-af: npc: cn20k: debugfs enhancements Ratheesh Kannoth
2026-03-09 2:46 ` [PATCH v3 net-next 2/5] devlink: Implement devlink param multi attribute nested data values Ratheesh Kannoth
2026-03-09 2:46 ` [PATCH v3 net-next 3/5] octeontx2-af: npc: cn20k: add subbank search order control Ratheesh Kannoth
2026-03-09 2:46 ` [PATCH v3 net-next 4/5] octeontx2-af: npc: cn20k: dynamically allocate and free default MCAM entries Ratheesh Kannoth
2026-03-09 2:46 ` [PATCH v3 net-next 5/5] octeontx2-af: Add support for loading custom KPU profile from filesystem Ratheesh Kannoth
2026-03-10 17:21 ` [v3,net-next,5/5] " Simon Horman
2026-03-11 3:15 ` Ratheesh Kannoth
2026-03-11 10:14 ` Simon Horman [this message]
2026-03-11 14:28 ` Ratheesh Kannoth
2026-03-13 2:08 ` 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=20260311101450.GR461701@kernel.org \
--to=horms@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=cjubran@nvidia.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matttbe@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rkannoth@marvell.com \
--cc=saeedm@nvidia.com \
--cc=sgoutham@marvell.com \
--cc=shshitrit@nvidia.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