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: <DBBQQQVVCTAC.I1OXFG4SVLRO@kernel.org>
Date: Mon, 14 Jul 2025 13:28:17 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Rhys Lloyd" <krakow20@...il.com>
Cc: <acourbot@...dia.com>, "Joel Fernandes" <joelagnelf@...dia.com>,
 <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 v2] gpu: nova-core: vbios: change PmuLookupTableEntry to
 relax alignment

(Cc: Joel)

On Mon Jul 14, 2025 at 1:02 PM CEST, Rhys Lloyd wrote:
> Instead of the data field containing a u32 and changing the alignment,
> change data to [u8; 4] and convert to u32 with a helper function.
> Removes another magic number by making the struct the same size as
> the data it needs to read, allowing the use of
> `size_of::<PmuLookupTableEntry>()`
>
> Signed-off-by: Rhys Lloyd <krakow20@...il.com>
> ---
> Changes in v2:
> - get_data helper function renamed to data
>
> ---
>  drivers/gpu/nova-core/vbios.rs | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
> index 5b5d9f38cbb3..339c66e63c7e 100644
> --- a/drivers/gpu/nova-core/vbios.rs
> +++ b/drivers/gpu/nova-core/vbios.rs
> @@ -896,21 +896,26 @@ fn try_from(base: BiosImageBase) -> Result<Self> {
>  struct PmuLookupTableEntry {
>      application_id: u8,
>      target_id: u8,
> -    data: u32,
> +    data: [u8; 4],
>  }
>  
>  impl PmuLookupTableEntry {
>      fn new(data: &[u8]) -> Result<Self> {
> -        if data.len() < 6 {
> +        if data.len() < core::mem::size_of::<Self>() {
>              return Err(EINVAL);
>          }
>  
>          Ok(PmuLookupTableEntry {
>              application_id: data[0],
>              target_id: data[1],
> -            data: u32::from_le_bytes(data[2..6].try_into().map_err(|_| EINVAL)?),
> +            data: [data[2], data[3], data[4], data[5]],
>          })
>      }
> +
> +    /// Construct a u32 from `self.data`.
> +    fn data(&self) -> u32 {
> +        u32::from_le_bytes(self.data)
> +    }
>  }
>  
>  /// The [`PmuLookupTableEntry`] structure is used to find the [`PmuLookupTableEntry`] for a given
> @@ -1037,7 +1042,7 @@ fn setup_falcon_data(
>              .find_entry_by_type(FALCON_UCODE_ENTRY_APPID_FWSEC_PROD)
>          {
>              Ok(entry) => {
> -                let mut ucode_offset = entry.data as usize;
> +                let mut ucode_offset = entry.data() as usize;
>                  ucode_offset -= pci_at_image.base.data.len();
>                  if ucode_offset < first_fwsec.base.data.len() {
>                      dev_err!(pdev.as_ref(), "Falcon Ucode offset not in second Fwsec.\n");
>
> base-commit: 215a3f91713383a3c0d2da82d223a608a3c17ac1
> prerequisite-patch-id: d80f92d314a0693d4c89ffb7810d9ab6990336fa


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ