All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pedro Yudi Honda" <niyudi.honda@usp.br>
Cc: dri-devel@lists.freedesktop.org, ojeda@kernel.org
Subject: Re: [PATCH v2 3/5] drm/nova: use `zerocopy` in fwsec.rs
Date: Wed, 01 Jul 2026 17:48:47 +0000	[thread overview]
Message-ID: <20260701174848.07E5F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701174056.12604-4-niyudi.honda@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Firmware structures use native integer types (e.g., `u32`, `u64`, `u16`) instead of explicit little-endian types, which causes data corruption when parsing firmware metadata on big-endian architectures.
--

commit 5588d64059dd57b42b45063f16c1c4ba8ddc35f4
Author: Pedro Yudi Honda <niyudi.honda@usp.br>

drm/nova: use zerocopy in fwsec.rs
    
In firmware/fwsec.rs, replace the following transmute traits with
their zerocopy equivalents:

- transmute::FromBytes -> zerocopy::FromBytes
- transmute::AsBytes -> zerocopy::IntoBytes
- add zerocopy::KnownLayout where necessary

Update call sites accordingly.

> diff --git a/drivers/gpu/nova-core/firmware/fwsec.rs b/drivers/gpu/nova-core/firmware/fwsec.rs
> index 95e0dd77746b0..1b75cdc02256c 100644
> --- a/drivers/gpu/nova-core/firmware/fwsec.rs
> +++ b/drivers/gpu/nova-core/firmware/fwsec.rs

[ ... ]

>  #[repr(C, packed)]
> -#[derive(Debug)]
> +#[derive(Debug, FromBytes)]
>  struct FalconAppifV1 {
>      id: u32,
>      dmem_base: u32,
>  }

[Severity: High]
This is a pre-existing issue, but will this struct misinterpret the firmware
data on big-endian architectures?

The firmware is little-endian, but these fields use native u32 types. When
read_from_prefix() parses the little-endian bytes directly into native types
on a big-endian host, it will corrupt dmem_base and id.

This causes out-of-bounds calculations when using dmem_base as an offset,
leading to an EINVAL failure during driver initialization.

Since this patch migrates the code to use zerocopy, would it make sense to
update these structures to use zerocopy's endian-aware types (such as
zerocopy::byteorder::little_endian::U32) instead of native integers?

[ ... ]

> -#[derive(Debug)]
> +#[derive(Debug, FromBytes, IntoBytes, zerocopy_derive::KnownLayout)]
>  #[repr(C, packed)]
>  struct FalconAppifDmemmapperV3 {
>      signature: u32,
>      os_code_offset: u32,
>      os_code_size: u32,

[Severity: High]
This is a pre-existing issue, but does this struct also need endian-aware
types for its u32 fields to prevent data corruption during parsing on
big-endian hosts?

[ ... ]

> -#[derive(Debug)]
> +#[derive(Debug, FromBytes, IntoBytes, zerocopy_derive::KnownLayout)]
>  #[repr(C, packed)]
>  struct ReadVbios {
>      ver: u32,
>      hdr: u32,
>      addr: u64,

[Severity: High]
This is a pre-existing issue, but does this struct also need endian-aware
types for its native u32 and u64 fields?

[ ... ]

> -#[derive(Debug)]
> +#[derive(Debug, FromBytes, IntoBytes, zerocopy_derive::KnownLayout)]
>  #[repr(C, packed)]
>  struct FrtsRegion {
>      ver: u32,
>      hdr: u32,
>      addr: u32,

[Severity: High]
This is a pre-existing issue, but will this command structure send corrupted
coordinates to the firmware if written from a big-endian architecture?

It appears to use native u32 types instead of little-endian types.

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260701174056.12604-1-niyudi.honda@gmail.com?part=3

  reply	other threads:[~2026-07-01 17:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 17:40 [PATCH v2 0/5] drm/nova: replace `transmute` with `zerocopy` Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 1/5] drm/nova: use `zerocopy` in firmware.rs Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 2/5] drm/nova: use `zerocopy` in booter.rs Pedro Yudi Honda
2026-07-01 17:50   ` sashiko-bot
2026-07-01 17:40 ` [PATCH v2 3/5] drm/nova: use `zerocopy` in fwsec.rs Pedro Yudi Honda
2026-07-01 17:48   ` sashiko-bot [this message]
2026-07-01 17:40 ` [PATCH v2 4/5] drm/nova: use `zerocopy` in bootloader.rs Pedro Yudi Honda
2026-07-01 17:40 ` [PATCH v2 5/5] drm/nova: use `zerocopy` in riscv.rs Pedro Yudi Honda
  -- strict thread matches above, loose matches on Subject: below --
2026-07-02 12:03 [RESEND PATCH v2 0/5] drm/nova: replace `transmute` with `zerocopy` Pedro Yudi Honda
2026-07-02 12:03 ` [PATCH v2 3/5] drm/nova: use `zerocopy` in fwsec.rs Pedro Yudi Honda
2026-07-06 11:43   ` Alistair Popple

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=20260701174848.07E5F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=niyudi.honda@usp.br \
    --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.