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=1796134350; b=Q8IrzI6nmwvrePQqSF018MbGEDCG4EWjRDf6mCses2kCbafOYg81X3d/K8SJ1NVm56oY Uy2Oz9syTmqsg8euR1ZXPGU2qkSEVB3Az8tMAB6PXqUdZB4TSEY/QjK5PttV5myo/2/0c SVYpxsYs+7E09w2cj5fVAEAXih5QuqMQMJzPyR1E/USEQG7w/bl4FJBYJYYWVQxVkDWeo uFPvWAQIF/vS6I+Q8A0WkXEEGzp1P/loGvfvtIVNWiFt6Yo04Px9R0aS6+kM0sLe42+A7 HTW5nfYtKUQmo03lXGOxA6m2fwnQ/jRLnmciS6/nbTkU7dIaMFB9FNOMZXJuQOZJJTw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796134350; h=Received:DKIM-Signature:Mime-Version:Content-Transfer-Encoding: Content-Type:Date:Message-Id:Subject:Cc:To:From:References: In-Reply-To; bh=LUX4D2pZeqcT0SB1JYJypy9r9UAWqoJ5G795Bo8wt8o=; b=nzR2cw5q7vf4OEtE1mZZ0CorZbXLDfkQVHd2jNAacgSLRPWxncsJbnrQSdPjjiojX2gJ WinF7xkRLKGGXYUy4E0CnGesofJb1kWkJiDB8IIMQSuK/TqSFU3D5hjHmcyjdcHtw06O5 2gTMmJxL/g3Fl7N4rTnXbLr2qN7EaGCuflUb252UaR33DKLM5hwbY/4agLdEUc5bInMrN 0CSNbwDyqj31HTJ0paA8X55rBYOH47dZm7oOzKZ+wC/MF7yAa6ckb8A7Whp7PeM4mHbcZ fLTMUGIItRfn4rEnRpyXAxdb6U2rzrU/umI4Xs1FNshIjavAXZTxkAg/B/KC10rPdsg== 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=SnDWU7ZF; 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 AD501606A322; Tue, 1 Dec 2026 14:12:30 +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=SnDWU7ZF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A6401F0089B; Tue, 1 Dec 2026 14:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796134350; bh=LUX4D2pZeqcT0SB1JYJypy9r9UAWqoJ5G795Bo8wt8o=; h=Date:Subject:Cc:To:From:References:In-Reply-To; b=SnDWU7ZFjjn0+tqSIhAAT1KT99mHxvFkI2bJ88WY0YkqjZ2SrgaRby2KclGRG9yj2 Y3E9Ecvnz+domajZLyw8bl26fPyq6ID42NYauGY9I70D3dBuY1q3RMakPMfRQdRfI8 0zERrbn+ZDhZl5XFKNP7S7L3lXjJF/ZPEtJBmAaAuPvkU5Kj1Po1Cxhqm+3VVjlg6D QLV3ew//fudf4shiGrVJNFzfzhiY9y8isaRtlqpVuudoAUqu4ry6N4R0EJ1c96gdAH LUh//z4vF3suXw20498IgunpujKwOvLXbG4aJ/McJ/okvVejBaTndg3XvBdjlk45oY lcD26i/4RMDMA== X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 01 Dec 2026 15:12:26 +0100 Message-Id: Subject: Re: [PATCH v4 1/6] gpu: nova-core: gsp: add the r000 queue element header Cc: "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "John Hubbard" , "Alistair Popple" , "Timur Tabi" , "Eliot Courtney" , "Zhi Wang" , , , To: "Alexandre Courbot" From: "Danilo Krummrich" References: <20261201-nova-r000-staging-v4-0-de45770a47a1@nvidia.com> <20261201-nova-r000-staging-v4-1-de45770a47a1@nvidia.com> In-Reply-To: <20261201-nova-r000-staging-v4-1-de45770a47a1@nvidia.com> On Tue Dec 1, 2026 at 9:15 AM CET, Alexandre Courbot wrote: > + pub(crate) fn validate(&self) -> Result { > + if self.mctp_magic !=3D Self::MCTP_MAGIC > + || !self.mctp_header.has_expected_version() > + || !self.nvdm_header.has_nvidia_vendor() > + { > + return Err(EIO); > + } > + > + let element_len =3D self.element_len(); > + if element_len < size_of::() + self.message_len() > + || element_len > GSP_MSG_QUEUE_ELEMENT_SIZE_MAX > + { > + return Err(EIO); > + } > + > + Ok(()) > + } > +} [...] > - /// Validates this header against the expected NVIDIA NVDM format an= d type. > - pub(crate) fn validate(self, expected_type: NvdmType) -> bool { > + /// Returns `true` if this NVDM header belongs to a PCI vendor-defin= ed message from NVIDIA. > + /// > + /// The GPU firmware only ever sends such messages, so a mismatch is= a sign of corruption. > + pub(crate) fn has_nvidia_vendor(self) -> bool { > u8::from(self.msg_type()) =3D=3D MSG_TYPE_VENDOR_PCI > && u16::from(self.vendor_id()) =3D=3D Vendor::NVIDIA.as_raw(= ) > + } > + > + /// Validates this header against the expected NVIDIA NVDM format an= d type. > + pub(crate) fn validate(self, expected_type: NvdmType) -> bool { > + self.has_nvidia_vendor() > && matches!(self.nvdm_type(), Ok(nvdm_type) if nvdm_type =3D= =3D expected_type) > } > } NIT: I find has_nvidia_vendor() slighly confusing, as it reads as if it can legitimately return false. I think it should either be validate() and validate_type(), or define validate() as done by this patch and rename has_nvidia_vendor() to has_expected_vendor(), matching has_expected_version= ().