Re: [PATCH v1 2/2] crypto/ccp: skip SNP_INIT if preparation fails

From: Tom Lendacky

Date: Fri Apr 03 2026 - 09:34:48 EST


On 4/1/26 09:35, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@xxxxxxxxxx>
>
> During SNP_INIT, the firmware checks to see that the SNP enable bit is set
> on all CPUs. If snp_prepare() failed because not all CPUs were online,
> SNP_INIT will fail, so skip it.
>
> Signed-off-by: Tycho Andersen (AMD) <tycho@xxxxxxxxxx>
> ---
> drivers/crypto/ccp/sev-dev.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 939fa8aa155c..1fc7ee432e28 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -1374,7 +1374,10 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
> return -EOPNOTSUPP;
> }
>
> - snp_prepare();
> + if (snp_prepare() < 0) {
> + dev_dbg(sev->dev, "SNP preparation failed, are all CPUs online?\n");
> + return -EOPNOTSUPP;
> + }

Shouldn't this propagate the snp_prepare() return code:

rc = snp_prepare();
if (rc) {
dev_dbg(...)
return ret;
}

Thanks,
Tom

>
> /*
> * Starting in SNP firmware v1.52, the SNP_INIT_EX command takes a list