From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.194.11 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796006839; b=1Ab3FsXRuDi4BrCyhWfHD8ELViVax8FUXBxRFXLqKjcSqVgSQMSxi5+B8rc7tO2nT0Du Lsnx9V/6qvH9CM83tpVsf2zXn6lwYmRIkJ4Brz6hOoVby07UB76T4ayQ/zq8kIIQENtQg Kf3IdDA4X/2pMWtw8LXpXqt2uYYuu3yfHe/LtbIUxfbik7jFpbJJlMlBevMbWaVWACS2h qI00DGQR86IDZDCG0zc6F+YXVpnTteuqRrB+wtTQ+A9gZA+FfP20QQt7hFEkLEHN7jAyn Fmhr4zYQ+LP4pH8lixFXhnSjcx0AblHIGx/0P3J2UQ8LXxmYOE6FbDGv6fYrAt56/BA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796006839; h=DMARC-Filter:DKIM-Signature:Received:Received: Content-Transfer-Encoding:Content-Type:Date:Message-Id:Cc:Subject: From:To:X-Mailer:References:In-Reply-To:X-ClientProxiedBy: MIME-Version:X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0: X-MS-Exchange-AntiSpam-MessageData-1:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=HW3uB40SZtrFoECgr8URVoyd6bFo4ldlsX1gaZbzmB0=; b=4vRr55wNRiTQf5HcjDVIJ5TxjS9XBQ/liwBordeDMCzYLpmL8NMb9fbCZ3dixJKdq1JB q2I7I0ds+4IqT3DWjbnJvYRMY5dO1Y/bAmUainwHLe1oSO/BZgdJ4FS1asaYSczafs9jh uN+a53G/YIek6Sl1PyJCAAvHO/iMxdwxElgIDR7GfJ3u+NWPIm1SXak7qvKvu7qxungWx E9CKRLcFAJbNZ75OCWK+WSn+x8Nozi+qq4AvOR+tzRQoSsdrS8IiybIGkZlFcozTsTfnW t8v2p5yzY5Wc9xx8St00ZyRTfEKDArnk4U1tBfvPlu706R4FcspvyhY4unfU66HRy8g== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b="mTnph/e4"; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.194.11 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011011.outbound.protection.outlook.com [40.93.194.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6047606A31C for ; Mon, 30 Nov 2026 02:47:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D6047606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=mTnph/e4 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PLEi6AWxCD7yKh87Gh/w9W6rXJ0Gda3vp/r3wk5F4ewPlCfBVo0N9K23fwdF6NVhpfG/s96fGKdxAyyhovo2RxgxauYjL78o7oEOrpAIrJHiEMHE/zCMZXD+fdKxZUvnHDr3dB2ydrJVqUeN9cFMgnXlJMDrr88wOi7P4zfZL++Vzabj00LBa9bltPbYdp3RiW24ndW148D6hutzeMqgdUDDmn3my8yDIG2L+uT7vytx6mW8Ltrz3PA4L7PikKwOqUBGS2eUIiEePUJnNggtEkZqr8T05axVIMLI0rU0p+RGHda0ef3ywg01BQItPGHQCMC8D650HsJ1PIiUS8S9Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HW3uB40SZtrFoECgr8URVoyd6bFo4ldlsX1gaZbzmB0=; b=w8mBM+Ft4dUOjgGj9Oc3psMCmU1rorQtZjwffRXGlkNlSX31CJW+Z/5DFegIjEVa69ZLU/UJW8hFOI24ZadThbzfwZbLwIPPQAyiVJ0BfqRAporI0niDKD0XrC/6cihzh5n9PNUFuzUOZMVHnKQ6goSJlNsPdT0LYvz2Dav7Hgta3DjktTrXB8gJrUqU11LB04L9oym/SI/d+yOmXrUD187QGADj3eiEFt5LAvyIwU3PSHQE4ksyIi/T9J6LBv8nxSwwMPa6qGkc9dY8DtYktNHzwxn3KMmSA2D+L9/VijSPsLsF9KRjFTVENcOHXKiiqleI3beKltoNXQA8IUbAnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HW3uB40SZtrFoECgr8URVoyd6bFo4ldlsX1gaZbzmB0=; b=mTnph/e4pNHZWMeWRCwPcGGsSABpLgyizkqrzkz/6zzAv00/fCvvzmkwgpWlTr8R8DATa3FHBWps4EAGp/FD5JQFcf/K6Y9QGPZZ/9zk9cN+JXXlVN8SVsrYGb480I+Ako1+Z0AQW6D2ZCIghUpECxnAwbNgWc+gH7ylY8FehkzxTQTaQN4sfUuamEzDml+2NPIBgH//xJMguBVtDH9hMqEaCykaEMQE+UqlyiJhjGNhUxD3//eq55AK+isCsSQ5OcX/Ddlphgt+AoAQ90syoOEsPbk6Qq02i8ZhEj3sV0HXxdXwiocq8Lo8wjIRUiW40DPpEwOIOmm7ZmExFdw+yg== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB6413.namprd12.prod.outlook.com (2603:10b6:8:ce::10) by BL3PR12MB6641.namprd12.prod.outlook.com (2603:10b6:208:38d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Mon, 30 Nov 2026 02:47:15 +0000 Received: from DS0PR12MB6413.namprd12.prod.outlook.com ([fe80::e82a:6673:4142:37fa]) by DS0PR12MB6413.namprd12.prod.outlook.com ([fe80::e82a:6673:4142:37fa%5]) with mapi id 15.21.0662.007; Mon, 30 Nov 2026 02:47:15 +0000 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 30 Nov 2026 11:47:11 +0900 Message-Id: Cc: "John Hubbard" , "Alistair Popple" , "Timur Tabi" , "Eliot Courtney" , "Zhi Wang" , , , , "dri-devel" Subject: Re: [PATCH v2 01/11] gpu: nova-core: gsp: add the r000 queue element header From: "Eliot Courtney" To: "Alexandre Courbot" , "Danilo Krummrich" , "Alice Ryhl" , "David Airlie" , "Simona Vetter" X-Mailer: aerc 0.22.0-0-gc2f86b7abde3 References: <20261130-nova-r000-staging-v2-0-afd079026a61@nvidia.com> <20261130-nova-r000-staging-v2-1-afd079026a61@nvidia.com> In-Reply-To: <20261130-nova-r000-staging-v2-1-afd079026a61@nvidia.com> X-ClientProxiedBy: TY4P286CA0123.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:37c::13) To DS0PR12MB6413.namprd12.prod.outlook.com (2603:10b6:8:ce::10) 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 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB6413:EE_|BL3PR12MB6641:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b0b0027-ed20-4a68-59b9-08df4e8c3dc9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|376014|1800799024|23010399003|366016|11063799006|4143699003|261009220027099003|261009223327099003|261009223027099003|261009221727099003|261009221227099003|18002099003|22082099003|3023799007|56012099006|10067099003|261102123227099003|261026140227099003|261021123027099003|261021121427099003|261028144727099003|261026121527099003|261022115727099003|261022105027099003; X-Microsoft-Antispam-Message-Info: tm0BwUdZ8UEj9M/C8SqFiBJ/yZ9raUtxuGhHwtUhqA7wWv6aiDoH5HMyEx0Khtz6JfzLthadWv1detXiNT+p5m+Tjj2ae9RfjVAiRVnLbu6xXxZevqCOqP8JdB75+i+SepTM+lZt0S87U/FQTwW955pr5e27zeFUWRZ3+kPwUsiIyQR61gnm55UhK+yHcH73GqfRz4Rjyn1BG/Asxar+rO6AJ3O/ggNyjtr0FZmQZYq7QqPM/lkqywjvZI3X8rEnbvZXPQPxRZCumP8ynAAZC3drAW3wm44cUJy9XYpR7jKLA5oXIEDIi4KToshWwpoXhMROQGQehyaBMu9E5GJLmgR4nqi536pa3Hb2WBPNZKpGnPVfhMk1PTkquDmYcroLkyu/ybnrnBelBsemEsBDoTWJpCvkdaKX0ZPUdq8UKH7MHsfJG4w8NSmxa9cxCw8em/M4soBpJ3Z1Wa7IMeIagKSZSXhqE99aG/79rllGceRVNa9tFNaF+Uy5laqEHJtT2MJZQZR3OpeWIsGWl+4pnFK29YG6c1fzjAS6bPeS+GNsUkCzJNaOjpr023ngFPWvZHk6lVRyY+2f7NMtF7ArZnlWXbvPvAj4sG5KMHOjtRBWa3QDhLLsCMcYxBcFsPHluZFQ26Oku2Ij6x5XefM3GQM9T/AVyq9lZTBNRw6nGQM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB6413.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(376014)(1800799024)(23010399003)(366016)(11063799006)(4143699003)(261009220027099003)(261009223327099003)(261009223027099003)(261009221727099003)(261009221227099003)(18002099003)(22082099003)(3023799007)(56012099006)(10067099003)(261102123227099003)(261026140227099003)(261021123027099003)(261021121427099003)(261028144727099003)(261026121527099003)(261022115727099003)(261022105027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Qk40MHo2M2ppNll6WE9VdkZydVluWWtSSHJlTVVxY29ma3o5UTJmTU91T0hx?= =?utf-8?B?bmVaU01VclVBN1h4RE0rZTFDZmJGbVkwTVIvTlp6NThvRTBTM0pMY0s0cEIx?= =?utf-8?B?MFZSeXk4L2tVU2h6RTUvWU1XTEduZTE5dERZOFVsdDNnK3FLN3ZrWUVPT1Bi?= =?utf-8?B?QUNjTjNVVU5kUUR6eVg3WWRONFYyN2lzVDVzMHdNeVdnd1QvdjNwM0ZWRStO?= =?utf-8?B?S1hRek5WV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JjSHk2bEVNWUlV?= =?utf-8?B?OVlsdWlmZlQ1OGpYYVlsZ1JGdWV0a2kwRUJCZlpNR05ua1hhbzlIQTFkeXln?= =?utf-8?B?MFptMTVNVVlNc1l1WTBlWThKT3ZmU3B6eWtJR3lDT0dEaVU2RFVqVjA1akhy?= =?utf-8?B?dEUzNmNPYXlLN2lzT1RvVDdCblhNUlJvaW5xK2c2ZDU5bkRjSmhMbHpEMGtH?= =?utf-8?B?MEdOMUNJUW1MTHBqdXZwQUxQME5oSFBCTkZwQ2Z2aWJTeDQ5QmRrS2x4RmM4?= =?utf-8?B?NkJDYVF2bG10SkNqQjVaZXhLemlmeWMzcnF0Y2FCeUsrbE9ySnY0Y0FPT1Fs?= =?utf-8?Q?kcPAdVCgj4sowtdTw3e3Ots2K4ZURR2qo95Qa8mO0Ogz3?= X-MS-Exchange-AntiSpam-MessageData-1: dRY5DYr/fXcNkw== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b0b0027-ed20-4a68-59b9-08df4e8c3dc9 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB6413.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 02:47:15.1903 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZGp7A6QLnzRvImANzwFzGYaQnyDrRFWjXw29UUOVZ0Yxsw65MvGkAPzo7d9A1ZtECRgmeDkZE9TpOzmJMZr+Rw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6641 On Mon Nov 30, 2026 at 12:11 AM JST, Alexandre Courbot wrote: > From: John Hubbard > > The upcoming r000 firmware uses a new queue element header that includes > MCTP and NVDM headers describing the type of message (RPC or GMC) that > follows. > > Add that header as the `QueueElementHeader` type, along with the two > NVDM types that the GSP queues use and the MCTP version and NVDM vendor > checks that validating it requires. > > The type is written out field by field rather than wrapped around the > generated binding, as `GSP_MSG_QUEUE_ELEMENT` keeps a 16-byte encryption > tag, only used with confidential computing, in a union with its last two > fields, making the binding 16 bytes larger than what the GSP expects on > the queues. Static assertions check every field offset and the size of > the type against the binding. > > The header has no user yet: it replaces `GspMsgElement` at the transport > level in a later patch that switches to the r000 firmware, and is built > as dead code until then. > > Signed-off-by: John Hubbard > Co-developed-by: Alexandre Courbot > Signed-off-by: Alexandre Courbot > --- > drivers/gpu/nova-core/gsp/fw.rs | 183 +++++++++++++++++= +++++- > drivers/gpu/nova-core/gsp/fw/r000_00/bindings.rs | 97 ++++++++++++ > drivers/gpu/nova-core/mctp.rs | 27 +++- > 3 files changed, 304 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/= fw.rs > index 5c216d777dff..937cbbc24e93 100644 > --- a/drivers/gpu/nova-core/gsp/fw.rs > +++ b/drivers/gpu/nova-core/gsp/fw.rs > @@ -33,6 +33,11 @@ > }, > }; > =20 > +use zerocopy_derive::{ > + Immutable, > + KnownLayout, // > +}; > + > use crate::{ > bounded_enum, > fb::{ > @@ -48,6 +53,11 @@ > cmdq::Cmdq, // > GSP_PAGE_SIZE, > }, > + mctp::{ > + MctpHeader, > + NvdmHeader, > + NvdmType, // > + }, > num::{ > self, > FromSafeCast, // > @@ -835,7 +845,7 @@ pub(crate) fn msg_length(&self) -> usize { > size_of::() + self.rpc_header().rpc_length() > } > =20 > - /// Returns the number of elements (i.e. memory pages) used by this = message. > + /// Returns the number of slots (i.e. memory pages) used by this mes= sage. > pub(crate) fn element_count(&self) -> u32 { > self.inner.elemCount > } > @@ -901,6 +911,177 @@ pub(crate) fn function(&self) -> Result { > } > } > =20 > +/// First word of every r000 queue element: `"MCTP"` in ASCII. > +const MCTP_MAGIC: u32 =3D 0x4D43_5450; nit: make this a const of impl QueueElementHeader? > + > +/// Header opening every element of the r000 GSP queues. > +/// > +/// A queue element is laid out as follows: > +/// > +/// ```text > +/// +------------------------------------+ > +/// | Queue element header | QueueElementHeader: MCTP= magic, element length, > +/// | | MCTP header, NVDM header= , message length. > +/// +------------------------------------+ > +/// | Message header | RPC header or GMC API he= ader. The NVDM type > +/// | | selects between the two. > +/// +------------------------------------+ > +/// | Payload | Message-specific data. > +/// +------------------------------------+ > +/// ``` > +/// > +/// This is the `noEncryption` layout of the `GSP_MSG_QUEUE_ELEMENT` bin= ding. That binding keeps > +/// a 16-byte encryption tag, used only with confidential computing, in = a union with the two > +/// trailing fields of the queue element header, so wrapping the binding= would make every element > +/// 16 bytes larger than what the GSP expects. The fields are therefore = declared again here, with > +/// their offsets checked against the binding. > +#[repr(C)] > +#[derive(FromBytes, IntoBytes, Immutable, KnownLayout)] > +pub(crate) struct QueueElementHeader { > + /// Always [`MCTP_MAGIC`]. > + mctp_magic: u32, > + /// Length in bytes of the whole element, this header included. > + /// > + /// Under confidential computing the GSP pads elements out to whole = queue slots, so this can > + /// be larger than `nvdm_payload_size` plus the size of this header,= but never smaller. > + mctp_payload_size: u32, > + /// MCTP transport header of the element. > + mctp_header: MctpHeader, > + /// NVDM header of the message. > + nvdm_header: NvdmHeader, > + /// Length in bytes of the message following this header: the messag= e header and its > + /// payload. > + nvdm_payload_size: u32, > + reserved: u32, > +} > + > +// Static validation of `QueueElementHeader` against its bindings type. > +const _: () =3D { > + use core::mem::offset_of; > + > + // Offsets of `QueueElementHeader`'s fields > + > + static_assert!( > + offset_of!(QueueElementHeader, mctp_magic) > + =3D=3D offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpMagic) > + ); > + static_assert!( > + offset_of!(QueueElementHeader, mctp_payload_size) > + =3D=3D offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpPayloa= dSize) > + ); > + static_assert!( > + offset_of!(QueueElementHeader, mctp_header) > + =3D=3D offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, mctpHeader= ) > + ); > + static_assert!( > + offset_of!(QueueElementHeader, nvdm_header) > + =3D=3D offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, nvdmHeader= ) > + ); > + > + /// The `noEncryption` member of the union of `GSP_MSG_QUEUE_ELEMENT= `, which holds the two > + /// trailing fields of [`QueueElementHeader`]. > + // Using `allow` instead of `expect` as rustc 1.85 ignores uses from= `static_assert!` and > + // reports this as dead code. > + #[allow(dead_code)] > + type QueueElementNoEncryption =3D r000_00::GSP_MSG_QUEUE_ELEMENT__bi= ndgen_ty_1__bindgen_ty_2; > + > + // Offsets of fields under [`QueueElementNoEncryption`] within `GSP_= MSG_QUEUE_ELEMENT`. > + > + // Using `allow` instead of `expect` as rustc 1.85 ignores uses from= `static_assert!` and > + // reports this as dead code. > + #[allow(dead_code)] we aren't using static_assert! in this version anymore so i think these dead_codes can go > + const QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET: usize =3D > + offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT, __bindgen_anon_1) > + + offset_of!(r000_00::GSP_MSG_QUEUE_ELEMENT__bindgen_ty_1, n= oEncryption); > + > + static_assert!( > + offset_of!(QueueElementHeader, nvdm_payload_size) > + =3D=3D QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET > + + offset_of!(QueueElementNoEncryption, nvdmPayloadSize) > + ); > + static_assert!( > + offset_of!(QueueElementHeader, reserved) > + =3D=3D QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET + offset_of!(Queue= ElementNoEncryption, reserved) > + ); > + > + // Ensure the size of `QueueElementHeader` matches the `noEncryption= ` layout. > + > + static_assert!( > + size_of::() > + =3D=3D QUEUE_ELEMENT_NO_ENCRYPTION_OFFSET + size_of::() > + ); > +}; > + > +#[expect(dead_code)] > +impl QueueElementHeader { > + /// Creates the queue element header of an element carrying a messag= e of NVDM type `nvdm_type` > + /// and `message_len` bytes, message header included. > + /// > + /// # Errors > + /// > + /// - `EOVERFLOW` if a length does not fit its 32-bit field. > + pub(crate) fn init(nvdm_type: NvdmType, message_len: usize) -> impl = Init { > + try_init!(QueueElementHeader { > + mctp_magic: MCTP_MAGIC, > + mctp_payload_size: size_of::() > + .checked_add(message_len) > + .ok_or(EOVERFLOW)? > + .try_into() > + .map_err(|_| EOVERFLOW)?, > + mctp_header: MctpHeader::single_packet(), > + nvdm_header: NvdmHeader::new(nvdm_type), > + nvdm_payload_size: message_len.try_into().map_err(|_| EOVERF= LOW)?, > + reserved: 0, > + }) > + } > + > + /// Returns the length of the whole element, this header included. > + pub(crate) fn element_len(&self) -> usize { > + num::u32_as_usize(self.mctp_payload_size) > + } > + > + /// Returns the length of the message following this header, message= header included. > + pub(crate) fn message_len(&self) -> usize { > + num::u32_as_usize(self.nvdm_payload_size) > + } > + > + /// Returns the number of slots (i.e. memory pages) used by this ele= ment. > + pub(crate) fn element_count(&self) -> u32 { > + self.mctp_payload_size.div_ceil(cv!(GSP_PAGE_SIZE)) > + } > + > + /// Returns the NVDM type of the message following this header, or `= EINVAL` if it is not a > + /// known one. > + pub(crate) fn nvdm_type(&self) -> Result { > + self.nvdm_header.nvdm_type() > + } > + > + /// Validates the framing of the element. > + /// > + /// # Errors > + /// > + /// - `EIO` if the magic, the MCTP version or the NVDM vendor is wro= ng, or if the element > + /// length is smaller than this header and the message together, o= r larger than the > + /// maximum element size. > + pub(crate) fn validate(&self) -> Result { > + if self.mctp_magic !=3D 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::().saturating_add(self.message_l= en()) optional nit: it's fairly obvious that this add can never saturate so it reads noisily to me > + || element_len > GSP_MSG_QUEUE_ELEMENT_SIZE_MAX > + { > + return Err(EIO); > + } > + > + Ok(()) > + } > +} > + > bounded_enum! { > /// Commands of the GMC API. > #[derive(Debug, Clone, Copy, PartialEq, Eq)] [...] > diff --git a/drivers/gpu/nova-core/mctp.rs b/drivers/gpu/nova-core/mctp.r= s > index f62e79f56b05..2058303dfbb9 100644 > --- a/drivers/gpu/nova-core/mctp.rs > +++ b/drivers/gpu/nova-core/mctp.rs > @@ -13,6 +13,11 @@ > prelude::*, // > }; > =20 > +use zerocopy_derive::{ > + Immutable, > + KnownLayout, // > +}; > + > use crate::{ > bounded_enum, > num, // > @@ -28,11 +33,16 @@ pub(crate) enum NvdmType with TryFrom= > { > Cot =3D 0x14, > /// FSP command response. > FspResponse =3D 0x15, > + /// RPC message to or from GSP-RM. > + RmRpc =3D 0x25, > + /// GMC (GPU Management Controller) API message to or from GSP-R= M. > + GmcApi =3D 0x26, > } > } > =20 > bitfield! { > /// MCTP transport header for NVIDIA firmware messages. > + #[derive(FromBytes, IntoBytes, Immutable, KnownLayout)] > pub(crate) struct MctpHeader(u32) { > /// Start-of-message bit. > 31:31 som; > @@ -67,6 +77,11 @@ pub(crate) fn single_packet() -> Self { > pub(crate) fn is_single_packet(self) -> bool { > self.som().into_bool() && self.eom().into_bool() > } > + > + /// Returns `true` if this MCTP header carries the version that this= driver uses. > + pub(crate) fn has_expected_version(self) -> bool { > + u32::from(self.version()) =3D=3D Self::VERSION nit: unnecessary u32::from? Reviewed-by: Eliot Courtney