From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3B8C606A31A for ; Tue, 1 Dec 2026 14:12:43 +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: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4080C10E302; Tue, 1 Dec 2026 14:12:38 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id B38FA10E40E for ; Tue, 1 Dec 2026 14:12:31 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id AC11662583; Tue, 1 Dec 2026 14:12:30 +0000 (UTC) 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-Archived-By: 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> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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= ().