[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOZdJXWKLu0y+kwC+Bm8nBCLizQVpsDdDUoS--hVgz2vnuZJQg@mail.gmail.com>
Date: Thu, 15 May 2025 09:30:28 -0500
From: Timur Tabi <timur@...nel.org>
To: 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 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
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