* [PATCH v2] crypto: ccp: Abort doing SEV INIT if SNP INIT fails
@ 2025-03-18 20:07 Ashish Kalra
2025-03-18 20:29 ` Tom Lendacky
0 siblings, 1 reply; 3+ messages in thread
From: Ashish Kalra @ 2025-03-18 20:07 UTC (permalink / raw)
To: seanjc, pbonzini, bp, thomas.lendacky, john.allen, herbert, davem
Cc: michael.roth, kvm, linux-kernel, linux-crypto, linux-coco
From: Ashish Kalra <ashish.kalra@amd.com>
If SNP host support (SYSCFG.SNPEn) is set, then the RMP table must
be initialized before calling SEV INIT.
In other words, if SNP_INIT(_EX) is not issued or fails then
SEV INIT will fail if SNP host support (SYSCFG.SNPEn) is enabled.
Fixes: 1ca5614b84eed ("crypto: ccp: Add support to initialize the AMD-SP for SEV-SNP")
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
v2:
- Fix commit logs.
---
drivers/crypto/ccp/sev-dev.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 2e87ca0e292a..a0e3de94704e 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1112,7 +1112,7 @@ static int __sev_snp_init_locked(int *error)
if (!sev_version_greater_or_equal(SNP_MIN_API_MAJOR, SNP_MIN_API_MINOR)) {
dev_dbg(sev->dev, "SEV-SNP support requires firmware version >= %d:%d\n",
SNP_MIN_API_MAJOR, SNP_MIN_API_MINOR);
- return 0;
+ return -EOPNOTSUPP;
}
/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
@@ -1325,12 +1325,9 @@ static int _sev_platform_init_locked(struct sev_platform_init_args *args)
*/
rc = __sev_snp_init_locked(&args->error);
if (rc && rc != -ENODEV) {
- /*
- * Don't abort the probe if SNP INIT failed,
- * continue to initialize the legacy SEV firmware.
- */
dev_err(sev->dev, "SEV-SNP: failed to INIT rc %d, error %#x\n",
rc, args->error);
+ return rc;
}
/* Defer legacy SEV/SEV-ES support if allowed by caller/module. */
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] crypto: ccp: Abort doing SEV INIT if SNP INIT fails
2025-03-18 20:07 [PATCH v2] crypto: ccp: Abort doing SEV INIT if SNP INIT fails Ashish Kalra
@ 2025-03-18 20:29 ` Tom Lendacky
2025-03-18 20:35 ` Kalra, Ashish
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lendacky @ 2025-03-18 20:29 UTC (permalink / raw)
To: Ashish Kalra, seanjc, pbonzini, bp, john.allen, herbert, davem
Cc: michael.roth, kvm, linux-kernel, linux-crypto, linux-coco
On 3/18/25 15:07, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@amd.com>
>
> If SNP host support (SYSCFG.SNPEn) is set, then the RMP table must
> be initialized before calling SEV INIT.
>
> In other words, if SNP_INIT(_EX) is not issued or fails then
> SEV INIT will fail if SNP host support (SYSCFG.SNPEn) is enabled.
>
> Fixes: 1ca5614b84eed ("crypto: ccp: Add support to initialize the AMD-SP for SEV-SNP")
Just wondering if this really needs a Fixes: tag. Either way SNP and SEV
won't be initialized, you're just returning earlier with an error code
rather than attempting the SEV_INIT(_EX) and getting back a failing
error code.
Thanks,
Tom
> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
>
> v2:
> - Fix commit logs.
> ---
> drivers/crypto/ccp/sev-dev.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 2e87ca0e292a..a0e3de94704e 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -1112,7 +1112,7 @@ static int __sev_snp_init_locked(int *error)
> if (!sev_version_greater_or_equal(SNP_MIN_API_MAJOR, SNP_MIN_API_MINOR)) {
> dev_dbg(sev->dev, "SEV-SNP support requires firmware version >= %d:%d\n",
> SNP_MIN_API_MAJOR, SNP_MIN_API_MINOR);
> - return 0;
> + return -EOPNOTSUPP;
> }
>
> /* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
> @@ -1325,12 +1325,9 @@ static int _sev_platform_init_locked(struct sev_platform_init_args *args)
> */
> rc = __sev_snp_init_locked(&args->error);
> if (rc && rc != -ENODEV) {
> - /*
> - * Don't abort the probe if SNP INIT failed,
> - * continue to initialize the legacy SEV firmware.
> - */
> dev_err(sev->dev, "SEV-SNP: failed to INIT rc %d, error %#x\n",
> rc, args->error);
> + return rc;
> }
>
> /* Defer legacy SEV/SEV-ES support if allowed by caller/module. */
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] crypto: ccp: Abort doing SEV INIT if SNP INIT fails
2025-03-18 20:29 ` Tom Lendacky
@ 2025-03-18 20:35 ` Kalra, Ashish
0 siblings, 0 replies; 3+ messages in thread
From: Kalra, Ashish @ 2025-03-18 20:35 UTC (permalink / raw)
To: Tom Lendacky, seanjc, pbonzini, bp, john.allen, herbert, davem
Cc: michael.roth, kvm, linux-kernel, linux-crypto, linux-coco
Hello Tom,
On 3/18/2025 3:29 PM, Tom Lendacky wrote:
> On 3/18/25 15:07, Ashish Kalra wrote:
>> From: Ashish Kalra <ashish.kalra@amd.com>
>>
>> If SNP host support (SYSCFG.SNPEn) is set, then the RMP table must
>> be initialized before calling SEV INIT.
>>
>> In other words, if SNP_INIT(_EX) is not issued or fails then
>> SEV INIT will fail if SNP host support (SYSCFG.SNPEn) is enabled.
>>
>> Fixes: 1ca5614b84eed ("crypto: ccp: Add support to initialize the AMD-SP for SEV-SNP")
>
> Just wondering if this really needs a Fixes: tag. Either way SNP and SEV
> won't be initialized, you're just returning earlier with an error code
> rather than attempting the SEV_INIT(_EX) and getting back a failing
> error code.
Yes, that's true in a way, as continuing with SEV INIT after SNP INIT(_EX) failure
will still cause SEV INIT to fail, we are simply aborting here after
SNP INIT(_EX) failure, so i will drop the Fixes: tag and post another version.
Thanks,
Ashish
>
> Thanks,
> Tom
>
>> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
>>
>> v2:
>> - Fix commit logs.
>> ---
>> drivers/crypto/ccp/sev-dev.c | 7 ++-----
>> 1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
>> index 2e87ca0e292a..a0e3de94704e 100644
>> --- a/drivers/crypto/ccp/sev-dev.c
>> +++ b/drivers/crypto/ccp/sev-dev.c
>> @@ -1112,7 +1112,7 @@ static int __sev_snp_init_locked(int *error)
>> if (!sev_version_greater_or_equal(SNP_MIN_API_MAJOR, SNP_MIN_API_MINOR)) {
>> dev_dbg(sev->dev, "SEV-SNP support requires firmware version >= %d:%d\n",
>> SNP_MIN_API_MAJOR, SNP_MIN_API_MINOR);
>> - return 0;
>> + return -EOPNOTSUPP;
>> }
>>
>> /* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
>> @@ -1325,12 +1325,9 @@ static int _sev_platform_init_locked(struct sev_platform_init_args *args)
>> */
>> rc = __sev_snp_init_locked(&args->error);
>> if (rc && rc != -ENODEV) {
>> - /*
>> - * Don't abort the probe if SNP INIT failed,
>> - * continue to initialize the legacy SEV firmware.
>> - */
>> dev_err(sev->dev, "SEV-SNP: failed to INIT rc %d, error %#x\n",
>> rc, args->error);
>> + return rc;
>> }
>>
>> /* Defer legacy SEV/SEV-ES support if allowed by caller/module. */
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-18 20:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-18 20:07 [PATCH v2] crypto: ccp: Abort doing SEV INIT if SNP INIT fails Ashish Kalra
2025-03-18 20:29 ` Tom Lendacky
2025-03-18 20:35 ` Kalra, Ashish
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®