From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Thorsten Blum" <blum@kernel.org>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>, "Gary Guo" <gary@garyguo.net>,
"Timur Tabi" <ttabi@nvidia.com>,
"Eliot Courtney" <ecourtney@nvidia.com>,
"Tim Kovalenko" <tim.kovalenko@proton.me>,
<nova-gpu@lists.linux.dev>, <dri-devel@lists.freedesktop.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] gpu: nova-core: firmware: fwsec: use zeroed() to zero-pad buffers
Date: Thu, 08 Oct 2026 00:29:15 +0900 [thread overview]
Message-ID: <DLYPOE6YLNWU.2PDPIJN9TDEGD@nvidia.com> (raw)
In-Reply-To: <20261007080708.124563-2-blum@kernel.org>
On Wed Oct 7, 2026 at 5:07 PM JST, Thorsten Blum wrote:
> Use KVec::zeroed() to allocate the zero-padded microcode buffer and copy
> the bootloader code into it. Also use KVVec::zeroed() to initialize the
> firmware object's leading zero padding.
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
> Changes in v2:
> - Add a // PANIC comment to copy_from_slice() (Danilo)
> - v1: https://lore.kernel.org/r/20261006100442.80432-3-blum@kernel.org/
> ---
> drivers/gpu/nova-core/firmware/fwsec/bootloader.rs | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
> index ec4d92317a93..1aa08ae8de78 100644
> --- a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
> +++ b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
> @@ -137,10 +137,9 @@ pub(crate) fn new(
> .align_up(Alignment::new::<{ falcon::MEM_BLOCK_ALIGNMENT }>())
> .ok_or(EINVAL)?;
>
> - let mut ucode = KVec::with_capacity(aligned_code_size, GFP_KERNEL)?;
> - ucode.extend_from_slice(code, GFP_KERNEL)?;
> - ucode.resize(aligned_code_size, 0, GFP_KERNEL)?;
> -
> + let mut ucode = KVec::zeroed(aligned_code_size, GFP_KERNEL)?;
> + // PANIC: ucode is sliced to code.len(); code.len() <= aligned_code_size.
> + ucode[..code.len()].copy_from_slice(code);
As I mentioned on the previous revision, I think not inserting panic
sites should take priority over other considerations. Besides this code
effectively writes he `code` area twice (not that this is a big
concern).
I guess if we want to introduce a new `Vec` API to cover this better, it
should be some kind of constructor cloning a slice - `from_slice` maybe?
> ucode
> };
>
> @@ -162,8 +161,7 @@ pub(crate) fn new(
> .ok_or(EOVERFLOW)?
> };
>
> - let mut firmware_obj = KVVec::new();
> - firmware_obj.extend_with(align_padding, 0u8, GFP_KERNEL)?;
> + let mut firmware_obj = KVVec::zeroed(align_padding, GFP_KERNEL)?;
This hunk is fine though.
prev parent reply other threads:[~2026-10-07 15:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 8:07 Thorsten Blum
2026-10-07 15:29 ` Alexandre Courbot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DLYPOE6YLNWU.2PDPIJN9TDEGD@nvidia.com \
--to=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=blum@kernel.org \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=simona@ffwll.ch \
--cc=tim.kovalenko@proton.me \
--cc=ttabi@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®