From: Tom Lendacky <thomas.lendacky@amd.com>
To: Tycho Andersen <tycho@kernel.org>,
Ashish Kalra <ashish.kalra@amd.com>,
John Allen <john.allen@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] crypto: ccp - simplify sev_update_firmware()
Date: Mon, 2 Mar 2026 09:15:55 -0600 [thread overview]
Message-ID: <0b7e2fdf-a331-4bfd-a79e-6a85d5c858b5@amd.com> (raw)
In-Reply-To: <20260302150224.786118-1-tycho@kernel.org>
On 3/2/26 09:02, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
>
> sev_do_cmd() has its own command buffer (sev->cmd_buf) with the correct
> alignment, perms, etc. that it copies the command into, so prepending it to
> the firmware data is unnecessary.
>
> Switch sev_update_firmware() to using a stack allocated command in light of
> this copy, and drop all of the resulting pointer math.
>
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> drivers/crypto/ccp/sev-dev.c | 27 +++++++++------------------
> 1 file changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 096f993974d1..c45c74190c75 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -1967,11 +1967,11 @@ static int sev_get_firmware(struct device *dev,
> /* Don't fail if SEV FW couldn't be updated. Continue with existing SEV FW */
> static int sev_update_firmware(struct device *dev)
> {
> - struct sev_data_download_firmware *data;
> + struct sev_data_download_firmware data;
> const struct firmware *firmware;
> int ret, error, order;
> struct page *p;
> - u64 data_size;
> + void *fw_blob;
>
> if (!sev_version_greater_or_equal(0, 15)) {
> dev_dbg(dev, "DOWNLOAD_FIRMWARE not supported\n");
> @@ -1983,16 +1983,7 @@ static int sev_update_firmware(struct device *dev)
> return -1;
> }
>
> - /*
> - * SEV FW expects the physical address given to it to be 32
> - * byte aligned. Memory allocated has structure placed at the
> - * beginning followed by the firmware being passed to the SEV
> - * FW. Allocate enough memory for data structure + alignment
> - * padding + SEV FW.
> - */
> - data_size = ALIGN(sizeof(struct sev_data_download_firmware), 32);
> -
> - order = get_order(firmware->size + data_size);
> + order = get_order(firmware->size);
> p = alloc_pages(GFP_KERNEL, order);
> if (!p) {
> ret = -1;
> @@ -2003,20 +1994,20 @@ static int sev_update_firmware(struct device *dev)
> * Copy firmware data to a kernel allocated contiguous
> * memory region.
> */
> - data = page_address(p);
> - memcpy(page_address(p) + data_size, firmware->data, firmware->size);
> + fw_blob = page_address(p);
> + memcpy(fw_blob, firmware->data, firmware->size);
>
> - data->address = __psp_pa(page_address(p) + data_size);
> - data->len = firmware->size;
> + data.address = __psp_pa(fw_blob);
> + data.len = firmware->size;
>
> - ret = sev_do_cmd(SEV_CMD_DOWNLOAD_FIRMWARE, data, &error);
> + ret = sev_do_cmd(SEV_CMD_DOWNLOAD_FIRMWARE, &data, &error);
>
> /*
> * A quirk for fixing the committed TCB version, when upgrading from
> * earlier firmware version than 1.50.
> */
> if (!ret && !sev_version_greater_or_equal(1, 50))
> - ret = sev_do_cmd(SEV_CMD_DOWNLOAD_FIRMWARE, data, &error);
> + ret = sev_do_cmd(SEV_CMD_DOWNLOAD_FIRMWARE, &data, &error);
>
> if (ret)
> dev_dbg(dev, "Failed to update SEV firmware: %#x\n", error);
>
> base-commit: 11439c4635edd669ae435eec308f4ab8a0804808
next prev parent reply other threads:[~2026-03-02 15:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 15:02 [PATCH 1/2] crypto: ccp - simplify sev_update_firmware() Tycho Andersen
2026-03-02 15:02 ` [PATCH 2/2] include/psp-sev.h: fix structure member in comment Tycho Andersen
2026-03-02 15:17 ` Tom Lendacky
2026-03-02 15:15 ` Tom Lendacky [this message]
2026-03-14 5:07 ` [PATCH 1/2] crypto: ccp - simplify sev_update_firmware() Herbert Xu
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=0b7e2fdf-a331-4bfd-a79e-6a85d5c858b5@amd.com \
--to=thomas.lendacky@amd.com \
--cc=ashish.kalra@amd.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=john.allen@amd.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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