From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 039362E1747 for ; Thu, 30 Oct 2025 10:31:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761820298; cv=none; b=hIHyXgBZVmeKyi8mNI+GR4IBcPkVp7fj+PNMiCQq1cFI29saSWI2W8wC9kE6ybMnePpGu/jqWMYXesLNW6tPQWPYzgv+cZ3Bf7eKyV3iIaUztU4kGZU/N+kqygUMBPruax4AUMU4wcimYuxuZccVHT1c8M+50IK1jZTUO+aOqMc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761820298; c=relaxed/simple; bh=/YUvUR3zhDx5+HG1lt6o7hAV5AVHpvcKDtbsJdFid74=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iLiYaTSHONNAQ478yv9Vol4SB/BVlGJgXxD73AiqRcdadPGH4lfNMEECxzNSlJqUaURWEW+UCas87ykl73q47az1GXB5b3zhIt38ENB4CEzobCmyQn2kj5h2q5+tOEUrSqt9I9uHE1N1H/ytzLYAxm0P5dYAlFNPxQ+mq8uMttw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4cy0jN4GpWz6K5rl; Thu, 30 Oct 2025 18:29:44 +0800 (CST) Received: from dubpeml100005.china.huawei.com (unknown [7.214.146.113]) by mail.maildlp.com (Postfix) with ESMTPS id A9FFB1402F9; Thu, 30 Oct 2025 18:31:33 +0800 (CST) Received: from localhost (10.203.177.15) by dubpeml100005.china.huawei.com (7.214.146.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 30 Oct 2025 10:31:33 +0000 Date: Thu, 30 Oct 2025 10:31:31 +0000 From: Jonathan Cameron To: Dan Williams CC: , , , , Xu Yilun Subject: Re: [RFC PATCH 03/27] coco/tdx-host: Support Link TSM for TDX host Message-ID: <20251030103131.00007678@huawei.com> In-Reply-To: <20250919142237.418648-4-dan.j.williams@intel.com> References: <20250919142237.418648-1-dan.j.williams@intel.com> <20250919142237.418648-4-dan.j.williams@intel.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500011.china.huawei.com (7.191.174.215) To dubpeml100005.china.huawei.com (7.214.146.113) On Fri, 19 Sep 2025 07:22:12 -0700 Dan Williams wrote: > From: Xu Yilun > > Register a Link TSM instance to support host side TSM operations for > TDISP, when the TDX Connect support bit is set by TDX Module in > tdx_feature0. > > This is the main purpose of an independent tdx-host module out of TDX > core. Recall that a TEE Security Manager (TSM) is a platform agent that > speaks the TEE Device Interface Security Protocol (TDISP) to PCIe > devices and manages private memory resources for the platform. An > independent tdx-host module allows for device-security enumeration and > initialization flows to be deferred from other TDX Module initialization > requirements. Crucially, when / if TDX Module init moves earlier in x86 > initialization flow this driver is still guaranteed to run after IOMMU > and PCI init (i.e. subsys_initcall() vs device_initcall()). > > The ability to unload the module, or unbind the driver is also useful > for debug and coarse grained transitioning between PCI TSM operation and > PCI CMA operation (native kernel PCI device authentication). > > For now this is the basic boilerplate with operation flows to be added > later. > > Signed-off-by: Xu Yilun > Co-developed-by: Dan Williams > Signed-off-by: Dan Williams > --- > arch/x86/include/asm/tdx.h | 1 + > drivers/virt/coco/tdx-host/Kconfig | 6 ++ > drivers/virt/coco/tdx-host/tdx-host.c | 145 +++++++++++++++++++++++++- > 3 files changed, 151 insertions(+), 1 deletion(-) > > diff --git a/drivers/virt/coco/tdx-host/tdx-host.c b/drivers/virt/coco/tdx-host/tdx-host.c > index 49c205913ef6..41813ba352d0 100644 > --- a/drivers/virt/coco/tdx-host/tdx-host.c > +++ b/drivers/virt/coco/tdx-host/tdx-host.c > +static struct pci_tsm_ops tdx_link_ops; > + Why is this needed? > +static int tdx_connect_init(struct device *dev) > +{ > + struct tsm_dev *link; > + > + if (!IS_ENABLED(CONFIG_TDX_CONNECT)) > + return 0; > + > + tdx_sysinfo = tdx_get_sysinfo(); > + if (!tdx_sysinfo) > + return -ENXIO; > + > + if (!(tdx_sysinfo->features.tdx_features0 & TDX_FEATURES0_TDXCONNECT)) > + return 0; > + > + link = tsm_register(dev, &tdx_link_ops); > + if (IS_ERR(link)) { > + dev_err(dev, "failed to register TSM: (%pe)\n", link); > + return PTR_ERR(link); Might as well use return dev_err_probe(dev, PTR_ERR(link), "failed to register TSM\n"); as that will pretty print the error for you anyway and saves a few lines of code. Thanks, Jonathan