From: sashiko-bot@kernel.org
To: "Eliot Courtney" <ecourtney@nvidia.com>
Cc: dri-devel@lists.freedesktop.org,
"Danilo Krummrich" <dakr@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
ojeda@kernel.org, gary@garyguo.net
Subject: Re: [PATCH v3 5/8] gpu: nova-core: add NVKV decoder
Date: Mon, 28 Sep 2026 08:52:11 +0000 [thread overview]
Message-ID: <20260928085212.625421F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260928-b4-nvkv-v3-5-f04504c262c2@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] nova-core: NVKV decode corrupts array layouts on big-endian hosts
--
commit 561207bfbca10da1af8ade9ea863d375b4883ed5
Author: Eliot Courtney <ecourtney@nvidia.com>
gpu: nova-core: add NVKV decoder
Add a decoder for NVKV. This is for receiving messages from GSP for
GMCAPI calls. The NVKV format essentially encodes a sequence of function
calls f(key, index, value).
> 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..c4c24fe1108e9
> --- /dev/null
> +++ b/drivers/gpu/nova-core/gsp/nvkv/decode.rs
[ ... ]
> + /// Takes `count` bytes. If `count` is not a multiple of 8 (`u64` size), bytes are discarded up
> + /// to the next multiple.
> + fn take_u8s(&mut self, count: usize) -> Result<&'a [u8]> {
> + let values = self.take_u64s(count.div_ceil(8))?;
> + values.as_bytes().get(..count).ok_or(EINVAL)
[Severity: High]
Does Cursor::take_u8s() in drivers/gpu/nova-core/gsp/nvkv/decode.rs handle
big-endian architectures correctly?
Directly casting native u64 memory to u8 slices yields the bytes in reverse
order within each 64-bit word on big-endian systems.
This could cause the NVKV protocol to fail to correctly decode (and encode)
`Array8` arrays, causing GPU initialization (GSP RPC) to fail completely or
receive corrupted data.
> + }
> +
> + /// Takes `count` 32-bit values. If `count` is not a multiple of 2 (`u64` size), bytes are
> + /// discarded up to the next multiple.
> + fn take_u32s(&mut self, count: usize) -> Result<&'a [u32]> {
> + let values = self.take_u64s(count.div_ceil(2))?;
> + <[u32]>::ref_from_prefix_with_elems(values.as_bytes(), count)
[Severity: High]
Can Cursor::take_u32s() corrupt array layouts on big-endian hosts?
Directly mapping native-endian u64 memory to u32 slices swaps the order of
packed elements on big-endian systems (e.g., swapping the first and second
32-bit values within the 64-bit word).
This defect prevents correctly decoding `Array32` and `Seq32` arrays on these
platforms.
> + .map(|(elems, _)| elems)
> + .map_err(|_| EINVAL)
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260928-b4-nvkv-v3-0-f04504c262c2@nvidia.com?part=5
next prev parent reply other threads:[~2026-09-28 8:52 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 8:42 [PATCH v3 0/8] gpu: nova-core: add NVKV codec Eliot Courtney
2026-09-28 8:42 ` [PATCH v3 1/8] rust: alloc: add Vec::try_push_init Eliot Courtney
2026-09-28 8:51 ` sashiko-bot
2026-10-06 5:52 ` Alexandre Courbot
2026-09-28 8:42 ` [PATCH v3 2/8] rust: alloc: add Vec::push_init Eliot Courtney
2026-09-28 8:52 ` sashiko-bot
2026-10-06 6:10 ` Alexandre Courbot
2026-09-28 8:42 ` [PATCH v3 3/8] rust: alloc: add ArrayVec Eliot Courtney
2026-09-28 8:51 ` sashiko-bot
2026-10-07 6:27 ` Alexandre Courbot
2026-09-28 8:42 ` [PATCH v3 4/8] gpu: nova-core: add NVKV encoder Eliot Courtney
2026-09-28 8:52 ` sashiko-bot
2026-10-07 3:43 ` Alexandre Courbot
2026-10-07 3:48 ` Alexandre Courbot
2026-10-07 11:33 ` John Hubbard
2026-10-07 11:56 ` Alexandre Courbot
2026-09-28 8:42 ` [PATCH v3 5/8] gpu: nova-core: add NVKV decoder Eliot Courtney
2026-09-28 8:52 ` sashiko-bot [this message]
2026-10-07 4:51 ` Alexandre Courbot
2026-09-28 8:42 ` [PATCH v3 6/8] gpu: nova-core: add NVKV typed encoding Eliot Courtney
2026-10-07 6:30 ` Alexandre Courbot
2026-09-28 8:42 ` [PATCH v3 7/8] gpu: nova-core: add NVKV typed decoding Eliot Courtney
2026-10-07 6:30 ` Alexandre Courbot
2026-10-07 12:05 ` Alexandre Courbot
2026-09-28 8:42 ` [PATCH v3 8/8] gpu: nova-core: add NVKV GSP_INIT schemas Eliot Courtney
2026-10-07 10:53 ` 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=20260928085212.625421F000FF@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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox