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.195.14 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795964439; b=y3OwbA0/dT5puX7x5azXRLSwgQHI82tkUgLQdqHKtkjfxgsy5IkcoqJkIQdKTReLaq3q +7w2uekdUbcA3sBUNQ8fpsSiZEXnKHjFCJNPOqdM0fi21jUQnxBJM+j9lqTC1tR0kLGp1 aO52Y5hLgtf60mJHo+WfnuY8psm5CD4BcLlgBx2dqdMMCVbP+PtgXF4PVydzglBzeNzlo ryUK/Thjxe31lSF/T/FWwJsWWIOYHzKZtdV2vDNC3o/+sWvbhSDjAL/OCaFHCpdxhEnIg BdWOq0wiVdYhsMtSbwnVHgjWVlD4pwDivgEPOTRboh5Rt0OFw4oKdB3zlRkgc61o9lA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795964439; h=DMARC-Filter:DKIM-Signature:Received:Received: Content-Transfer-Encoding:Content-Type:Date:Message-Id:Subject:From: To:Cc: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=tNCJbQ1YUm4mRsJyfpAswyXqMXVefVXcAZ4KBJlo1jg=; b=fHAFB+WjtU6O9SvhQoPftVnvJa8dpULuwT/grHiAo2UEegenx1vdcWTfm9gfgup181kj TUinKR3ZmX+EBSomchtRM7FoPLw9a/N89DBQlcUphzLq3yGDr9iVv1786bQjo9i0CpLUy 5lGuHAorFY7WBbPe9WcEV6S9djQHS/zk7OGpprj6YYry/CsfRgrfYdsICXhcNAdyENEvx NVNdvBBk0PIEGffafJP/9f6+3VWeCx+8xiC5qSwB6IYw26TUg5y+b6nzsZ5zNoYC0sU01 ITtOnAg5MeMeyJ6nTD4be9U2BxM3E/WtHFC/X0gDoCdR9oZmeBhUPDXtkFtyxmr8NQw== 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=Ky+qOnEf; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.195.14 Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11012014.outbound.protection.outlook.com [40.93.195.14]) (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 8563E606A325 for ; Sun, 29 Nov 2026 15:00:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8563E606A325 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=Ky+qOnEf ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EmB/G+zyXAqZteCAtirpVrU6MfzDGSLEkJW536A66IISANRxOFuZp4/UIBTsNx1f9k3m1EIpsTaCxZzvrGH+CogU6+m5fTZB8uK1Rcf8Y17lsvanOwUqV8He1bnTGNaf6FNvVDnQWPDI7mTFwc07F8S5NMNkMQvuMzMyYoR99N6+X7CCSfIdmlhhhFgR5n7Rt8CFrvMPOD0JtrYoeUzOan2EZe0M+jReZM6c0SdTjHo4JLV40i5cBKGs50QyMQsD5c0MVd5udmuhMXW60b1yzmu3Ys9qz52drNTX//4cgZnskhp/le9dDS9unqThAzmUgfNl/peBSmTTRoFLbQ94ug== 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=tNCJbQ1YUm4mRsJyfpAswyXqMXVefVXcAZ4KBJlo1jg=; b=eQyPNj7LBmNJmtNlLtjtxnrRrFV+1ah3xTH6uhW1FZMPORXDBqgAO3d4H+52Lo5hDRi8uZ6Xn+zsI6QWibICjDefnDd/kwUKqK8oZfEvsbQC2kc5iQPOoLeHtNJIgSAcRRfV6XxS2sq5mr6i7tAhz7KpyAxV51zRtshObvQgoNa0/xNMVvtA/LEE1UVIqouyVMYk4Piiw5e+hTlEvgHFaqwpGyhb2A1uWu9U9J0elohhA7O/NUVP/iSm//a05F3Nv9eP+kbrwZQARI0+WKmD2BstHE5xsL3gHteyqtyHxJe+jS/i9ieBVqnmTLR4WzKws3d5nZsArLy42I3OtURx7Q== 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=tNCJbQ1YUm4mRsJyfpAswyXqMXVefVXcAZ4KBJlo1jg=; b=Ky+qOnEfJfi6wnprT94+7n+kprsu4InEMPCyR4ZFlIP4VvYoJB8AT7sD3sJUVroarCm8EkEtZjWXsZh8bPck7ZkKkKQy9U0RLSixZkbhj0PJwvuT+A2QfGPL8GzYJtrW1MVZl+7HyodIhD7V5NZsE3uPfSYg9gSOWZhqCK9hXbPsI8bk8fkFSrQ6YNdaM50PNX71ZGBf/4hoYemUsHrPDAAVIjqEgjUmIyibF6/CzKJYfHcoRiANizf83+s8qiImKBUm2lqYFW11J0V5k39pCuVNZZFLcHOzEZkHVLm0FU/+Du5EKUb1FNg0sA3/YshAG0yXxxk3EWl7gjYYg5VEGQ== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MW4PR12MB6873.namprd12.prod.outlook.com (2603:10b6:303:20c::17) by LV1PR12MB999279.namprd12.prod.outlook.com (2603:10b6:408:3f7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.7; Sun, 29 Nov 2026 15:00:34 +0000 Received: from MW4PR12MB6873.namprd12.prod.outlook.com ([fe80::a338:bd2c:3a38:ece1]) by MW4PR12MB6873.namprd12.prod.outlook.com ([fe80::a338:bd2c:3a38:ece1%5]) with mapi id 15.21.0662.001; Sun, 29 Nov 2026 15:00:34 +0000 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 30 Nov 2026 00:00:31 +0900 Message-Id: Subject: Re: [PATCH 1/4] gpu: nova-core: gsp: add the r000 queue element header From: "Alexandre Courbot" To: "Gary Guo" Cc: "Danilo Krummrich" , "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "John Hubbard" , "Alistair Popple" , "Timur Tabi" , "Eliot Courtney" , "Zhi Wang" , , , References: <20261127-nova-r000-staging-v1-0-4eaf6e3c0942@nvidia.com> <20261127-nova-r000-staging-v1-1-4eaf6e3c0942@nvidia.com> In-Reply-To: X-ClientProxiedBy: TY6P286CA0025.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:3b9::6) To MW4PR12MB6873.namprd12.prod.outlook.com (2603:10b6:303:20c::17) X-Mailing-List: nova-gpu@lists.linux.dev 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: MW4PR12MB6873:EE_|LV1PR12MB999279:EE_ X-MS-Office365-Filtering-Correlation-Id: 128d2fbb-5ae1-400c-4023-08df4e298505 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|10070799003|376014|1800799024|23010399003|261022115727099003|56012099006|10067099003|261022105027099003|261026121527099003|261022075727099003|261028144727099003|261021121427099003|261026140227099003|261102123227099003|261009223027099003|18002099003|22082099003|11063799006|6133799003|4143699003; X-Microsoft-Antispam-Message-Info: u2MAYCDqu2DTDbOYZHREDICqskayMZJRJXfUl4+FBKeld/SXDH9kzs9Da1nqrZYg5KjsM44a3YmWA6OKork/D10ma1QVUgsyzruVwZFNCgPGYOEcQjCIrLj8ak17FP7p5MyzBI8lqJkPZglt5hQkgzjTXbin7RXd1CbWC6Z4dGqi1hfh74PRaYsZGWqz2deCwan0MqKn3sX9rMsYww/4yhLGd9fHU17GWHitKQULs9+/7NX5vdn8k0foHWlvNNCzlwg0eA1MchWpaiNtTAUGJ9Ga+enjWi1ZCtlnlvwUpuJpoeW98/rKdk6v+2bRBUJIARsQRFbcbZpoJGxKW52FsksLTcFc5YDaaDmac3CdUUzd3GS4PyDCtZsv5YRO8PIOYjJ5epFk2bIvtehR0ZjivrXmeotVKZl+ou4MizfAShxnHhhEflCsWVco8cCmG6EgNLuQOk7aPLmx7+8oVM/K9FqSrGiqDxnbPu5IQ0mebV+Q3dclUgp6mQR1ccTASJNEQLM0O/xV+h0oDHOAWtKyJWxRhyPfyWV9fPu/iAL82vKqu55TdmXniuhSx5/zCOc0yUwkQ4jVM14Fv6f8tc2nHDsElWATbT54vhP6l8mY6N5EbHHSTC8+/8BXoVqKaeSNT0ZwEfTV1leEVhwZYV9V4LMzRpEuBHT/ULjZRWwSnWg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR12MB6873.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(10070799003)(376014)(1800799024)(23010399003)(261022115727099003)(56012099006)(10067099003)(261022105027099003)(261026121527099003)(261022075727099003)(261028144727099003)(261021121427099003)(261026140227099003)(261102123227099003)(261009223027099003)(18002099003)(22082099003)(11063799006)(6133799003)(4143699003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TFlJUUJWTFZGT0NBU2MwMVZueFBRZXAzL1FDS1pSRDZJMXpqbTF0TnI5dFpz?= =?utf-8?B?YUhERy8xdHZCeEcrdklzdWxxcElmamkwUityb0hWWi9yUkc1Q09wMm1NamJC?= =?utf-8?B?VHZNVVdoOUlYVW9STW5veTd3YWNDZnlJbW9SMlNDYmRtUmQxQ2RSejJFT0pZ?= =?utf-8?B?UVFEalZBRG9OUElZRVdxcy9tWWJaajJVWkYrU20raXlQR1BsWStCTWQzb2J0?= =?utf-8?B?U1k1K0NBamhyc1k2STUvSDJIbkl6S1Q2ZStRa2hvTm1nMFJkTUZxaVpWNDJM?= =?utf-8?B?Vld5UDZkWWZLOHN6WXNXSTc3MmlST2dwZXppOHVaQ2hkSTZSaDczYmw3Ulpq?= =?utf-8?B?RXZ2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ZW91aC9yMzF5a3JUdUk0?= =?utf-8?B?QzVuaE5BMG00Ykl2eW1lRjNpc1A5QXJIUDZYUzJ2VUErbCtUdkxodUNVQWY4?= =?utf-8?B?NWFkRmowZWpZVWwzeWx5K1g1djVXSUhSWi95WmpOOC82ZGJsUXhwTXhXZ2g5?= =?utf-8?B?eW5JTTV6WVFaZ1NqVWJ6VCtlNEJNbTB0R3NReTgvL05iU1pPdVJGR2tnaHRY?= =?utf-8?Q?T5Od9Mw4JbeKUiGnHvYqmBc/AzZDtOU8W4k+mcxAM6bsY?= X-MS-Exchange-AntiSpam-MessageData-1: 1Y6WO3T1eB4qvw== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 128d2fbb-5ae1-400c-4023-08df4e298505 X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB6873.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2026 15:00:34.5444 (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: M5ZnSOAFGKw6joaA69UqtK3tiYTbLD0L8EEcY4f39xZGCBCmni05TJocybeo6gvD4o4jzG1JQeX1wNgYXGXarA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV1PR12MB999279 On Fri Nov 27, 2026 at 11:52 PM JST, Gary Guo wrote: <...> >> +/// First word of every r000 queue element: `"MCTP"` in ASCII. >> +const MCTP_MAGIC: u32 =3D 0x4D43_5450; >> + >> +/// Header opening every element of the r000 GSP queues. >> +/// >> +/// A queue element is laid out as follows: >> +/// >> +/// ```text >> +/// +------------------------------------+ >> +/// | Queue element header | QueueElementHeader: MCT= P magic, element length, >> +/// | | MCTP header, NVDM heade= r, message length. >> +/// +------------------------------------+ >> +/// | Message header | RPC header or GMC API h= eader. The NVDM type >> +/// | | selects between the two= . >> +/// +------------------------------------+ >> +/// | Payload | Message-specific data. >> +/// +------------------------------------+ >> +/// ``` >> +/// >> +/// This is the `noEncryption` layout of the `GSP_MSG_QUEUE_ELEMENT` bi= nding. 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 bindin= g 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)] >> +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 messa= ge header and its >> + /// payload. >> + nvdm_payload_size: u32, >> + reserved: u32, >> +} >> + >> +/// Static validation of [`QueueElementHeader`] against its bindings ty= pe. Kept in a sub-module to >> +/// stay out of the way of the rest of the code. > > If you just want "grouping" then > > const _: () =3D { > }; > > is usually the way and you don't need `super::*` with it. Much better indeed, thanks! > >> +mod queue_element_header_validation { >> + use super::*; >> + >> + // Offsets of `QueueElementHeader`'s fields >> + >> + static_assert!( >> + core::mem::offset_of!(QueueElementHeader, mctp_magic) > > Perhaps import offset_of in the scope? Good idea. <...> >> +#[expect(dead_code)] >> +impl QueueElementHeader { >> + /// Creates the queue element header of an element carrying a messa= ge 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(|_| EOVER= FLOW)?, >> + 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, messag= e 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 el= ement. >> + 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 wr= ong, or if the element >> + /// length is smaller than this header and the message together, = or 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_= len()) >> + || element_len > GSP_MSG_QUEUE_ELEMENT_SIZE_MAX >> + { >> + return Err(EIO); >> + } >> + >> + Ok(()) >> + } >> +} >> + >> +// SAFETY: All fields are integer types or transparent wrappers over on= e, with no padding. >> +unsafe impl AsBytes for QueueElementHeader {} > > Use zerocopy derives instead perhaps? That works yes. Most of the `fw` module still uses the old `transmute` traits, but we will convert them as well eventually so we might as well get the new ones right from the get-go.