From: sashiko-bot@kernel.org
To: "Eliot Courtney" <ecourtney@nvidia.com>
Cc: ojeda@kernel.org, "Danilo Krummrich" <dakr@kernel.org>,
dri-devel@lists.freedesktop.org,
"Alexandre Courbot" <acourbot@nvidia.com>
Subject: Re: [PATCH 2/6] gpu: nova-core: add NVKV encoder
Date: Mon, 17 Aug 2026 13:06:42 +0000 [thread overview]
Message-ID: <20260817130642.8BF9D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260817-b4-nvkv-v1-2-b84db5e84b67@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] NVKV array encoding relies on host memory layout, causing endianness corruption and unconditional KUnit test failures on big-endian architectures.
--
--- Patch [2]: [PATCH 2/6] gpu: nova-core: add NVKV encoder ---
commit 0223916dc52ad28f6ad72c2fdc7087b7939c7ed3
Author: Eliot Courtney <ecourtney@nvidia.com>
gpu: nova-core: add NVKV encoder
This commit adds an encoder for the NVKV wire format, which encodes calls
as a sequence of 64-bit values. It includes functions to encode single
values and arrays, and adds a test for the encoding.
> diff --git a/drivers/gpu/nova-core/gsp/nvkv/encode.rs b/drivers/gpu/nova-core/gsp/nvkv/encode.rs
> index 0000000000000..6da81a371651a 100644
> --- /dev/null
> +++ b/drivers/gpu/nova-core/gsp/nvkv/encode.rs
[ ... ]
> + fn push_bytes_with_padding(&mut self, bytes: &[u8]) -> Result {
[ ... ]
> + // SAFETY: At least bytes.len() bytes of space are guaranteed since num_entries
> + // worth of space was just reserved.
> + unsafe { core::ptr::copy_nonoverlapping(bytes.as_ptr(), dst, bytes.len()) };
> +
> + let padding = num_entries * size_of::<u64>() - bytes.len();
> + if padding > 0 {
> + // SAFETY: At least num_entries * size_of::<u64>() bytes of space are guaranteed.
> + unsafe { core::ptr::write_bytes(dst.add(bytes.len()), 0, padding) };
> + }
> +
> + // SAFETY: These bytes were just initialized and every bit pattern is valid for u64.
> + unsafe { self.backing.inc_len(num_entries) };
> +
> + Ok(())
> + }
[ ... ]
> + pub(crate) fn encode_array32(&mut self, key: KeyId, index: Index, array: &[u32]) -> Result {
[ ... ]
> + self.push_bytes_with_padding(array.as_bytes())?;
> + Ok(())
> + }
[ ... ]
> + pub(crate) fn encode_array64(&mut self, key: KeyId, index: Index, array: &[u64]) -> Result {
[ ... ]
> + self.push_bytes_with_padding(array.as_bytes())?;
> + Ok(())
> + }
[Severity: High]
Will this produce an incorrect byte stream on big-endian architectures?
Because push_bytes_with_padding() in drivers/gpu/nova-core/gsp/nvkv/encode.rs
copies host memory directly into the u64 backing storage, and encode_array32()
and encode_array64() extract host-endian bytes via array.as_bytes(), the
endianness of the generated stream depends on the host.
[ ... ]
> + assert_eq!(
> + encoded[4],
> + u64::from_le_bytes([0xaa, 0xbb, 0xcc, 0, 0, 0, 0, 0])
> + );
[Severity: High]
Will this test unconditionally fail on big-endian systems?
The test in drivers/gpu/nova-core/gsp/nvkv/encode.rs explicitly asserts that
the generated u64 must match a little-endian layout, which seems to prove
the host-endian implementation above will produce unexpected results on
big-endian architectures.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260817-b4-nvkv-v1-0-b84db5e84b67@nvidia.com?part=2
next prev parent reply other threads:[~2026-08-17 13:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 12:56 [PATCH 0/6] gpu: nova-core: add NVKV codec Eliot Courtney
2026-08-17 12:56 ` [PATCH 1/6] rust: alloc: add Vec::push_init Eliot Courtney
2026-08-17 14:02 ` Gary Guo
2026-08-19 7:43 ` Eliot Courtney
2026-08-19 10:49 ` Danilo Krummrich
2026-08-19 11:23 ` Danilo Krummrich
2026-08-19 12:08 ` Gary Guo
2026-08-19 12:14 ` Gary Guo
2026-08-25 1:52 ` Eliot Courtney
2026-08-26 14:15 ` Eliot Courtney
2026-08-17 12:56 ` [PATCH 2/6] gpu: nova-core: add NVKV encoder Eliot Courtney
2026-08-17 13:06 ` sashiko-bot [this message]
2026-08-19 16:32 ` Danilo Krummrich
2026-08-19 16:47 ` Danilo Krummrich
2026-08-24 12:58 ` Eliot Courtney
2026-08-27 14:25 ` Eliot Courtney
2026-08-28 18:11 ` Danilo Krummrich
2026-08-17 12:56 ` [PATCH 3/6] gpu: nova-core: add NVKV decoder Eliot Courtney
2026-08-17 13:06 ` sashiko-bot
2026-08-17 12:56 ` [PATCH 4/6] gpu: nova-core: add NVKV typed encoding Eliot Courtney
2026-08-17 12:56 ` [PATCH 5/6] gpu: nova-core: add NVKV typed decoding Eliot Courtney
2026-08-19 18:59 ` Danilo Krummrich
2026-08-25 6:46 ` Eliot Courtney
2026-08-17 12:56 ` [PATCH 6/6] gpu: nova-core: add NVKV GSP_INIT schemas Eliot Courtney
2026-08-17 13:06 ` 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=20260817130642.8BF9D1F000E9@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