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=198.175.65.9 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796007027; b=zuuAgRFciG2mfHxQBq8dF7cbl1qVtCzVRXNuaEUCEMgYwLXJo18ynsiCZKuigbKRFbRT SWbPbgGOlr/GcXkIJzs09QYTxqqu4yKT7mEGVVuW6TDg0CtiUtc5UvGXresHR5ondsPXC 8rVaroXsa/MTCvRJ3weMeLt6VT64OyMkfO6Ck7OZ848nWG4Ag7EOIkMhjZaP0UW//PoX5 i7NzIFsw5ehReRxJr2u7Oey1JAI7Cz5p3vdkwwE6lTV1l0h9kHy+3eqm4W7ka6xoo3/SI 5bmUV07H0mUeIJMdp2CPoP3GjS3zG7xLQCiGD9iArIkuZH0zdhAHQM5XYFL4WttMncQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796007027; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:Received: Received:Received:Received:Date:From:To:CC:Subject:Message-ID: References:Content-Type:Content-Disposition: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-Exchange-RoutingPolicyChecked: 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:X-OriginatorOrg; bh=TjFBLWtOM2Gpdy4/t8Zlmj77TJLGyLkrnBhJ3mD2Mjw=; b=hhK26eaBm8/3/dvW8QpiypmrfqLx9dRETKPGA+bG5T7MoFVAISeFNRpFNYLj1Nr8ctPS hgw9o+LxctA++h/wrD2kfoTy6PHqNko1KZYyHvPcqFZDQYHNjMPpxYnmxXDLN8aObTvTF GT1pOf5eTjAyD9wSc3T+RYdZp/bFjNsoeDlbAU6nPUgD+Ad7UOLM4sONnMNhxiNx/g1T4 XNgxCwkVYiQ/gx4/wfmRDYhRLnfLZVI+YOS6J4n4EK77eP+lqbcTKH0BtKr8W9YypLTQ0 VDUu9BO9nuhkedz1pLyDzZsLpEoy6AW+0oBce0EWAddfFvf6l5Di3irC6Q0S63C863Q== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jghVgyiV; arc=pass header.oldest-pass=0 smtp.remote-ip=198.175.65.9 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66202606A32E; Mon, 30 Nov 2026 02:50:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 66202606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jghVgyiV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796007027; x=1827543027; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=zlfV4WnI/LORSMQ8es3OI83rvLcewSxB3/PMEFDZRUw=; b=jghVgyiVr4GWC1uJ4llQJJupqERPopqxVw1pu3OoiX4m/jtprYyt8hDk 453uLLl6j2oZn83ibf6JmfXbeKKWOS+mPI28rdY9J8QLJlL9J/GSnY0vU HqerF85BT9vFq0u3sjHvSQmalxPl9bUjf6lfhAh9euGAnP1YSnhtW3wi2 pTZXAM7nOyaN9MlFRouxFzAnZci1MNg0i1T8Cmvyo5u1IhpjYXM+3CPEi ZGa4mD4jCTYpypVYF1sogPVzPKGs9b5BpxTHyNEWTrOjTPsbHOtiHeVao 4BS/QdYXLpuJsjwEwqjUdd1mxB0ILEqo0646HsPyehy5f5sBO9/X93R4X w==; X-CSE-ConnectionGUID: ghuSSNkhRKeMZf2Uvra0zA== X-CSE-MsgGUID: m/WF+yKLS5OtZ89yY0vtnA== X-IronPort-AV: E=McAfee;i="6800,10657,11981"; a="4733849" X-IronPort-AV: E=Sophos;i="6.27,241,1787036400"; d="scan'208";a="4733849" Received: from fmviesa011.fm.intel.com ([10.60.135.151]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2026 18:50:26 -0800 X-CSE-ConnectionGUID: UTa9v0Q+SlWe7i+YSTxVvQ== X-CSE-MsgGUID: JFVGkr/HRDi2ZrQ3ssImSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,241,1787036400"; d="scan'208";a="14572082" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by fmviesa011.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2026 18:50:25 -0800 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Sun, 29 Nov 2026 18:50:25 -0800 Received: from ORSEDG901.ED.cps.intel.com (10.7.248.11) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Sun, 29 Nov 2026 18:50:25 -0800 Received: from DM5PR21CU001.outbound.protection.outlook.com (52.101.62.34) by edgegateway.intel.com (134.134.137.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Sun, 29 Nov 2026 18:50:24 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r0XooAXI7fRZyDwwFq1udwSLLKvadoVTKb06p1PpbkY1NTsnmpv5BeA5zJxvQDxmMMP89O17QvAzAR6INMniVnJ4E1C+imxKFQmg11RkLVvOqZuw6aMoGWz8XNYzHtwIg5ceLIRGw3hIaccUwXrn4XX5PaeUrfqWvU8fnkDvviphCdhXa5Ft7OO5P8oFjOyYlTdgzPLmb5dQnzj0m2apU9axZxaCnwpYY0AFG4FeXXWm24sWU0EA6k0NsLix/VCcyNlaitNNmSkxqoKicGER94v5qTY4JW3jfMQUmdv14WcWN1J0JFfqrh96AJpyMZwm8YU/d+q89CUNm3oXGQb6vQ== 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=TjFBLWtOM2Gpdy4/t8Zlmj77TJLGyLkrnBhJ3mD2Mjw=; b=OjH0PlWV961COEjUkyO+Jpsv5PND7jFcNtZDVXgT3tEKyr+QwODVCNdQLdLUf8GHPqSaCaXYGxL78HmzClT2sW2BV71q7xqCIhBnNYyHoPSey5+DkvZv9LWBWjSngvyaFfkQsOojLw7DkZLRooivcpPqaxHL8inYjIl8gp2PW2op+BEhRYzUp6AtrDB4Fq3j2eykVnMyLZskgA+HO0WLh2OgA7I4l+r3aVli27sPDOxIusm6IR5WkY8rtf2D2OPgXicv9wG2+88g3BYQ4++aX9nRx/7ibA3UJGmMwxG2/4YPkb9KuIWkD4+G3zF5ukIqPoZw/CiyyIl9mjAMCBsx6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from IA0PR11MB8380.namprd11.prod.outlook.com (2603:10b6:208:485::21) by PH8PR11MB7069.namprd11.prod.outlook.com (2603:10b6:510:217::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.7; Mon, 30 Nov 2026 02:50:12 +0000 Received: from IA0PR11MB8380.namprd11.prod.outlook.com ([fe80::ea8e:eec4:f8d3:f95d]) by IA0PR11MB8380.namprd11.prod.outlook.com ([fe80::ea8e:eec4:f8d3:f95d%5]) with mapi id 15.21.0662.004; Mon, 30 Nov 2026 02:50:12 +0000 Date: Mon, 30 Nov 2026 10:50:00 +0800 From: Chao Gao To: "Edgecombe, Rick P" CC: "kvm@vger.kernel.org" , "linux-coco@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "Xu, Yilun" , "dave.hansen@linux.intel.com" , "baolu.lu@linux.intel.com" , "Peng, Chao P" , "bp@alien8.de" , "mingo@redhat.com" , "x86@kernel.org" , "tglx@kernel.org" , "Tian, Kevin" , "hpa@zytor.com" , "kas@kernel.org" Subject: Re: [RFC PATCH 1/7] coco/tdx-host: Create metadata for an SPDM session Message-ID: References: <20261116111037.3478844-1-chao.gao@intel.com> <20261116111037.3478844-2-chao.gao@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SG2PR01CA0181.apcprd01.prod.exchangelabs.com (2603:1096:4:189::13) To IA0PR11MB8380.namprd11.prod.outlook.com (2603:10b6:208:485::21) X-Mailing-List: kvm@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: IA0PR11MB8380:EE_|PH8PR11MB7069:EE_ X-MS-Office365-Filtering-Correlation-Id: 26534774-4857-4063-77a8-08df4e8ca787 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|23010399003|366016|18002099003|22082099003|3023799007|4143699003|56012099006|11063799006|261026140227099003|261022105027099003|261022075727099003|261026121527099003|261028144727099003|261021123027099003|261102123227099003|261021121427099003|10067099003; X-Microsoft-Antispam-Message-Info: Ny2fIQoV307i1eMQFfSlWj33Ec5PzNP2wP+m567In9mPHQtpGkUE555L6uvwQ3c7/p7TQoJSgA/pWdiPB+gvXdFMhNqK57wCIuCD/0He0lMXkqNu78zfApjXxVg4SDF450BkKS+nu43UkAGtswnSck5CENrsXqiTFc6g0UfjUik5r7G6e9xppzUbWLyHWHCwb26G4zxpQHGEDvggJvTyMgHUSP5AKQ3tjun2cpQ8JdJTbQuZn1COWsWMJLgq9PNcTj2fSZ04HsS3QlAP3NtkLzfRq1fPoQl2RidZ+12EdwlXO6A13eLb/qHE+U+7KSZkDKCYNBBEN40ycD6ofrJF2CMHtm+oFvzvmWHlQU4zlIdTMr79mKPC/BR+gFpXSdljAmI/NF077Z3Ye662yKl+Z8HfEiq+RcE6J7oksC4fYKaHjAdemZxB4m8j+mx7R3Sy4+i3zShRHII44crTyx9xN5cqLTahXWHtlv9RMMHhPlqkSQTVAYjtqwMkR+HcyqTplU7kq82vQKSQ2ImeZ664wVNHc/mbstv+IB1h5C0gUsstYL+FD4UiiV6KMLBqPpVBHFm8/hWgjastmlbVV4NMd+oea1vzvCkn8xH5CoE/Ko6UleYjD74vrrHPcfuhjYF2Y5bhIV1CARHSu/W0tbeMXoG4dnqmG6U/eJ1JGCYHyQ0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA0PR11MB8380.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(23010399003)(366016)(18002099003)(22082099003)(3023799007)(4143699003)(56012099006)(11063799006)(261026140227099003)(261022105027099003)(261022075727099003)(261026121527099003)(261028144727099003)(261021123027099003)(261102123227099003)(261021121427099003)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?krCHoetH/V3HfdMKCgWpf8ZdjHRx5SYayPR+b0792MswAyd8qeSul4lzJ+E1?= =?us-ascii?Q?59hoRF4PmZsiBujNpuzhMJsgsOrNS5vs8ruSJjMIpon78zfAaKbEiAo5iF/c?= =?us-ascii?Q?rox/o/gWennh34NDafqqIL1euvmtn0iB3TnyTXQXw8jn615pltATnn0TKvC/?= =?us-ascii?Q?Wlux7QrMGqlH+ctQ4PyOhI8rGxnU2SnjqIPIKxdz2Ht/BNhu2CLNnHvO9ph5?= =?us-ascii?Q?D02H4UlpxOIqODHixbgEwbI/U4LjLuIq/aXym6zvuJh35xRc0Ov9LerW6pDr?= =?us-ascii?Q?CbfwGQ5mpAivjnDFb9ddeUH4o8T4cHzey4ukCIZs8PRnZecyJLiBBfGrVQ9K?= =?us-ascii?Q?VQHFpzPuExbtB4uCxqUp1lLrWZLyyjVAdmqyYWvMwiE3eACQju3YNcVEKCuZ?= =?us-ascii?Q?RwcHFKXZb0eEBqNpRktUMmhX4V5G+xsni96SCqk+cWDZwv6efddyonZU4Tjm?= =?us-ascii?Q?MIbKqt5tLn43zySuUIl+DYvaeXum3ByZdUcDPqtbu2cO29gkds7OGz/ef4eC?= =?us-ascii?Q?BiwlC5BeDafx9gAGZCrK2dbrmxcikI4HnuB4YAP4/2XNOeoGgaQCt7bS2TH3?= =?us-ascii?Q?Lf/JbChkpUOqCmEMRZ+qk8T/YBQ6ETIDxGsPPHRU7K+m5JhWHd8LXUy8PJqX?= =?us-ascii?Q?oe2Qg2Zyp/5xzgeqHcTznSrjCqS5NvCSkhKnLRqWqgUrZNesxFaYR8Btwifi?= =?us-ascii?Q?+KKjnDgWAYutFTDLhah2IxcILcEvQ5LoHiCOu6LBCZF73ti2t5ntxM9xr0lv?= =?us-ascii?Q?W7JkYvyi3znVlJkAWIczpINAFwsayTrpFyA2MgFHlMdmpymGQjtsSKr68yY1?= =?us-ascii?Q?C6ZlODY/u19RrgV0+DO3Z9uAgbicLDrGkT0ozTnwaA1Dw++7WrA5Q3TN35O9?= =?us-ascii?Q?aZuCvRSHlVsQoF06nsMBxuvUFrALQXAZG7E6KTdQ8n57/e2EwNw6/Qhb6Mc1?= =?us-ascii?Q?CNYl0ITJUkXE32ayRIomVO2nOaesA+VPN+NkMBMkjl5oQgNkmRpvnuAGuciZ?= =?us-ascii?Q?PAPk3jSOIIJK9FCCdkQFZnXD1dXqZXvVEunYV/UuBSjlnbQFFnnsjsommU7u?= =?us-ascii?Q?+S0PJ40ioIVKRrNBDMZBkYFH39UJBPHUXKYSQ2slANEkxzbBApMhq/cI3dPp?= =?us-ascii?Q?4bfuS/IkrIO5uIkESPCeYW4nURcQ7O92vKIRrOqLrXwDoVpJfSeSjWxflxNt?= =?us-ascii?Q?/vgl7l/HotPV8DIVG9jzeEQYZNGfmxX3ysNhbj/lKawuiAAhTab4bfJG9Mlu?= =?us-ascii?Q?FjI8y/YmUosDyV+SfW6E9lGtJFWmer8gf7FoZdkmWyOtM5z9Pd+3M8ofcg2W?= =?us-ascii?Q?80CN0LenbKX0kpPOhg7QXv5Aa3Qbz5j2vrhovEXxrVMNx97PFOF8/L4ZB/lm?= =?us-ascii?Q?doIZWS8s9uA7X16YKBXaxyO8T/4u5BxTlkRzv4mv5kExuJss9GGvowpdgvpY?= =?us-ascii?Q?XzwMjd0Bjriv9sZIgw4dSWEZnmVarl5qUroFVwKgtjrpH1fTH61pIQcsXUK6?= =?us-ascii?Q?doym2eaYCLjIx5B0P0zmT9IGOyML1cT5Bu3c50NQuMgZ3K5JGUA1YYcgM53Q?= =?us-ascii?Q?68v2T/aLlUew3jH+T53h2lWki7K+VGUJTgf2Egvd7uyx4dzl+40CCXG7hkhX?= =?us-ascii?Q?oMDoGqnOF7Y3QGpyfngSf6dP//ZuiE/zUbnXnGbX1/79rqBnDUVEcxvO+hGR?= =?us-ascii?Q?l/c7ttjESaN7h0BefD7EKkZkYg5/ptWRFxL2CaLb3Eql3vI3mr4y+y6LVWdf?= =?us-ascii?Q?idEdCBfZJQ=3D=3D?= X-Exchange-RoutingPolicyChecked: hLQXFNi4PABQ+jVAs0/yOrcA0btR1f54xTTVFz6YcfSMyDUIQZyGg0tRhYYuZtnFGZUj24fL+xqCcNaYES+IwaWPdC/icSP++2wILyJxxkKloJ3yadDbiLsNK7UuxDcQJUwqS1+Y0u0A0fp/DEQ6pg0vM2nSM1hpxnsSKhbztTrX1PTTXRM3gHJefZ86VFpGUeBKsrgm4gdeS2S73k/txYRibR1YPdNtkLv+pp1l9kKtBAXUCxHL3Jdd8hYnH6aOA3AUDBcqgxHK7k2N7cUUua0zG3CKc0Zk6NXBitL+4ytbYuQWLygZ1l/8SQr5p/MFDM1Yi9PIT7prA8ySmyR4rg== X-MS-Exchange-CrossTenant-Network-Message-Id: 26534774-4857-4063-77a8-08df4e8ca787 X-MS-Exchange-CrossTenant-AuthSource: IA0PR11MB8380.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 02:50:12.6201 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yEBkGq87t8vqFErx9o/uAc+AvhhfzYlKrvactbRyM+uyM136yf2h5q/fu6pY1OrvrPg0Dq7BWBvYgbW16S/VOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB7069 X-OriginatorOrg: intel.com On Sat, Nov 21, 2026 at 10:05:50AM +0800, Edgecombe, Rick P wrote: >On Mon, 2026-11-16 at 03:10 -0800, Chao Gao wrote: >> The TDX module talks to the device over a Security Protocol and Data >> Model (SPDM) session. It needs host memory for each session's metadata, >> and reports the number of pages required in its global metadata. > >Since we usually talk about metadata and mean the global metadata, we will >probably need to explain what session metadata is. Is it just data? Yes. It is used to keep the TDX module's own state for one SPDM session, for example, the session keys. >> >> When setting up an SPDM session, allocate the memory and hand it to the >> TDX module with TDH.SPDM.CREATE. Keep the returned session ID for later >> SEAMCALLs. >> > >This is getting to be a pretty familiar concept. TDX needs per-something scoped >memory. Give it to the TDX module per some seamcall. Can we make it sounds >especially ordinary and then just call out any thing that is different? How about: To set up link encryption, the TDX module talks to the device over a Security Protocol and Data Model (SPDM) session. An SPDM session is an object like a TD or a vCPU. They are managed by the TDX module in the same way. Each has SEAMCALLs to create and delete it, and the TDX module keeps its state for the object in memory provided by the host. Allocate the memory when setting up a session and give it to the TDX module. Get it back when tearing the session down. Creating a session returns a session ID, which later SEAMCALLs use to identify the session. Store it. >> When tearing the session down, reclaim the memory with >> TDH.SPDM.DELETE. If that fails, leak the memory, as the TDX module may >> still be using it. > >When would it fail? It shouldn't in practice. Per the spec, it fails if the input is wrong, if the session is still in use (by another SEAMCALL or by an IDE stream that has not been torn down), or if the TDX module extension hit a fatal error. Any of them would be unexpected. They mean a bug in the kernel or in the TDX module, or an earlier failure to tear down the IDE stream. I would just say in the changelog that TDH.SPDM.DELETE should not fail, and WARN_ON() and leak the memory if it does. >> +#define TDISP_FUNC_ID_SEG_VALID BIT(24) >> + >> +static inline u32 tdisp_func_id(struct pci_dev *pdev) >> +{ >> + u32 func_id; >> + >> + func_id = FIELD_PREP(TDISP_FUNC_ID_SEGMENT, pci_domain_nr(pdev->bus)); >> + if (func_id) >> + func_id |= TDISP_FUNC_ID_SEG_VALID; >> + func_id |= FIELD_PREP(TDISP_FUNC_ID, >> + PCI_DEVID(pdev->bus->number, pdev->devfn)); >> + >> + return func_id; >> +} > >Is this TDISP specific encoding or a TDX-TDISP specific encoding? I think TDISP. >There isn't a more general place to put it? TDISP defines it. There is no TDISP header for such definitions yet. AMD passes the segment and the BDF to its firmware separately. So it looks like TDX is the first user of this encoding. I will add a pci-tdisp.h for it. >> + return -ENXIO; >> + >> + nr_pages = tdx_sysinfo->tdx_connect.spdm_mt_page_count; >> + >> + spdm_mt = alloc_pages_exact(nr_pages * PAGE_SIZE, >> + GFP_KERNEL | __GFP_ZERO); > >Why zero? It is not needed. Will drop it. >> +static int tdx_spdm_session_setup(struct tdx_tsm_link *tlink) >> +{ >> + return tdx_spdm_create(tlink); > >Hmm, its not clear from this patch why we would need so many levels of wrapper >for the setup/teardown seamcall. But it grows in later patches. But it looks >weird in this patch and will probably throw off the tip review. Indeed. I will drop the wrappers from this patch and add them in the later patches (if necessary). >> } >> >> @@ -66,6 +165,7 @@ static struct pci_tsm *tdx_tsm_link_pf0_probe(struct tsm_dev *tsm_dev, >> if (rc) >> return NULL; >> >> + tlink->func_id = tdisp_func_id(pdev); > >Why is this here instead of tdx_spdm_create()? I would drop the cached value. The ID can always be derived from the pci_dev, so tdx_spdm_create() can compute it when needed.