From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796115402; b=xQZo5rdF+vn7dvXLdG3H98EQ2iZDz73Hjv9xGJtYzzQk2rJZcqK3nPGmyzJwCKjvy668 Cdm2NQam/6Eec7Qr3DeMXNqhLcAFtYljLpgRlfYejWi3WwqSS1HnwO2Gt+AYnO7PZZl/q Z2DquC5ecpyHl25bwXjo0e7L7bJp3ntDvh/YOL8hjafMfSrxcKCnCLEYFkAUs9TNUerAH HuJ06otEJsJNy+oQlamfcbne1ZP2EOTbbUm8PrcKPexM3Ow0iGGhscQjk2egL4TtDuiBy d4y4vSKwyw0AZ6AkQfK+xeyCbkJaJW80tFhFVJydl2V7rv1rfW7lffKuoiMhO0M5O0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115402; 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:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=e6LxdO7OiNovFbJslmHGg/Vm8tlmlD/mHTMxoQupAl0=; b=Sdi8V4dtLYBiT2HhNDU6PqJzHo6ZywcuFyRmGXGk0N/Df96FgtRSgzP7ae8VmmbLDs4Q Lyfvx0G9bMfkXm8TRkTJDLpYHFL5Hk/QRTGLe7RHucvMDsdphqdkVa3uU/eUTzFhehT7P nK2RrZ/cOs3mj+iPIYy7cOLhDQQjo4ILElxuXFxTZnwy29dglkwEmHVp8ooXMpcH8kCIG nrYd4Z/uhaewI7rYAfb70WU6hGmGBfZKnZpRN9ag2EFVUbzqDt7oNeKkRewSznDWPWW6R Q5Sz7s9XSyG1M5xW8c4/nCvWxqGGKMgYgNVmfwdCfKtjDVyj1ng7gHRz+mwkPT7gVRw== ARC-Authentication-Results: i=1; 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=SuCg7+bO; arc=none smtp.remote-ip=192.198.163.14 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 D35EA606A31A; Tue, 1 Dec 2026 08:56:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D35EA606A31A 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=SuCg7+bO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796115401; x=1827651401; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=e6LxdO7OiNovFbJslmHGg/Vm8tlmlD/mHTMxoQupAl0=; b=SuCg7+bO6h8Z0fw+1cj74T08/LDffim93nXlqaM70h7GFD8cUTHudYL9 QX4/+tJAP+Q0hjiHQCHN1u1SbKcgvs78Efes+UQBJUamqVCK7oilabrpA ZTe7uwvJ8nehFJ6bt7b3a19hPs0VoKBpMpe/WgzPs5coJBx4iAyOoFnfF exMACffqS7r/3eo4Ahd694YpYGT1gcmoGryphw7OEDKXlZiBCJGkCWhze n0r37d0Njfb+gGxXfREx2dfRT+4QfJswRMQmQ2sEwpcawP7qhS0olPS3L NmJVdCiTy5jp0YTw0sVK1b5ZvIe7bCTANALFf/Mb3CQmSFIy8D+NWlfK+ A==; X-CSE-ConnectionGUID: BpbajL1UQAW1suWacwqbnA== X-CSE-MsgGUID: hkUH/PVUQDOSu1k2WHqT3A== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4945367" X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="4945367" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 00:56:41 -0800 X-CSE-ConnectionGUID: Y75WSdExQTS4D3C276mgnA== X-CSE-MsgGUID: rd5FxMmvQ6WskhvmPx0eWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="13314739" Received: from unknown (HELO gnr-sp-2s-612) ([10.112.229.148]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 00:56:36 -0800 Date: Tue, 1 Dec 2026 16:56:28 +0800 From: Zhenzhong Duan To: "Aneesh Kumar K.V (Arm)" Cc: linux-coco@lists.linux.dev, Dan Williams , Leon Romanovsky , Bjorn Helgaas , Jason Gunthorpe , Jonathan Cameron , Xu Yilun , Alexey Kardashevskiy , Greg Kroah-Hartman , "Rafael J . Wysocki" , Steven Price , Suzuki K Poulose , Lukas Wunner , Ashish Kalra , Tom Lendacky , Herbert Xu , driver-core@lists.linux.dev, linux-pci@vger.kernel.org, kvm@vger.kernel.org, patches@lists.linux.dev Subject: Re: [PATCH v1 08/10] PCI/TSM: Add sysfs lock and unlock for guest-assigned devices Message-ID: References: <20261123083337.2731019-1-aneesh.kumar@kernel.org> <20261123083337.2731019-9-aneesh.kumar@kernel.org> X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261123083337.2731019-9-aneesh.kumar@kernel.org> On Mon, Nov 23, 2026 at 02:03:35PM +0530, Aneesh Kumar K.V (Arm) wrote: > A confidential guest needs to lock a PCI device before collecting and > verifying evidence about it. Userspace also needs a way to unlock the > device after use or when verification fails. > > Add tsm/lock and tsm/unlock sysfs attributes for TSM drivers > implementing devsec_ops. Writing a TSM device name to tsm/lock calls its > lock callback. Unlock calls the matching driver's unlock callback > > Take device::mutex to prevent driver attachment, then pci_tsm_rwsem > for write to protect pci_dev::tsm during either operation. This order > matches PCI DMA preparation, which runs with the device mutex held. > Return -EBUSY if a PCI driver is already attached. Also call unlock > during PCI device removal or TSM unregister, using the same lock order. > Guest TSM unregister processes one PCI device at a time and releases > both locks before moving to the next device. > > Require ARCH_HAS_CC_PLATFORM and select CONFIDENTIAL_DEVICES so > pci_tsm_unlock() clears the device's accepted state. > > Expose the TSM class device's pci_mode attribute so userspace can > distinguish host link TSM from guest device-security TSM. Evidence > retrieval and acceptance are handled separately through the attestation > subsystem. > > Based on the original Device Security LOCK patch from > Dan Williams , adapted to the current PCI/TSM structures > and locking rules. > > Signed-off-by: Aneesh Kumar K.V (Arm) > --- > Documentation/ABI/testing/sysfs-bus-pci | 35 ++- > Documentation/ABI/testing/sysfs-class-tsm | 19 ++ > Documentation/driver-api/pci/tsm.rst | 47 ++++ > drivers/pci/Kconfig | 2 + > drivers/pci/tsm.c | 247 ++++++++++++++++++++-- > drivers/virt/coco/tsm-core.c | 48 ++++- > include/linux/pci-tsm.h | 21 +- > 7 files changed, 401 insertions(+), 18 deletions(-) <...> > +/** > + * pci_tsm_unlock() - Transition TDI from LOCKED/RUN to UNLOCKED > + * @pdev: TDI device to unlock > + * > + * Returns void, requires all callers to have satisfied dependencies like making > + * sure the device is locked and detached from its driver. > + */ > +static void pci_tsm_unlock(struct pci_dev *pdev) > +{ > + lockdep_assert_held_write(&pci_tsm_rwsem); > + device_lock_assert(&pdev->dev); > + > + if (dev_WARN_ONCE(&pdev->dev, pdev->dev.driver, > + "unlock attempted on driver attached device\n")) > + return; > + > + device_cc_reject(&pdev->dev); > + to_pci_tsm_ops(pdev->tsm)->unlock(pdev->tsm); > + pdev->tsm = NULL; > +} Vendor specific unlock() implemenation can fail for whatever reason, don't we need to return the failure to caller and finally to userspace? I looked into old thread but didn't find why, sorry if I missed. Thanks Zhenzhong