[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8b14b078-b899-42e8-8522-599daa65bc63@nvidia.com>
Date: Thu, 15 May 2025 12:17:00 -0700
From: John Hubbard <jhubbard@...dia.com>
To: Timur Tabi <timur@...nel.org>, Greg KH <gregkh@...uxfoundation.org>
Cc: Alexandre Courbot <acourbot@...dia.com>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH] rust: add basic ELF sections parser
On 5/15/25 7:30 AM, Timur Tabi wrote:
> On Thu, May 15, 2025 at 6:43 AM Greg KH <gregkh@...uxfoundation.org> wrote:
>>> Or if ELF is the problem, I don't mind introducing a WAD loader. ;)
>>
>> The "problem" I'm not understanding is why does the kernel have to do
>> any of this parsing at all?
>
> Nova will need to parse ELF headers in order to properly load and boot
> Nvidia firmware images. Nouveau does this already:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c#n2931
Hi Greg!
Nouveau influenced us heavily here, because having firmware that we
can post once, and use everywhere (Nouveau and Nova), is very attractive.
Alex and Timur discuss other details that explain why the standard
user-space approach is less simple and clean than it might appear at
first glance, but I wanted to emphasize that the firmware re-use point
a little bit, too.
Oh, and also: the ELF images are going to remain extremely simple,
because there is nothing now (nor can I see anything in the future)
that would drive anyone to do complicated things. For example, if
there is some exotic new thing in the future, it could be put into
its own firmware image if necessary--because we understand that
this parser here is intended to be a simple subset of ELF, and
left alone really.
thanks,
--
John Hubbard
>
> In addition, we are adding new ELF image support to Nouveau to support
> newer Hopper and Blackwell GPUs:
>
> https://lore.kernel.org/nouveau/20250511210722.80350-55-bskeggs@nvidia.com/T/
> (grep for "elf_header[]")
>
> For this new code, I used ELF for new firmware images. I did this for
> a few reasons:
>
> 1. In addition to the large GSP-RM binary, there are 3 "meta data"
> blobs that are very small (<100 bytes) and I wanted a way to combine
> all blobs into one file to keep things neat.
> 2. I didn't want to invent a new encapsulation format from scratch.
> 3. ELF allows you to use existing user-space tools to parse the file
> if you are so inclined.
> 4. ELF contained all of the header bits I was looking for.
> 5. I was even able to include a CRC in the ELF header, for extra validation.
> 6. Structs for the headers already exist in the kernel and are used by
> other drivers.
>
>
>
> What does it do with these segments that
>> userspace can't do instead? Why does patching have to be done within
>> the kernel at all? What prevents all of this from being done elsewhere?
>>
>> And ELF parsing is "tricky" in places, and you aren't using the existing
>> elf parser, as proof of needing a new parser in rust :)
>>
>> thanks,
>>
>> greg k-h
>>
>
Powered by blists - more mailing lists