mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: "Pratik R. Sampat" <prsampat@amd.com>,
	mcgrof@kernel.org, russ.weight@linux.dev, dakr@kernel.org,
	ashish.kalra@amd.com, herbert@gondor.apana.org.au,
	davem@davemloft.net
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	gregkh@linuxfoundation.org, rafael@kernel.org,
	chao.gao@intel.com, aik@amd.com, tycho@kernel.org,
	nikunj@amd.com, michael.roth@amd.com, shansinha@google.com
Subject: Re: [Patch v3 6/7] crypto/ccp: Register with fw_uploader and always fail
Date: Wed, 7 Oct 2026 08:55:38 -0500	[thread overview]
Message-ID: <bf2e64d8-3ba5-4310-a048-7dafc6699512@amd.com> (raw)
In-Reply-To: <35ce536c154380a2f8f3af9b2b50069ce16804d0.1791212077.git.prsampat@amd.com>

On 10/5/26 11:15, Pratik R. Sampat wrote:
> In preparation for SEV-SNP DOWNLOAD_FIRMWARE_EX live firmware update
> support, add an 'sev' firmware loader that always fails with EBUSY.
> 
> Co-developed-by: Tycho Andersen (AMD) <tycho@kernel.org>
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
> Signed-off-by: Pratik R. Sampat <prsampat@amd.com>

Just some minor comments below.

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  drivers/crypto/ccp/sev-dev.c | 80 ++++++++++++++++++++++++++++++++++++
>  drivers/crypto/ccp/sev-dev.h |  2 +
>  2 files changed, 82 insertions(+)
> 
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index c40401c861d3..88cf60a9640e 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -2212,6 +2212,80 @@ static int sev_update_firmware(struct device *dev)
>  	return ret;
>  }
>  
> +#ifdef CONFIG_FW_UPLOAD
> +static enum fw_upload_err sev_fw_upload_prepare(struct fw_upload *fw_upload,
> +						const u8 *data, u32 size)
> +{
> +	return FW_UPLOAD_ERR_NONE;
> +}
> +
> +static enum fw_upload_err sev_fw_upload_write(struct fw_upload *fw_upload,
> +					      const u8 *data, u32 offset,
> +					      u32 size, u32 *written)
> +{
> +	return FW_UPLOAD_ERR_BUSY;
> +}
> +
> +static enum fw_upload_err sev_fw_upload_poll_complete(struct fw_upload *fw_upload)
> +{
> +	return FW_UPLOAD_ERR_NONE;
> +}
> +
> +static void sev_fw_upload_cancel(struct fw_upload *fw_upload)
> +{
> +	/* intentional no-op */
> +}
> +
> +static const struct fw_upload_ops sev_fw_upload_ops = {
> +	.prepare = sev_fw_upload_prepare,
> +	.write = sev_fw_upload_write,
> +	.poll_complete = sev_fw_upload_poll_complete,
> +	.cancel = sev_fw_upload_cancel,
> +};
> +
> +/* Serializes registration and unregistration of sev->fwl */
> +static DEFINE_MUTEX(sev_fwl_lock);
> +
> +static void register_sev_fw_uploader(struct sev_device *sev)
> +{
> +	struct fw_upload *fwl;
> +
> +	guard(mutex)(&sev_fwl_lock);
> +
> +	/*
> +	 * The interface only drives DOWNLOAD_FIRMWARE_EX, which is an SNP
> +	 * command, so do not advertise it where SNP is unavailable or the
> +	 * interface already exists.
> +	 */
> +	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP) || sev->fwl)
> +		return;
> +
> +	fwl = firmware_upload_register(sev->dev, "sev", &sev_fw_upload_ops,
> +				       sev);

Make this all one line.

> +	if (IS_ERR(fwl)) {
> +		dev_err(sev->dev, "SEV firmware upload registration failure: %ld\n",
> +			PTR_ERR(fwl));

and this one.

Thanks,
Tom

> +		return;
> +	}
> +
> +	sev->fwl = fwl;
> +}
> +
> +static void unregister_sev_fw_uploader(struct sev_device *sev)
> +{
> +	guard(mutex)(&sev_fwl_lock);
> +
> +	if (!sev->fwl)
> +		return;
> +
> +	firmware_upload_unregister(sev->fwl);
> +	sev->fwl = NULL;
> +}
> +#else	/* CONFIG_FW_UPLOAD */
> +static void register_sev_fw_uploader(struct sev_device *sev) { }
> +static void unregister_sev_fw_uploader(struct sev_device *sev) { }
> +#endif	/* CONFIG_FW_UPLOAD */
> +
>  static int __sev_snp_shutdown_locked(int *error, bool panic)
>  {
>  	struct psp_device *psp = psp_master;
> @@ -3018,6 +3092,8 @@ void sev_dev_destroy(struct psp_device *psp)
>  	if (!sev)
>  		return;
>  
> +	unregister_sev_fw_uploader(sev);
> +
>  	sev_firmware_shutdown(sev);
>  
>  	if (sev->misc)
> @@ -3081,6 +3157,8 @@ void sev_pci_init(void)
>  			 api_major, api_minor, build,
>  			 sev->api_major, sev->api_minor, sev->build);
>  
> +	register_sev_fw_uploader(sev);
> +
>  	return;
>  
>  err:
> @@ -3096,6 +3174,8 @@ void sev_pci_exit(void)
>  	if (!sev)
>  		return;
>  
> +	unregister_sev_fw_uploader(sev);
> +
>  	sev_firmware_shutdown(sev);
>  }
>  
> diff --git a/drivers/crypto/ccp/sev-dev.h b/drivers/crypto/ccp/sev-dev.h
> index d5e596606def..7ec692e2147e 100644
> --- a/drivers/crypto/ccp/sev-dev.h
> +++ b/drivers/crypto/ccp/sev-dev.h
> @@ -69,6 +69,8 @@ struct sev_device {
>  
>  	struct tsm_dev *tsmdev;
>  	struct sev_tio_status *tio_status;
> +
> +	struct fw_upload *fwl;
>  };
>  
>  int sev_dev_init(struct psp_device *psp);


  parent reply	other threads:[~2026-10-07 13:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 16:15 [Patch v3 0/7] Implement SNP live firmware update support Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 1/7] firmware_loader: Stop pinning modules on registration Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 2/7] firmware_loader: Stop pinning parent device per workqueue invocation Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 3/7] treewide: firmware_loader: Drop the unused @module argument Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 4/7] crypto: ccp - Factor out the release of the SEV firmware buffers Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 5/7] crypto: ccp - Allow SNP platform data to be queried after SNP INIT Pratik R. Sampat
2026-10-06 14:45   ` Tom Lendacky
2026-10-06 14:50     ` Pratik R. Sampat
2026-10-05 16:15 ` [Patch v3 6/7] crypto/ccp: Register with fw_uploader and always fail Pratik R. Sampat
2026-10-06 20:24   ` Shantanu Sinha
2026-10-07 15:36     ` Pratik R. Sampat
2026-10-07 13:55   ` Tom Lendacky [this message]
2026-10-05 16:15 ` [Patch v3 7/7] crypto/ccp: Implement SNP Download Firmware EX Pratik R. Sampat
2026-10-06 16:10   ` Tom Lendacky
2026-10-06 16:41     ` Pratik R. Sampat
2026-10-06 17:32       ` Tom Lendacky
2026-10-06 17:55         ` Pratik R. Sampat
2026-10-06 21:09           ` Shantanu Sinha
2026-10-07 15:36             ` Pratik R. Sampat

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=bf2e64d8-3ba5-4310-a048-7dafc6699512@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=aik@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=chao.gao@intel.com \
    --cc=dakr@kernel.org \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=michael.roth@amd.com \
    --cc=nikunj@amd.com \
    --cc=prsampat@amd.com \
    --cc=rafael@kernel.org \
    --cc=russ.weight@linux.dev \
    --cc=shansinha@google.com \
    --cc=tycho@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®