Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: Timur Tabi <ttabi@nvidia.com>
To: Alexandre Courbot <acourbot@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>,
	Eliot Courtney <ecourtney@nvidia.com>,
	"nova-gpu@lists.linux.dev" <nova-gpu@lists.linux.dev>,
	Zhi Wang <zhiw@nvidia.com>, "gary@garyguo.net" <gary@garyguo.net>,
	"mcgrof@kernel.org" <mcgrof@kernel.org>,
	"dakr@kernel.org" <dakr@kernel.org>,
	"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>,
	"driver-core@lists.linux.dev" <driver-core@lists.linux.dev>,
	"ojeda@kernel.org" <ojeda@kernel.org>,
	"russ.weight@linux.dev" <russ.weight@linux.dev>
Subject: Re: [PATCH v3 3/7] gpu: nova-core: transition booter_load to TLV images
Date: Wed, 8 Jul 2026 20:46:59 +0000	[thread overview]
Message-ID: <a3b7dcc404d857531972ac52623e63620d117cc1.camel@nvidia.com> (raw)
In-Reply-To: <DJR9ZZLA72BK.G14HXKV5E8LP@nvidia.com>

On Mon, 2026-07-06 at 15:31 +0900, Alexandre Courbot wrote:
> 
> > +        let os_data_offset = tlv.get_u32(b"DAOF")?;
> > +        let os_data_size = tlv.get_u32(b"DASZ")?;
> > +        let os_code_offset = tlv.get_u32(b"CDOF")?;
> > +        let os_code_size = tlv.get_u32(b"CDSZ")?;
> > +        let patch_loc = tlv.get_u32(b"PLOC")?;
> > +        let fuse_version = tlv.get_u32(b"FUSE")?;
> > +        let engine_id = tlv.get_u32(b"ENID")?;
> > +        let ucode_id = tlv.get_u32(b"UCID")?;
> > +        let app0_code_offset = tlv.get_u32(b"A0CO")?;
> > +        let app0_code_size = tlv.get_u32(b"A0CS")?;
> > +        let num_sigs = tlv.get_u32(b"NSIG")?;
> > +        let sig_bytes = tlv.get_bytes(b"SIGN")?;
> > +
> > +        // Booter is always signed
> 
> The `.rst` file mentions the non-signed case though - we should
> reconcile the spec and the code one way or the other.

The .rst does not mention that Booter is signed, only that if the firmware is unsigned, then NSIG is
0 and SIGN does not exist.  And since get_bytes() now returns Error if SIGN doesn't exist, we
enforce that here.

But you're right in that it does feel a little off.  That's one of the reasons I had get_nth() in v1
-- to streamline getting the nth signature.  

What do you think about adding a get_signature(index) method that combines parsing NSIG and SIGN,
automatically calculating sig_size and returning Option<&[u8]> ?

> 
> >  
> > +        // The size of one signature
> > +        let sig_size = sig_bytes
> > +            .len()
> > +            .checked_div(num_sigs.into_safe_cast())
> > +            .ok_or(EINVAL)?;
> > +
> > +        // Extract the nth signature
> > +        let sig_chunk = sig_bytes
> > +            .chunks_exact(sig_size)
> 
> As Sashiko pointed out, this will panic if `sig_size == 0`, so we need
> to check that - and whether an unsigned Booter is valid at all.

sig_size cannot be 0 because of this:

        if !(1..=15).contains(&num_sigs) || sig_bytes.len() % num_sigs != 0 {

Neither sig_bytes.len() nor num_sigs can be 0.

But IMHO, this just reinforces the idea that I should add get_signature().



  reply	other threads:[~2026-07-08 20:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 19:27 [PATCH v3 0/7] Transition Nova Core to TLV firmare images Timur Tabi
2026-07-02 19:27 ` [PATCH v3 1/7] rust: firmware: add request_into_buf() Timur Tabi
2026-07-03  2:51   ` Alvin Sun
2026-07-03  3:06     ` Timur Tabi
2026-07-03 13:51       ` Danilo Krummrich
2026-07-06  6:30   ` Alexandre Courbot
2026-07-06 10:50     ` Danilo Krummrich
2026-07-07  2:54       ` Timur Tabi
2026-07-07  5:10         ` Alexandre Courbot
2026-07-07 13:32           ` Danilo Krummrich
2026-07-02 19:27 ` [PATCH v3 2/7] gpu: nova-core: add TLV parser for firmware files Timur Tabi
2026-07-02 19:45   ` Timur Tabi
2026-07-06  6:31     ` Alexandre Courbot
2026-07-07  2:56       ` Timur Tabi
2026-07-07  5:13         ` Alexandre Courbot
2026-07-06  6:31   ` Alexandre Courbot
2026-07-08 20:12     ` Timur Tabi
2026-07-02 19:27 ` [PATCH v3 3/7] gpu: nova-core: transition booter_load to TLV images Timur Tabi
2026-07-06  6:31   ` Alexandre Courbot
2026-07-08 20:46     ` Timur Tabi [this message]
2026-07-02 19:27 ` [PATCH v3 4/7] gpu: nova-core: transition gsp " Timur Tabi
2026-07-02 19:27 ` [PATCH v3 5/7] gpu: nova-core: transition gen_bootloader " Timur Tabi
2026-07-06  6:31   ` Alexandre Courbot
2026-07-02 19:27 ` [PATCH v3 6/7] gpu: nova-core: transition fsp " Timur Tabi
2026-07-02 19:27 ` [PATCH v3 7/7] gpu: nova-core: update firmware module info for " Timur Tabi

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=a3b7dcc404d857531972ac52623e63620d117cc1.camel@nvidia.com \
    --to=ttabi@nvidia.com \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=mcgrof@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=russ.weight@linux.dev \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=zhiw@nvidia.com \
    /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