From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796180466; b=QZ1x++Ka5LGYi8i6Wma/4CTgSBdiBiwaUgHuRBNGyhFEKBpbro3t+2gQBdo+WtvdCzHR WHjeGKWg2/JPYCvbjKtQBPqbYB8nKdlHATJ0QDlXx1pbDzqnLBmRNdaX7xdYyTiLGjpPR MrtkbKvZ+f+8qiYq5Vwethkj/gALJbpAV3f8heTpyPxYZttzUs71IUvENILFa2esDMeTZ EFWQoR/ddAocl++fOYCAr5zz75JkQerXjqpzr8kBWoxNB32dw3gcn6F4/O31J5QE0EYjR Uiv9N0s6azplaSrtgfQ/5yPIsO/FsxVNlgACJrZd071svrFgZDUOju2koRJbv1R6IEQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796180466; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=nOQhYsOo8wtbNOOZLxrHJlq4bou5mLzC6rSvcb//5HA=; b=vBuvvIqVBLEXmByI4gSlB2LkmMhKQx0UUcyJ6xpwP4Bz8uBgoDbKBeMKI4VZlBJDjDyS 86he4nbIcdwv2sTznvx5m1/EbPadXy/LvcP0zgocq98Rz1A/OaRPEWvJfrgaJEynDHDLq 8c1sfOunT1v02zoX+0YMQOPRcdElnJdcyuBtWYerY7q7Y8jstJdGkXczQxok+E4ailUNE TU0SbAOaQsBe4YF5PUx5Zvc8j7GFwf81WBrdQ8zAIxxiRHSAhaLs1vtCheLUg5ykEC5uy 1YEf03+8WmMvH7Mbkv+2u/mwQTV9bTDt0saI+iEDtzQ8ZTiJHoLuJU5mXAhrEm9LpbQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hquQjH8E; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15EC8606A322 for ; Wed, 2 Dec 2026 03:01:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hquQjH8E Received: by smtp.kernel.org (Postfix) with ESMTPSA id 445841F00893; Wed, 2 Dec 2026 03:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796180465; bh=nOQhYsOo8wtbNOOZLxrHJlq4bou5mLzC6rSvcb//5HA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=hquQjH8EPwnvF80J5ZFnrAfXH60NsYHPebDCN4DlUAGXoMBxgfimYaZqmgjYJvlVZ rqpN5WA/OIWoIEP0jnODQv4fH5FX/8bOc3bOJ3hiVo/DA+4hZ9APi4gWass5N0Ry06 sZ5oFT6EZSQKfcApeCgZWxLt5dQhm1ypM+GqD0rV5myPm3DAwzfXB3ILcMfDvLQFBt AoB90HV/wO3cX8QwKcBwdWCnTJU36Vv8An2GzO8USjUdlbxEhgbEVUQ02fcXA7jpdW cvcDdn0JXqVvZJ6NS5wxL6J9gmnWfoRDuRA/5vYi4ZTynr5Q/WeIjqqFsX9a0KSbGl tLqARA+DkOfAQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v2] gpu: nova-core: gsp: add RM alloc/control/free RPCs and client/device API Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?QWd1c3TDrW4gUGVyZWlyYQ==?= , "Danilo Krummrich" , "Alexandre Courbot" Cc: "David Airlie" , "Simona Vetter" , "Miguel Ojeda" , nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, gary@garyguo.net In-Reply-To: <20261202025028.43497-2-agustin.pereira.ro@gmail.com> References: <20261202025028.43497-1-agustin.pereira.ro@gmail.com> <20261202025028.43497-2-agustin.pereira.ro@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 03:01:04 +0000 X-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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=C3=ADn Pereira 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 type= d parameters `P`. > + #[expect(dead_code)] > + pub(crate) fn alloc_object( > + &self, > + parent: RmHandle, > + object: RmHandle, > + class: u32, > + params: &P, > + ) -> Result> { > + 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 =3D [0u8; size_of::()]; > + 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 =3D GspRmControlHeader::from_bytes(&err_hdr_bytes).o= k_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() =3D=3D 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 in place avoids depending on stack alignment. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202025028.4349= 7-2-agustin.pereira.ro@gmail.com?part=3D1