dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eliot Courtney" <ecourtney@nvidia.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	dri-devel@lists.freedesktop.org, ojeda@kernel.org
Subject: Re: [PATCH v2 5/8] gpu: nova-core: add NVKV decoder
Date: Thu, 27 Aug 2026 14:36:28 +0000	[thread overview]
Message-ID: <20260827143629.61BEE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827-b4-nvkv-v2-5-0de9d5c8658c@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Host-endianness dependency in NVKV decoder corrupts GSP messages on Big-Endian systems.
--

commit 5b94f2ac2ef1beaefecc7f609e789baca4eb7809
Author: Eliot Courtney <ecourtney@nvidia.com>

gpu: nova-core: add NVKV decoder
    
This commit adds a decoder for NVKV to receive messages from GSP for GMCAPI
calls. The decoder reads an encoded stream and invokes a type implementing
the Schema visitor trait.

> diff --git a/drivers/gpu/nova-core/gsp/nvkv/decode.rs b/drivers/gpu/nova-core/gsp/nvkv/decode.rs
> new file mode 100644
> index 0000000000000..ceb97e73e1004
> --- /dev/null
> +++ b/drivers/gpu/nova-core/gsp/nvkv/decode.rs
[ ... ]
> +    fn take_u32s(&mut self, count: usize) -> Result<&[u32]> {
> +        let values = self.take_u64s(count.div_ceil(2))?;
> +        <[u32]>::ref_from_prefix_with_elems(values.as_bytes(), count)

[Severity: High]
Does this code correctly handle endianness on Big-Endian architectures?

This views a byte slice derived from Little-Endian DMA memory as an array of
native 32-bit elements. On Big-Endian architectures, this will reverse the
byte order of each integer, leading to corrupted parsing of message arrays.

> +            .map(|(elems, _)| elems)
> +            .map_err(|_| EINVAL)
> +    }
[ ... ]
> +    pub(crate) fn decode<'s, S: Schema>(
> +        &self,
> +        schema: &'s mut S,
> +    ) -> Result<impl Init<S::Target, Error> + 's> {
> +        let mut cursor = Cursor::new(self.data);
> +        while !cursor.is_empty() {
> +            let op: Op = cursor.take_u64()?.into();

[Severity: High]
Can this native 64-bit read corrupt GSP message parsing on Big-Endian systems?

This reads a 64-bit word natively and parses it as a bitfield. Since the
underlying GSP memory is Little-Endian, the native bitfield extraction reads
the wrong bits entirely on Big-Endian systems, which could lead to device
initialization failure.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260827-b4-nvkv-v2-0-0de9d5c8658c@nvidia.com?part=5

  reply	other threads:[~2026-08-27 14:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 14:12 [PATCH v2 0/8] gpu: nova-core: add NVKV codec Eliot Courtney
2026-08-27 14:12 ` [PATCH v2 1/8] rust: alloc: add Vec::try_push_init Eliot Courtney
2026-08-27 14:12 ` [PATCH v2 2/8] rust: alloc: add Vec::push_init Eliot Courtney
2026-08-27 14:30   ` sashiko-bot
2026-08-27 14:12 ` [PATCH v2 3/8] rust: alloc: add ArrayVec Eliot Courtney
2026-08-27 14:33   ` sashiko-bot
2026-08-27 14:12 ` [PATCH v2 4/8] gpu: nova-core: add NVKV encoder Eliot Courtney
2026-08-27 14:35   ` sashiko-bot
2026-09-07 15:07   ` Alexandre Courbot
2026-08-27 14:12 ` [PATCH v2 5/8] gpu: nova-core: add NVKV decoder Eliot Courtney
2026-08-27 14:36   ` sashiko-bot [this message]
2026-09-09  0:51   ` Alexandre Courbot
2026-09-09  1:13     ` Eliot Courtney
2026-09-09  4:48       ` Alexandre Courbot
2026-09-10  7:47   ` Alexandre Courbot
2026-08-27 14:12 ` [PATCH v2 6/8] gpu: nova-core: add NVKV typed encoding Eliot Courtney
2026-09-10  8:10   ` Alexandre Courbot
2026-09-11  5:17     ` Alexandre Courbot
2026-09-11  5:28       ` Eliot Courtney
2026-09-11 11:18         ` Alexandre Courbot
2026-08-27 14:12 ` [PATCH v2 7/8] gpu: nova-core: add NVKV typed decoding Eliot Courtney
2026-08-27 14:12 ` [PATCH v2 8/8] gpu: nova-core: add NVKV GSP_INIT schemas Eliot Courtney
2026-08-27 14:34   ` sashiko-bot

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=20260827143629.61BEE1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox