public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Jarkko Sakkinen <jarkko@profian.com>,
	Harald Hoyer <harald@profian.com>,
	Brijesh Singh <brijesh.singh@amd.com>,
	John Allen <john.allen@amd.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	"open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - SE..." 
	<linux-crypto@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] crypto: ccp: Load the firmware twice when SEV API version < 1.43
Date: Sat, 6 Aug 2022 21:17:08 +0300	[thread overview]
Message-ID: <Yu6wJKS39HyuD4XN@kernel.org> (raw)
In-Reply-To: <77cbdadb-b86c-f8ab-4992-f1963a9fa1e9@amd.com>

On Thu, Aug 04, 2022 at 09:59:44AM -0500, Tom Lendacky wrote:
> On 8/3/22 20:02, Jarkko Sakkinen wrote:
> > From: Jarkko Sakkinen <jarkko@profian.com>
> > 
> > SEV-SNP does not initialize to a legit state, unless the firmware is
> > loaded twice, when SEP API version < 1.43, and the firmware is updated
> > to a later version. Because of this user space needs to work around
> > this with "rmmod && modprobe" combo. Fix this by implementing the
> > workaround to the driver.
> > 
> > Reported-by: Harald Hoyer <harald@profian.com>
> > Signed-off-by: Jarkko Sakkinen <jarkko@profian.com>
> > ---
> >   drivers/crypto/ccp/sev-dev.c | 22 +++++++++++++++++++---
> >   1 file changed, 19 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> > index 799b476fc3e8..f2abb7439dde 100644
> > --- a/drivers/crypto/ccp/sev-dev.c
> > +++ b/drivers/crypto/ccp/sev-dev.c
> 
> > @@ -1274,6 +1285,7 @@ void sev_pci_init(void)
> >   {
> >   	struct sev_device *sev = psp_master->sev_data;
> >   	int error, rc;
> > +	int i;
> >   	if (!sev)
> >   		return;
> > @@ -1283,9 +1295,13 @@ void sev_pci_init(void)
> >   	if (sev_get_api_version())
> >   		goto err;
> > -	if (sev_version_greater_or_equal(0, 15) &&
> > -	    sev_update_firmware(sev->dev) == 0)
> > -		sev_get_api_version();
> > +	/*
> > +	 * SEV-SNP does not work properly before loading the FW twice in the API
> > +	 * versions older than SEV 1.43.
> > +	 */
> > +	for (i = 0; i < sev_version_greater_or_equal(0, 15) + sev_version_less(1, 43); i++)
> > +		if (sev_update_firmware(sev->dev) == 0)
> > +			sev_get_api_version();
> 
> I prefer to have this logic in the sev_update_firmware() function.
> 
> And while the loop is correct, it isn't obvious. Something in
> sev_update_firmware() that just does:
> 
> 	ret = sev_do_cmd(SEV_CMD_DOWNLOAD_FIRMWARE, data, &error);
> 
> 	if (!ret && sev_version_greater_or_equal(0, 15) && sev_version_less(1, 43))
> 		ret = sev_do_cmd(SEV_CMD_DOWNLOAD_FIRMWARE, data, &error);
> 
> And place a comment before the second command that references the reason
> for the second download.
 
OK, I'll do that. Thank you.

BR, Jarkko

      reply	other threads:[~2022-08-06 18:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04  1:02 [PATCH] crypto: ccp: Load the firmware twice when SEV API version < 1.43 Jarkko Sakkinen
2022-08-04 13:13 ` Tom Lendacky
2022-08-04 13:37   ` Harald Hoyer
2022-08-04 13:51     ` Tom Lendacky
2022-08-06 18:16       ` Jarkko Sakkinen
2022-08-06 18:15     ` Jarkko Sakkinen
2022-08-04 13:39   ` Jeremi Piotrowski
2022-08-04 14:59 ` Tom Lendacky
2022-08-06 18:17   ` Jarkko Sakkinen [this message]

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=Yu6wJKS39HyuD4XN@kernel.org \
    --to=jarkko@kernel.org \
    --cc=brijesh.singh@amd.com \
    --cc=davem@davemloft.net \
    --cc=harald@profian.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jarkko@profian.com \
    --cc=john.allen@amd.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=thomas.lendacky@amd.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