All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: ojeda@kernel.org, "Danilo Krummrich" <dakr@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	gary@garyguo.net, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 03/10] gpu: nova-core: gsp: introduce and use proper RpcMessageHeader type
Date: Sun, 27 Sep 2026 11:25:17 +0000	[thread overview]
Message-ID: <20260927112517.C334F1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927-cmdq-rpc-v1-3-822db5af910e@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] gsp: spurious checksum failures due to untruncated message buffers
--

commit 1576576bd4ef9c21c59c6b207630d4431a81e34d
Author: Alexandre Courbot <acourbot@nvidia.com>

gpu: nova-core: gsp: introduce and use proper RpcMessageHeader type

This commit untangles the GSP command queue transport and message layer code
by making the RPC message header more explicit. It introduces the
RpcMessageHeader wrapping type to replace GspMsgElement for querying
RPC header data. The initialization of the RPC header is now handled
separately by the command queue code.

> diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs
> --- a/drivers/gpu/nova-core/gsp/cmdq.rs
> +++ b/drivers/gpu/nova-core/gsp/cmdq.rs
[ ... ]
> @@ -768,16 +774,28 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {
>          // Extract the `GspMsgElement`.
>          let (header, slice_1) = GspMsgElement::from_bytes_prefix(slice_1).ok_or(EIO)?;
>  
> +        // Validate checksum.
> +        if Cmdq::calculate_checksum(SBufferIter::new_reader([
> +            header.as_bytes(),
> +            slice_1,
> +            slice_2,
> +        ])) != 0
> +        {
> +            dev_err!(&self.dev, "GSP receive: bad checksum\n");
> +            return Err(EIO);
> +        }
> +

[Severity: High]
Does this code compute the checksum over the entire untruncated message buffers?

By moving Cmdq::calculate_checksum() to run before slice_1 and slice_2 are
truncated to payload_length, it appears to process uninitialized page padding
and any subsequent messages present in the ring buffer.

The previous code correctly computed the checksum over the exact message size
after truncating the slices:

        // Cut the message slices down to the actual length of the message.
        let (slice_1, slice_2) = if slice_1.len() > payload_length {
            ...
        };

        // Validate checksum.
        if Cmdq::calculate_checksum( ... ) != 0

Could this result in the driver dropping valid GSP messages due to spurious
checksum failures, stalling the command queue and preventing GPU initialization?

It appears this flaw persists in the final commit of the series
(41ab580cce9e4df6dca3c50983301c4f117e6a64). Even though the code is refactored
into wait_for_element() and wait_for_rpc_msg(), wait_for_element() still calls
calculate_checksum() on the untruncated slices before returning the message to
wait_for_rpc_msg() where the size truncation finally happens.

> +        let rpc_header = header.rpc_header();
> +        let payload_length = rpc_header.length();
> +
>          dev_dbg!(
>              &self.dev,
>              "GSP RPC: receive: seq# {}, function={:?}, length=0x{:x}\n",
> -            header.sequence(),
> -            header.function(),
> -            header.length(),
> +            rpc_header.sequence(),
> +            rpc_header.function(),
> +            payload_length,
>          );
>  
> -        let payload_length = header.payload_length();
> -
>          // Check that the driver read area is large enough for the message.
>          if slice_1.len() + slice_2.len() < payload_length {
>              return Err(EIO);
> @@ -796,21 +814,6 @@ fn wait_for_msg(&self, timeout: Delta) -> Result<GspMessage<'_>> {
>              )
>          };
>  
> -        // Validate checksum.
> -        if Cmdq::calculate_checksum(SBufferIter::new_reader([
> -            header.as_bytes(),
> -            slice_1,
> -            slice_2,
> -        ])) != 0
> -        {
> -            dev_err!(
> -                &self.dev,
> -                "GSP RPC: receive: Call {} - bad checksum\n",
> -                header.sequence()
> -            );
> -            return Err(EIO);
> -        }
> -
>          Ok(GspMessage {
>              header,
>              contents: (slice_1, slice_2),

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260927-cmdq-rpc-v1-0-822db5af910e@nvidia.com?part=3

  reply	other threads:[~2026-09-27 11:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 11:14 [PATCH 00/10] gpu: nova-core: gsp: prepare the command queue for r000 dual-message types Alexandre Courbot
2026-09-27 11:14 ` [PATCH 01/10] gpu: nova-core: gsp: cmdq: use element_count to advance queue pointer Alexandre Courbot
2026-09-27 11:23   ` sashiko-bot
2026-09-27 11:14 ` [PATCH 02/10] gpu: nova-core: gsp: cmdq: validate checksum earlier on receive Alexandre Courbot
2026-09-27 11:23   ` sashiko-bot
2026-09-27 11:14 ` [PATCH 03/10] gpu: nova-core: gsp: introduce and use proper RpcMessageHeader type Alexandre Courbot
2026-09-27 11:25   ` sashiko-bot [this message]
2026-09-27 11:14 ` [PATCH 04/10] gpu: nova-core: gsp: cmdq: group the RPC-specific part of send_single_command Alexandre Courbot
2026-09-27 11:14 ` [PATCH 05/10] gpu: nova-core: gsp: cmdq: split the transport part of the send path Alexandre Courbot
2026-09-27 11:26   ` sashiko-bot
2026-09-27 11:14 ` [PATCH 06/10] gpu: nova-core: gsp: cmdq: move the RPC send code into a sub-module Alexandre Courbot
2026-09-27 11:14 ` [PATCH 07/10] gpu: nova-core: gsp: cmdq: split the transport part of the receive path Alexandre Courbot
2026-09-27 11:27   ` sashiko-bot
2026-09-27 11:14 ` [PATCH 08/10] gpu: nova-core: gsp: cmdq: move the RPC receive code into a sub-module Alexandre Courbot
2026-09-27 11:14 ` [PATCH 09/10] gpu: nova-core: gsp: move the RPC commands " Alexandre Courbot
2026-09-27 11:14 ` [PATCH 10/10] gpu: nova-core: gsp: add `rpc` to RPC message send/receive methods Alexandre Courbot
2026-09-27 11:22   ` sashiko-bot
2026-09-27 13:35 ` [PATCH 00/10] gpu: nova-core: gsp: prepare the command queue for r000 dual-message types 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=20260927112517.C334F1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --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.