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] [day] [month] [year] [list]
Message-ID: <ad09976c-07ed-4ba4-b103-4433cab59c5e@nvidia.com>
Date: Thu, 5 Jun 2025 12:28:39 -0400
From: Joel Fernandes <joelagnelf@...dia.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: Lyude Paul <lyude@...hat.com>, 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>, David Airlie <airlied@...il.com>,
 Simona Vetter <simona@...ll.ch>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
 John Hubbard <jhubbard@...dia.com>, Ben Skeggs <bskeggs@...dia.com>,
 Timur Tabi <ttabi@...dia.com>, Alistair Popple <apopple@...dia.com>,
 linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
 nouveau@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
 Shirish Baskaran <sbaskaran@...dia.com>
Subject: Re: [PATCH v4 16/20] nova-core: Add support for VBIOS ucode
 extraction for boot



On 6/5/2025 12:21 PM, Danilo Krummrich wrote:
> On Thu, Jun 05, 2025 at 12:09:46PM -0400, Joel Fernandes wrote:
>>>> +impl PmuLookupTable {
>>>> +    fn new(pdev: &pci::Device, data: &[u8]) -> Result<Self> {
>>>> +        if data.len() < 4 {
>>>> +            return Err(EINVAL);
>>>> +        }
>>>> +
>>>> +        let header_len = data[1] as usize;
>>>> +        let entry_len = data[2] as usize;
>>>> +        let entry_count = data[3] as usize;
>>>> +
>>>> +        let required_bytes = header_len + (entry_count * entry_len);
>>>> +
>>>> +        if data.len() < required_bytes {
>>>> +            dev_err!(
>>>> +                pdev.as_ref(),
>>>> +                "PmuLookupTable data length less than required\n"
>>>> +            );
>>>> +            return Err(EINVAL);
>>>> +        }
>>>> +
>>>> +        // Create a copy of only the table data
>>>> +        let table_data = {
>>>> +            let mut ret = KVec::new();
>>>> +            ret.extend_from_slice(&data[header_len..required_bytes], GFP_KERNEL)?;
>>>> +            ret
>>>> +        };
>>>> +
>>>> +        // Debug logging of entries (dumps the table data to dmesg)
>>>> +        if cfg!(debug_assertions) {
>>>> +            for i in (header_len..required_bytes).step_by(entry_len) {
>>>> +                dev_dbg!(
>>>> +                    pdev.as_ref(),
>>>> +                    "PMU entry: {:02x?}\n",
>>>> +                    &data[i..][..entry_len]
>>>> +                );
>>>> +            }
>>>> +        }
>>>
>>> Not sure this makes sense - debug_assertions is supposed to be about
>>> assertions, we probably shouldn't try to use it for other things (especially
>>> since we've already got dev_dbg! here)
>>
>> This was suggested by Danilo. I don't really feel strongly either way, IMO I am
>> also Ok with running it in production.
> 
> When I suggested this, the code looked like this:
> 
> 	// "last_entry_bytes" is a debugging aid.
> 	// let mut last_entry_bytes: Option<KVec<u8>> = Some(KVec::new());
> 	
> 	for &byte in &data[header_len..required_bytes] {
> 	    table_data.push(byte, GFP_KERNEL)?;
> 	    /*
> 	     * Uncomment for debugging (dumps the table data to dmesg):
> 	     * last_entry_bytes.as_mut().ok_or(EINVAL)?.push(byte, GFP_KERNEL)?;
> 	     *
> 	     * let last_entry_bytes_len = last_entry_bytes.as_ref().ok_or(EINVAL)?.len();
> 	     * if last_entry_bytes_len == entry_len {
> 	     *     pr_info!("Last entry bytes: {:02x?}\n", &last_entry_bytes.as_ref().ok_or(EINVAL)?[..]);
> 	     *     last_entry_bytes = Some(KVec::new());
> 	     * }
> 	     */
> 	}
> 
> Now the compiler probably optimizes the loop away, since dev_dbg!() turns into a
> noop. So, now we can indeed probably remove it.

Makes sense, Ok then I'll drop the "if cfg!(debug_assertions)".

 - Joel


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ