lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DBD3I0RWQ39M.XA1Q0WSOJWSE@nvidia.com>
Date: Wed, 16 Jul 2025 10:40:47 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Rhys Lloyd" <krakow20@...il.com>, <dakr@...nel.org>
Cc: <rust-for-linux@...r.kernel.org>, <airlied@...il.com>,
 <simona@...ll.ch>, <nouveau@...ts.freedesktop.org>,
 <dri-devel@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpu: nova-core: vbios: split out PmuLookupTableHeader
 from PmuLookupTable

On Mon Jul 14, 2025 at 7:43 PM JST, Rhys Lloyd wrote:
> Separating the header allows the use of `size_of::<PmuLookupTableHeader>()`
> instead of the magic number 4.
>
> Signed-off-by: Rhys Lloyd <krakow20@...il.com>
> ---
>  drivers/gpu/nova-core/vbios.rs | 56 +++++++++++++++++++++-------------
>  1 file changed, 35 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
> index 663fc50e8b66..20011c5c9bbc 100644
> --- a/drivers/gpu/nova-core/vbios.rs
> +++ b/drivers/gpu/nova-core/vbios.rs
> @@ -889,6 +889,32 @@ fn try_from(base: BiosImageBase) -> Result<Self> {
>      }
>  }
>  
> +/// The [`PmuLookupTableHeader`] structure is header information for [`PmuLookupTable`].
> +///
> +/// See the [`PmuLookupTable`] description for more information.
> +#[expect(dead_code)]
> +struct PmuLookupTableHeader {
> +    version: u8,
> +    header_len: u8,
> +    entry_len: u8,
> +    entry_count: u8,
> +}
> +
> +impl PmuLookupTableHeader {

Can you add a 

  // TODO[TRSM]: use FromBytes::from_bytes when it becomes available.

as ultimately that's what we want to do.

(we are using these markers to keep track of tasks to complete as Rust
features land, see Documentation/gpu/nova/core/todo.rst)

> +    fn new(data: &[u8]) -> Result<Self> {
> +        if data.len() < core::mem::size_of::<Self>() {
> +            return Err(EINVAL);
> +        }
> +
> +        Ok(PmuLookupTableHeader {
> +            version: data[0],

How about making `PmuLookupTableHeader` `#[repr(C)]` and using
`offset_of!`? This will also set the stage for the transition to using
`FromBytes::from_bytes`.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ