* [PATCH] crypto: ccp: Improve sev_platform_init() error messages
@ 2022-12-31 15:11 Jarkko Sakkinen
2023-01-02 3:18 ` David Rientjes
0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Sakkinen @ 2022-12-31 15:11 UTC (permalink / raw)
To: linux-crypto, Brijesh Singh, Tom Lendacky, John Allen,
Herbert Xu, David S. Miller
Cc: Jarkko Sakkinen, linux-kernel
The following functions end up calling sev_platform_init() or
__sev_platform_init_locked():
* sev_guest_init()
* sev_ioctl_do_pek_csr
* sev_ioctl_do_pdh_export()
* sev_ioctl_do_pek_import()
* sev_ioctl_do_pek_pdh_gen()
* sev_pci_init()
However, only sev_pci_init() prints out the failed command error code, and
even there the error message does not specify, SEV which command failed.
Address this by printing out the SEV command errors inside
__sev_platform_init_locked(), and differentiate between DF_FLUSH, INIT and
INIT_EX commands.
This extra information is particularly useful if firmware loading and/or
initialization is going to be made more robust, e.g. by allowing
firmware loading to be postponed.
Signed-off-by: Jarkko Sakkinen <jarkko@profian.com>
---
drivers/crypto/ccp/sev-dev.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 5350eacaba3a..ac7385c12091 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -963,6 +963,7 @@ static int __sev_init_ex_locked(int *error)
static int __sev_platform_init_locked(int *error)
{
+ const char *cmd = sev_init_ex_buffer ? "SEV_CMD_INIT_EX" : "SEV_CMD_INIT";
struct psp_device *psp = psp_master;
struct sev_device *sev;
int rc = 0, psp_ret = -1;
@@ -1008,18 +1009,23 @@ static int __sev_platform_init_locked(int *error)
if (error)
*error = psp_ret;
- if (rc)
+ if (rc) {
+ dev_err(sev->dev, "SEV: %s failed error %#x", cmd, psp_ret);
return rc;
+ }
sev->state = SEV_STATE_INIT;
/* Prepare for first SEV guest launch after INIT */
wbinvd_on_all_cpus();
- rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, error);
- if (rc)
- return rc;
+ rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, &psp_ret);
+ if (error)
+ *error = psp_ret;
- dev_dbg(sev->dev, "SEV firmware initialized\n");
+ if (rc) {
+ dev_err(sev->dev, "SEV: SEV_CMD_DF_FLUSH failed error %#x", psp_ret);
+ return rc;
+ }
dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major,
sev->api_minor, sev->build);
@@ -2354,8 +2360,7 @@ void sev_pci_init(void)
/* Initialize the platform */
rc = sev_platform_init(&error);
if (rc)
- dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n",
- error, rc);
+ dev_err(sev->dev, "SEV: failed to INIT rc %d\n", rc);
skip_legacy:
dev_info(sev->dev, "SEV%s API:%d.%d build:%d\n", sev->snp_initialized ?
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: ccp: Improve sev_platform_init() error messages
2022-12-31 15:11 [PATCH] crypto: ccp: Improve sev_platform_init() error messages Jarkko Sakkinen
@ 2023-01-02 3:18 ` David Rientjes
2023-01-08 19:50 ` Jarkko Sakkinen
0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2023-01-02 3:18 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: linux-crypto, Brijesh Singh, Tom Lendacky, John Allen,
Herbert Xu, David S. Miller, linux-kernel
On Sat, 31 Dec 2022, Jarkko Sakkinen wrote:
> The following functions end up calling sev_platform_init() or
> __sev_platform_init_locked():
>
> * sev_guest_init()
> * sev_ioctl_do_pek_csr
> * sev_ioctl_do_pdh_export()
> * sev_ioctl_do_pek_import()
> * sev_ioctl_do_pek_pdh_gen()
> * sev_pci_init()
>
> However, only sev_pci_init() prints out the failed command error code, and
> even there the error message does not specify, SEV which command failed.
>
> Address this by printing out the SEV command errors inside
> __sev_platform_init_locked(), and differentiate between DF_FLUSH, INIT and
> INIT_EX commands.
>
> This extra information is particularly useful if firmware loading and/or
> initialization is going to be made more robust, e.g. by allowing
> firmware loading to be postponed.
>
> Signed-off-by: Jarkko Sakkinen <jarkko@profian.com>
> ---
> drivers/crypto/ccp/sev-dev.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 5350eacaba3a..ac7385c12091 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -963,6 +963,7 @@ static int __sev_init_ex_locked(int *error)
>
> static int __sev_platform_init_locked(int *error)
> {
> + const char *cmd = sev_init_ex_buffer ? "SEV_CMD_INIT_EX" : "SEV_CMD_INIT";
> struct psp_device *psp = psp_master;
> struct sev_device *sev;
> int rc = 0, psp_ret = -1;
I think this can just be handled directly in the dev_err() since it's only
used once.
> @@ -1008,18 +1009,23 @@ static int __sev_platform_init_locked(int *error)
> if (error)
> *error = psp_ret;
>
> - if (rc)
> + if (rc) {
> + dev_err(sev->dev, "SEV: %s failed error %#x", cmd, psp_ret);
> return rc;
> + }
>
> sev->state = SEV_STATE_INIT;
>
> /* Prepare for first SEV guest launch after INIT */
> wbinvd_on_all_cpus();
> - rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, error);
> - if (rc)
> - return rc;
> + rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, &psp_ret);
> + if (error)
> + *error = psp_ret;
>
> - dev_dbg(sev->dev, "SEV firmware initialized\n");
Any reason to remove this dbg line? I assume the following dev_info()
line is deemed sufficient?
> + if (rc) {
> + dev_err(sev->dev, "SEV: SEV_CMD_DF_FLUSH failed error %#x", psp_ret);
> + return rc;
> + }
>
> dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major,
> sev->api_minor, sev->build);
> @@ -2354,8 +2360,7 @@ void sev_pci_init(void)
> /* Initialize the platform */
> rc = sev_platform_init(&error);
> if (rc)
> - dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n",
> - error, rc);
> + dev_err(sev->dev, "SEV: failed to INIT rc %d\n", rc);
>
> skip_legacy:
> dev_info(sev->dev, "SEV%s API:%d.%d build:%d\n", sev->snp_initialized ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: ccp: Improve sev_platform_init() error messages
2023-01-02 3:18 ` David Rientjes
@ 2023-01-08 19:50 ` Jarkko Sakkinen
0 siblings, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2023-01-08 19:50 UTC (permalink / raw)
To: David Rientjes
Cc: linux-crypto, Brijesh Singh, Tom Lendacky, John Allen,
Herbert Xu, David S. Miller, linux-kernel
On Sun, Jan 01, 2023 at 07:18:30PM -0800, David Rientjes wrote:
> On Sat, 31 Dec 2022, Jarkko Sakkinen wrote:
>
> > The following functions end up calling sev_platform_init() or
> > __sev_platform_init_locked():
> >
> > * sev_guest_init()
> > * sev_ioctl_do_pek_csr
> > * sev_ioctl_do_pdh_export()
> > * sev_ioctl_do_pek_import()
> > * sev_ioctl_do_pek_pdh_gen()
> > * sev_pci_init()
> >
> > However, only sev_pci_init() prints out the failed command error code, and
> > even there the error message does not specify, SEV which command failed.
> >
> > Address this by printing out the SEV command errors inside
> > __sev_platform_init_locked(), and differentiate between DF_FLUSH, INIT and
> > INIT_EX commands.
> >
> > This extra information is particularly useful if firmware loading and/or
> > initialization is going to be made more robust, e.g. by allowing
> > firmware loading to be postponed.
> >
> > Signed-off-by: Jarkko Sakkinen <jarkko@profian.com>
> > ---
> > drivers/crypto/ccp/sev-dev.c | 19 ++++++++++++-------
> > 1 file changed, 12 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> > index 5350eacaba3a..ac7385c12091 100644
> > --- a/drivers/crypto/ccp/sev-dev.c
> > +++ b/drivers/crypto/ccp/sev-dev.c
> > @@ -963,6 +963,7 @@ static int __sev_init_ex_locked(int *error)
> >
> > static int __sev_platform_init_locked(int *error)
> > {
> > + const char *cmd = sev_init_ex_buffer ? "SEV_CMD_INIT_EX" : "SEV_CMD_INIT";
> > struct psp_device *psp = psp_master;
> > struct sev_device *sev;
> > int rc = 0, psp_ret = -1;
>
> I think this can just be handled directly in the dev_err() since it's only
> used once.
Ack.
> > @@ -1008,18 +1009,23 @@ static int __sev_platform_init_locked(int *error)
> > if (error)
> > *error = psp_ret;
> >
> > - if (rc)
> > + if (rc) {
> > + dev_err(sev->dev, "SEV: %s failed error %#x", cmd, psp_ret);
> > return rc;
> > + }
> >
> > sev->state = SEV_STATE_INIT;
> >
> > /* Prepare for first SEV guest launch after INIT */
> > wbinvd_on_all_cpus();
> > - rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, error);
> > - if (rc)
> > - return rc;
> > + rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, &psp_ret);
> > + if (error)
> > + *error = psp_ret;
> >
> > - dev_dbg(sev->dev, "SEV firmware initialized\n");
>
> Any reason to remove this dbg line? I assume the following dev_info()
> line is deemed sufficient?
Yes, but agreed that it is not in the scope of the patch so I'll remove
it from the next version.
>
> > + if (rc) {
> > + dev_err(sev->dev, "SEV: SEV_CMD_DF_FLUSH failed error %#x", psp_ret);
> > + return rc;
> > + }
> >
> > dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major,
> > sev->api_minor, sev->build);
> > @@ -2354,8 +2360,7 @@ void sev_pci_init(void)
> > /* Initialize the platform */
> > rc = sev_platform_init(&error);
> > if (rc)
> > - dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n",
> > - error, rc);
> > + dev_err(sev->dev, "SEV: failed to INIT rc %d\n", rc);
> >
> > skip_legacy:
> > dev_info(sev->dev, "SEV%s API:%d.%d build:%d\n", sev->snp_initialized ?
Thank you for the feedback.
BR, Jarkko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-08 19:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-31 15:11 [PATCH] crypto: ccp: Improve sev_platform_init() error messages Jarkko Sakkinen
2023-01-02 3:18 ` David Rientjes
2023-01-08 19:50 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).