From: sashiko-bot@kernel.org
To: "Agustín Pereira" <agustin.pereira.ro@gmail.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>
Cc: "David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Miguel Ojeda" <ojeda@kernel.org>,
nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
gary@garyguo.net
Subject: Re: [RFC PATCH v2] gpu: nova-core: gsp: add RM alloc/control/free RPCs and client/device API
Date: Wed, 02 Dec 2026 03:01:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-244740@kernel.org> (raw)
In-Reply-To: <20261202025028.43497-2-agustin.pereira.ro@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] gpu: nova-core: gsp: alloc_object() does not tie RmObject to
parent lifetime
- [Low] gpu: nova-core: gsp: unaligned buffer in
rm_control_roundtrip_and_error()
--
commit 3fa3eea017ee1413da688a66f0c79d30aaad55dc
Author: Agustín Pereira <agustin.pereira.ro@gmail.com>
gpu: nova-core: gsp: add RM alloc/control/free RPCs and client/device API
This commit implements the GSP-RM object allocation, control, and free RPC
commands along with RAII handle wrappers for RM clients, devices,
subdevices, and child objects.
> diff --git a/drivers/gpu/nova-core/gsp/rm.rs b/drivers/gpu/nova-core/gsp/rm.rs
> new file mode 100644
> index 0000000000000..29bddfb699de8
> --- /dev/null
> +++ b/drivers/gpu/nova-core/gsp/rm.rs
> @@ -0,0 +1,640 @@
[ ... ]
> + /// Allocates an arbitrary RM child object under `parent` using typed parameters `P`.
> + #[expect(dead_code)]
> + pub(crate) fn alloc_object<P: AsBytes + FromBytes>(
> + &self,
> + parent: RmHandle,
> + object: RmHandle,
> + class: u32,
> + params: &P,
> + ) -> Result<RmObject<'_, 'gsp>> {
> + self.cmdq.send_command(RmAlloc::new(
> + self.handle.raw(),
> + parent.raw(),
> + object.raw(),
> + class,
> + params,
> + ))?;
> +
> + Ok(RmObject {
> + cmdq: self.cmdq,
> + client_handle: self.handle,
> + handle: object,
> + })
> + }
[Severity: Low]
Can an RmObject returned by RmClient::alloc_object() outlive its parent
RmDevice, RmSubdevice, or RmObject?
Unlike RmClient::alloc_device() and RmDevice::alloc_subdevice(),
alloc_object() takes parent by value as a Copy RmHandle and ties the
returned RmObject's lifetime only to &self (the RmClient). If the parent
object is dropped first, GSP-RM frees the child in its resource database,
and later RmObject::control() or Drop::drop() calls on the surviving
RmObject will operate on an already-freed handle.
[ ... ]
> + // Simulate a non-zero NV_STATUS error in reply header (`NV_ERR_NO_MEMORY`).
> + let mut err_hdr_bytes = [0u8; size_of::<GspRmControlHeader>()];
> + err_hdr_bytes.copy_from_slice(hdr.as_bytes());
> + // `status` is the 4th `u32` field (byte offset 12) in `rpc_gsp_rm_control_v03_00`.
> + err_hdr_bytes[12..16].copy_from_slice(&0x51u32.to_le_bytes());
> + let err_hdr = GspRmControlHeader::from_bytes(&err_hdr_bytes).ok_or(EIO)?;
[Severity: Low]
Can GspRmControlHeader::from_bytes(&err_hdr_bytes) fail spuriously with EIO
when err_hdr_bytes is not 4-byte aligned on the stack?
err_hdr_bytes is a [u8; 24] array with 1-byte alignment, whereas
GspRmControlHeader requires 4-byte alignment and FromBytes::from_bytes()
returns None when slice_ptr.is_aligned() is false:
rust/kernel/transmute.rs:FromBytes::from_bytes() {
...
if bytes.len() == size && slice_ptr.is_aligned() {
// SAFETY: Size and alignment were just checked.
unsafe { Some(&*slice_ptr) }
} else {
None
}
}
Using GspRmControlHeader::from_bytes_copy(&err_hdr_bytes) or mutating the
aligned KBox<GspRmControlHeader> in place avoids depending on stack
alignment.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202025028.43497-2-agustin.pereira.ro@gmail.com?part=1
next prev parent reply other threads:[~2026-12-02 3:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 2:50 [RFC PATCH v2] gpu: nova-core: gsp: retain debugfs logs on teardown and capture logpmu Agustín Pereira
2026-12-02 2:50 ` [RFC PATCH v2] gpu: nova-core: gsp: add RM alloc/control/free RPCs and client/device API Agustín Pereira
2026-12-02 3:01 ` sashiko-bot [this message]
2026-12-02 3:05 ` [RFC PATCH v2] gpu: nova-core: gsp: retain debugfs logs on teardown and capture logpmu sashiko-bot
2026-12-02 3:37 ` John Hubbard
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=sashiko-outbox-244740@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acourbot@nvidia.com \
--cc=agustin.pereira.ro@gmail.com \
--cc=airlied@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=simona@ffwll.ch \
/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