From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796371076; b=3+8DBCdFuT3Ifz9/gJE1aXRZtAWHkVchBUTra7GSN/Lmvw3HjPu+cpNUb7epQcgDDWUl B+XlbLJUEQXkBX62W+YYJtBV7/WMmaS6NfRhxUMHsWekWNyHiWhmsU27DSkk6zVA2NYHF f+zXBgVDId902gBzTDon45U50VlZolqH6prCAJgi7g9JxLVLWoBV5cFDNS9NP9lwZmJq3 PmE7Am6ITZXMy7+LvE5j85vR1zxxepfQh3Ye0T1rU0Oy0a8mszPzQCG1h8tJM31lgfNx3 TjZzx2RxzLvZp2Yz76CoVWDN5YhOudPuol3PanTZCZQbKS71gTVSz5ApPVmSw5t5YqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796371076; h=Received:DKIM-Signature:X-Mailer:From:To:Cc:Subject:In-Reply-To: References:Date:Message-ID:MIME-Version:Content-Type; bh=s8AYbUXfY3QPFAkb2qblLzvvmciUchwvJ+sI64nPOBY=; b=Ae1S2GsKm4oXZ2yRmdf2dNUzPBIUUBpRXr/A+YuL2F7Tujiq2mGqi/cWJY+8A6CrWsRZ Lc7Z7rVtZLhKdLF8pRf81N8ViBP+FGc21E11z1AU52DCoxLujXjhmaMPObX/PakdGC8Dv 3g+mXix73zTQuAt1XWB7t0sAOitvWTsaZnH/MT5MKl/8X1mzgI/4rHOmNwMc0L0Z6+U5x 86kBhVI9WEK31iQ8HdcMqFE/1l2xCsBZUAnNgHSzUp9PizquNMwM9l0bcbH4wjHBl0vSs IFVFeA/rfa2ujIToqFM6jD6DHMcJpWEq/+hL15B1Gw7iI6lKD4X7Xnb0XQ7DBf6rbUg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jQ3MiT+T; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E8E9606A322; Fri, 4 Dec 2026 07:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jQ3MiT+T Received: by smtp.kernel.org (Postfix) with ESMTPSA id 259F21F000CE; Fri, 4 Dec 2026 07:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796371076; bh=s8AYbUXfY3QPFAkb2qblLzvvmciUchwvJ+sI64nPOBY=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=jQ3MiT+To5BlKEqXJAi5IpcN9WXxC3/bLh6ULQVUh4tzffCpZVxnrSxxiBlO672fM r2JTRH1n9sTeG9Xg3KQY3ZZESFm0T4meBUzF1gfv0AqTO20kr3sVKPlsjwKlNNazWj lQ9ph5zXgGUPRDikj0xIOfIhImSl7WRoPMEe21wKkLeKnAYrtbkJsUhmAzJg0vMiHr HT9c1L2bbUuEbZ5BviUqiYv55DkPpN8Hd+bWtZfFxjJ6zg9zy6jWxmjDVBidlRYAPL wPPSayENl2tVvWOmuextxFsyMAk3pzwYwqzmJ1RGQt27waqgVLJu2L2xQyGe1WhHYw V7VfcnhGCcnWg== X-Mailer: emacs 31.1 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Jiri Pirko , linux-coco@lists.linux.dev Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, jgg@ziepe.ca, david.quigley@intel.com, lukas@wunner.de, ksinyuk@kernel.org, rodrigo.vivi@intel.com, cedric.xing@intel.com, sameo@meta.com, drdeeglaze@gmail.com, James.Bottomley@HansenPartnership.com, aik@amd.com, jpiotrowski@nvidia.com, qinkun@google.com, pgonda@google.com, jic23@kernel.org, alistair.francis@wdc.com, ankita@nvidia.com, suzuki.poulose@arm.com, kas@kernel.org, rick.p.edgecombe@intel.com, elena.reshetova@intel.com, dave.hansen@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, peter.fang@intel.com, jarkko@kernel.org, zohar@linux.ibm.com, yeoreum.yun@arm.com, dave.jiang@intel.com, nik.borisov@suse.com, sergii.dmytruk@3mdeb.com Subject: Re: [PATCH RFC v2 3/9] attestation: Prepare provider and instance core In-Reply-To: <20261113160838.2512652-4-jiri@resnulli.us> References: <20261113160838.2512652-1-jiri@resnulli.us> <20261113160838.2512652-4-jiri@resnulli.us> Date: Fri, 04 Dec 2026 13:27:41 +0530 Message-ID: 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 Content-Type: text/plain Jiri Pirko writes: > From: Jiri Pirko > > Add provider validation, instance registration and lifecycle management > for the attestation family. Each instance is a device of the attestation > class, with a node under /dev/attestation/, and embeds its CTLV > instance and node. > > The provider descriptor is one immutable evidence and MR contract; MR > state follows in the next patch. The core object can be compile-checked > here. CONFIG_ATTESTATION remains unwired until the CTLV handlers land. > [ ... 444 lines skipped ... ] > +/** > + * attestation_register - Make an allocated device reachable. > + * @att: device from attestation_alloc() > + * > + * Return: 0, or a negative errno with @att still to be put. > + */ > +int attestation_register(struct attestation_dev *att) > +{ > + int ret; > + > + ret = attestation_registry_insert(att); > + if (ret) > + return ret; > + ctlv_publish(&att->ctlv); > + xa_lock(&attestation_instances); > + __xa_set_mark(&attestation_instances, att->index, ATTESTATION_REGISTERED); > + xa_unlock(&attestation_instances); > + > + ret = ctlv_device_add(&att->node); > + if (ret) > + goto err_withdraw; > + return 0; > + > +err_withdraw: > + attestation_withdraw(att); > + ctlv_unpublish(&att->ctlv); > + attestation_registry_remove(att); > + return ret; > +} > +EXPORT_SYMBOL_NS_GPL(attestation_register, "ATTESTATION"); > I ran into this while implementing SPDM attestation. We should keep ctlv->registered false until all registration steps, including ctlv_device_add(), have succeeded. Enabling callbacks should be the final step in attestation_register(). Could we also avoid taking ctlv->registration_lock in ctlv_device_add() and ctlv_publish()? TSM drivers may call attestation_register() while holding their own locks. For CCA, registration holds pci_tsm_rwsem, so taking registration_lock here introduces this dependency: pci_tsm_rwsem -> ctlv->registration_lock CTLV operations hold registration_lock while invoking callbacks, and those callbacks may need to acquire pci_tsm_rwsem, creating the reverse dependency. I think we should preserve this lock ordering: ctlv->registration_lock -> pci_tsm_rwsem and avoid taking registration_lock during ctlv_publish() and ctlv_device_add(). -aneesh