From: Tom Lendacky <thomas.lendacky@amd.com>
To: Michael Roth <michael.roth@amd.com>, linux-crypto@vger.kernel.org
Cc: herbert@gondor.apana.org.au, davem@davemloft.net,
ackerleytng@google.com, ashish.kalra@amd.com, aik@amd.com,
seanjc@google.com
Subject: Re: [PATCH 1/4] crypto: ccp - Shut down SEV firmware before copying to user
Date: Wed, 14 Oct 2026 08:37:09 -0500 [thread overview]
Message-ID: <6ff1ff1f-6849-4d1c-9232-ea8af465c606@amd.com> (raw)
In-Reply-To: <20261014132145.1726322-2-michael.roth@amd.com>
On 10/14/26 08:20, Michael Roth wrote:
> From: Ackerley Tng <ackerleytng@google.com>
>
> When servicing PEK CSR and PDH certificate export ioctl commands while
> the SEV platform is in the uninitialized state, the driver temporarily
> transitions the firmware to the initialized state, executes the
> firmware command, and shuts the firmware back down.
>
> Currently, the firmware shutdown is performed in the cleanup path
> after copying the command results back to userspace. To allow
> releasing the global SEV command mutex before copying results to
> userspace in a subsequent change, the temporary firmware state
> transition and shutdown must remain grouped with the firmware command
> execution rather than spanning across userspace memory copies.
>
> Move the conditional firmware shutdown immediately after executing the
> firmware command, before copying the output buffers to userspace.
>
> No functional change intended.
>
> Signed-off-by: Ackerley Tng <ackerleytng@google.com>
> Signed-off-by: Michael Roth <michael.roth@amd.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> drivers/crypto/ccp/sev-dev.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index f833cb7e4da3..7de3b6bf71e1 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -2022,6 +2022,9 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
>
> ret = __sev_do_cmd_locked(SEV_CMD_PEK_CSR, &data, &argp->error);
>
> + if (shutdown_required)
> + __sev_firmware_shutdown(sev, false);
> +
> /*
> * Firmware will returns the length of the CSR blob (either the minimum
> * required length or the actual length written), return it to the user.
> @@ -2042,9 +2045,6 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
> }
>
> e_free_blob:
> - if (shutdown_required)
> - __sev_firmware_shutdown(sev, false);
> -
> kfree(blob);
> return ret;
> }
> @@ -2505,6 +2505,9 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
>
> ret = __sev_do_cmd_locked(SEV_CMD_PDH_CERT_EXPORT, &data, &argp->error);
>
> + if (shutdown_required)
> + __sev_firmware_shutdown(sev, false);
> +
> /*
> * Firmware will return the length of the blobs (either the minimum
> * required length or the actual length written), return 'em to the user.
> @@ -2535,9 +2538,6 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
> }
>
> e_free_cert:
> - if (shutdown_required)
> - __sev_firmware_shutdown(sev, false);
> -
> kfree(cert_blob);
> e_free_pdh:
> kfree(pdh_blob);
next prev parent reply other threads:[~2026-10-14 13:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 13:20 [PATCH 0/4] crypto: ccp - Make sev_cmd_mutex more granular Michael Roth
2026-10-14 13:20 ` [PATCH 1/4] crypto: ccp - Shut down SEV firmware before copying to user Michael Roth
2026-10-14 13:37 ` Tom Lendacky [this message]
2026-10-14 13:20 ` [PATCH 2/4] crypto: ccp - Check SNP initialization state after copying user inputs Michael Roth
2026-10-14 13:45 ` Tom Lendacky
2026-10-14 13:20 ` [PATCH 3/4] crypto: ccp - Make usage of sev_cmd_mutex more granular Michael Roth
2026-10-14 13:58 ` Tom Lendacky
2026-10-14 13:20 ` [PATCH 4/4] crypto: ccp - Allocate status page outside sev_cmd_mutex in SNP_PLATFORM_STATUS Michael Roth
2026-10-14 14:04 ` Tom Lendacky
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=6ff1ff1f-6849-4d1c-9232-ea8af465c606@amd.com \
--to=thomas.lendacky@amd.com \
--cc=ackerleytng@google.com \
--cc=aik@amd.com \
--cc=ashish.kalra@amd.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=seanjc@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox