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 <[email protected]> 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/[email protected]?part=5
