All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
To: Jiri Pirko <jiri@resnulli.us>, 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
Date: Fri, 04 Dec 2026 13:27:41 +0530	[thread overview]
Message-ID: <yq5awlpp1nre.fsf@kernel.org> (raw)
In-Reply-To: <20261113160838.2512652-4-jiri@resnulli.us>

Jiri Pirko <jiri@resnulli.us> writes:

> From: Jiri Pirko <jiri@nvidia.com>
>
> 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

  parent reply	other threads:[~2026-12-04  7:57 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 16:08 [PATCH RFC v2 0/9] attestation: Add a common subsystem and TDX support Jiri Pirko
2026-11-13 16:08 ` [PATCH RFC v2 1/9] attestation: Add the base family specification and generated files Jiri Pirko
2026-11-27  0:25   ` Jason Gunthorpe
2026-11-27 12:54     ` Jiri Pirko
2026-11-30 20:25       ` Jason Gunthorpe
2026-12-02 14:01         ` Jiri Pirko
2026-12-02 14:28           ` Jason Gunthorpe
2026-12-03  9:29             ` Jiri Pirko
2026-12-02 15:38           ` Jarkko Sakkinen
2026-12-02 15:47             ` Jason Gunthorpe
2026-12-02 18:33               ` Jarkko Sakkinen
2026-12-04 10:00           ` Jiri Pirko
2026-12-04 17:31             ` Peter Fang
2026-11-30 14:00     ` Jiri Pirko
2026-11-30 20:35       ` Jason Gunthorpe
2026-12-02 14:55         ` Jiri Pirko
2026-12-02 15:08           ` Jason Gunthorpe
2026-12-03  9:14             ` Jiri Pirko
2026-11-13 16:08 ` [PATCH RFC v2 2/9] Documentation: attestation: Add userspace ABI Jiri Pirko
2026-11-13 16:08 ` [PATCH RFC v2 3/9] attestation: Prepare provider and instance core Jiri Pirko
2026-11-27  0:25   ` Jason Gunthorpe
2026-11-30 14:19     ` Jiri Pirko
2026-11-30 20:37       ` Jason Gunthorpe
2026-12-03 10:16         ` Jiri Pirko
2026-12-03 13:43           ` Jason Gunthorpe
2026-12-03 14:12             ` Jiri Pirko
2026-12-04  7:57   ` Aneesh Kumar K.V [this message]
2026-12-04 17:21     ` Jason Gunthorpe
2026-11-13 16:08 ` [PATCH RFC v2 4/9] attestation: Prepare measurement registers Jiri Pirko
2026-11-13 16:08 ` [PATCH RFC v2 5/9] attestation: Add CTLV operation handling Jiri Pirko
2026-11-13 16:08 ` [PATCH RFC v2 6/9] Documentation: attestation: Describe how to write a provider Jiri Pirko
2026-11-13 16:08 ` [PATCH RFC v2 7/9] tdx-guest: Expose the native attestation service API Jiri Pirko
2026-11-13 16:08 ` [PATCH RFC v2 8/9] attestation: Add the TDX family specification and generated files Jiri Pirko
2026-12-02 20:11   ` Jason Gunthorpe
2026-12-02 21:31     ` Jarkko Sakkinen
2026-12-03  9:53       ` Jiri Pirko
2026-12-03 11:30         ` Jarkko Sakkinen
2026-12-03  9:55     ` Jiri Pirko
2026-11-13 16:08 ` [PATCH RFC v2 9/9] attestation: Add the TDX family implementation Jiri Pirko
2026-11-23  9:09   ` Yeoreum Yun
2026-11-23 12:38     ` Jarkko Sakkinen
2026-11-23 15:11       ` Jason Gunthorpe
2026-11-23 15:15         ` Jarkko Sakkinen
2026-11-23 15:24           ` Jarkko Sakkinen
2026-11-23 15:40             ` Jason Gunthorpe
2026-11-23 15:42               ` Jarkko Sakkinen
2026-11-24 12:13                 ` Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yq5awlpp1nre.fsf@kernel.org \
    --to=aneesh.kumar@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=aik@amd.com \
    --cc=alistair.francis@wdc.com \
    --cc=ankita@nvidia.com \
    --cc=cedric.xing@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dave.jiang@intel.com \
    --cc=david.quigley@intel.com \
    --cc=drdeeglaze@gmail.com \
    --cc=elena.reshetova@intel.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jic23@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=jpiotrowski@nvidia.com \
    --cc=kas@kernel.org \
    --cc=ksinyuk@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=nik.borisov@suse.com \
    --cc=peter.fang@intel.com \
    --cc=pgonda@google.com \
    --cc=qinkun@google.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sameo@meta.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=sergii.dmytruk@3mdeb.com \
    --cc=suzuki.poulose@arm.com \
    --cc=x86@kernel.org \
    --cc=yeoreum.yun@arm.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.