All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	ojeda@kernel.org, "Alexandre Courbot" <acourbot@nvidia.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 02/13] gpu: nova-core: gsp: sequencer: do not store sequence into GspSequencer
Date: Tue, 07 Jul 2026 07:58:22 +0000	[thread overview]
Message-ID: <20260707075822.CE7201F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707-nova-bootcontext-v5-2-ecad9346387f@nvidia.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

Pre-existing issues:
- [High] Command parsing errors silently terminate execution while reporting success.
- [High] Truncated commands are executed with zeroed payloads instead of failing.
- [High] `seq_info.cmd_index` is improperly used as the total command count.
--

--- Patch [2]: [PATCH v5 02/13] gpu: nova-core: gsp: sequencer: do not store sequence into GspSequencer ---
commit b9f8dfb196e815ccff55e396434b9fbb45c0cc05
Author: Alexandre Courbot <acourbot@nvidia.com>

gpu: nova-core: gsp: sequencer: do not store sequence into GspSequencer

Moves the sequence out of the GspSequencer struct to avoid borrow-checker
limitations. Iterator creation is moved to GspSeqIter::new so it no longer
borrows the entire GspSequencer.

> diff --git a/drivers/gpu/nova-core/gsp/sequencer.rs b/drivers/gpu/nova-core/gsp/sequencer.rs
> index f55205bd61f35..ddce32cc4e308 100644
> --- a/drivers/gpu/nova-core/gsp/sequencer.rs
> +++ b/drivers/gpu/nova-core/gsp/sequencer.rs

[ ... ]

> @@ -281,6 +279,18 @@ pub(crate) struct GspSeqIter<'a> {
>      dev: &'a device::Device,
>  }
>  
> +impl<'a> GspSeqIter<'a> {
> +    fn new(seq: &'a GspSequence, dev: &'a device::Device) -> Self {
> +        Self {
> +            cmd_data: &seq.cmd_data,
> +            current_offset: 0,
> +            total_cmds: seq.cmd_index,

[Severity: High]
This is a pre-existing issue, but does this incorrectly use the DWord size
as the command count?

If seq.cmd_index represents the buffer length in DWords, assigning it to
total_cmds breaks the iteration bounds check.

In GspSeqIter::next(), cmds_processed is incremented by 1 per command,
which means the condition cmds_processed >= total_cmds won't trigger at
the actual end of valid commands.

Could this cause the iterator to parse and execute padding bytes as
commands?

> +            cmds_processed: 0,
> +            dev,
> +        }
> +    }
> +}

[ ... ]

> @@ -363,14 +358,14 @@ pub(crate) fn run(
>  
>          dev_dbg!(sequencer.dev, "Running CPU Sequencer commands\n");
>  
> -        for cmd_result in sequencer.iter() {
> +        for cmd_result in GspSeqIter::new(&seq_info, sequencer.dev) {

[Severity: High]
This is a pre-existing issue, but is it possible for truncated commands to
be parsed and executed with zeroed payloads?

Looking at GspSeqIter::next(), if the remaining buffer is smaller than
CMD_SIZE, it appears to zero-pad the data into a buffer of size CMD_SIZE
before passing it to GspSeqCmd::new():

    let cmd_result = GspSeqCmd::new(&buffer, self.dev);

Inside GspSeqCmd::new(), the safety check uses data.len():

    if data.len() < size {
        dev_err!(dev, "Data is not enough for command\n");
        return Err(EINVAL);
    }

Since the padded buffer length is always exactly CMD_SIZE, this check might
act as dead code. Does this mean truncated commands would succeed using the
zero padding as their payload rather than failing with an error?

[Severity: High]
This is another pre-existing issue, but does command parsing silently
terminate on errors while reporting success to the caller?

In GspSeqIter::next(), when parsing fails, the error closure logs the
failure but returns None:

    cmd_result.map_or_else(
        |_err| {
            dev_err!(self.dev, "Error parsing command at offset {}\n", offset);
            None
        },

Since None signals normal iterator termination, this loop in
GspSequencer::run() will exit cleanly and return Ok(()) without triggering
an error.

Could this leave the hardware sequence incomplete while the driver
incorrectly assumes the boot sequence succeeded?

>              match cmd_result {
>                  Ok(cmd) => cmd.run(&sequencer)?,
>                  Err(e) => {
>                      dev_err!(
>                          sequencer.dev,
>                          "Error running command at index {}\n",
> -                        sequencer.seq_info.cmd_index
> +                        seq_info.cmd_index
>                      );
>                      return Err(e);
>                  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707-nova-bootcontext-v5-0-ecad9346387f@nvidia.com?part=2

  reply	other threads:[~2026-07-07  7:58 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  7:21 [PATCH v5 00/13] gpu: nova-core: consolidate and streamline GSP boot process Alexandre Courbot
2026-07-07  7:21 ` [PATCH v5 01/13] gpu: nova-core: gsp: sequencer: use GspBootContext Alexandre Courbot
2026-07-07  7:21 ` [PATCH v5 02/13] gpu: nova-core: gsp: sequencer: do not store sequence into GspSequencer Alexandre Courbot
2026-07-07  7:58   ` sashiko-bot [this message]
2026-07-07  7:21 ` [PATCH v5 03/13] gpu: nova-core: gsp: replace BootUnloadGuard with local handlers Alexandre Courbot
2026-07-07  8:04   ` Eliot Courtney
2026-07-07 12:56     ` Alexandre Courbot
2026-07-07 13:34       ` Eliot Courtney
2026-07-09  6:27         ` Alexandre Courbot
2026-07-07  8:10   ` sashiko-bot
2026-07-07  7:21 ` [PATCH v5 04/13] gpu: nova-core: gsp: pass GspBootContext to unload methods Alexandre Courbot
2026-07-07  7:21 ` [PATCH v5 05/13] gpu: nova-core: gsp: centralize missing unload bundle warnings Alexandre Courbot
2026-07-07  8:30   ` sashiko-bot
2026-07-07  7:21 ` [PATCH v5 06/13] gpu: nova-core: gsp: fold TU102 unload bundle construction into HAL method Alexandre Courbot
2026-07-07  7:21 ` [PATCH v5 07/13] gpu: nova-core: gsp: turn FWSEC execution " Alexandre Courbot
2026-07-07  7:21 ` [PATCH v5 08/13] gpu: nova-core: gsp: make use of FWSEC bootloader a property of the TU102 HAL Alexandre Courbot
2026-07-07  7:42   ` Eliot Courtney
2026-07-07  7:21 ` [PATCH v5 09/13] gpu: nova-core: move GSP firmware files decision to GSP HAL Alexandre Courbot
2026-07-07  7:49   ` Alexandre Courbot
2026-07-07 13:08     ` Eliot Courtney
2026-07-07  7:21 ` [PATCH v5 10/13] gpu: nova-core: avoid repeated calls to pci::Device::as_ref Alexandre Courbot
2026-07-07  7:21 ` [PATCH v5 11/13] gpu: nova-core: gsp: pass GspBootContext mutably Alexandre Courbot
2026-07-07  7:21 ` [PATCH v5 12/13] gpu: nova-core: gsp: separate context and GPU lifetimes in GspBootContext Alexandre Courbot
2026-07-07  9:02   ` sashiko-bot
2026-07-07  7:21 ` [PATCH v5 13/13] gpu: nova-core: store Fsp instance in Gpu Alexandre Courbot

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=20260707075822.CE7201F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.