[PATCH v6 3/4] crypto: ccp: Skip SEV and SNP INIT for kdump boot

Ashish Kalra posted 4 patches 5 months, 2 weeks ago
[PATCH v6 3/4] crypto: ccp: Skip SEV and SNP INIT for kdump boot
Posted by Ashish Kalra 5 months, 2 weeks ago
From: Ashish Kalra <ashish.kalra@amd.com>

Since SEV or SNP may already be initialized in the previous kernel,
attempting to initialize them again in the kdump kernel can result
in SNP initialization failures, which in turn lead to IOMMU
initialization failures. Moreover, SNP/SEV guests are not run under a
kdump kernel, so there is no need to initialize SEV or SNP during
kdump boot.

Skip SNP and SEV INIT if doing kdump boot.

Tested-by: Sairaj Kodilkar <sarunkod@amd.com>
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
 drivers/crypto/ccp/sev-dev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 4f000dc2e639..b701908c0bdc 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -28,6 +28,7 @@
 #include <linux/fs_struct.h>
 #include <linux/psp.h>
 #include <linux/amd-iommu.h>
+#include <linux/crash_dump.h>
 
 #include <asm/smp.h>
 #include <asm/cacheflush.h>
@@ -1374,6 +1375,15 @@ static int __sev_platform_init_locked(int *error)
 	if (!psp_master || !psp_master->sev_data)
 		return -ENODEV;
 
+	/*
+	 * Skip SNP/SEV initialization under a kdump kernel as SEV/SNP
+	 * may already be initialized in the previous kernel. Since no
+	 * SNP/SEV guests are run under a kdump kernel, there is no
+	 * need to initialize SNP or SEV during kdump boot.
+	 */
+	if (is_kdump_kernel())
+		return 0;
+
 	sev = psp_master->sev_data;
 
 	if (sev->sev_plat_status.state == SEV_STATE_INIT)
-- 
2.34.1
Re: [PATCH v6 3/4] crypto: ccp: Skip SEV and SNP INIT for kdump boot
Posted by vsntk18@gmail.com 3 months, 1 week ago
Hi,

   these changes seem to have been overwritten after
   459daec42ea0c("crypto: ccp - Cache SEV platform status and platform state")
   has been merged upstream.

   I can send a patch if that's not been done already. Please let me know.

Thanks,
Vasant
Re: [PATCH v6 3/4] crypto: ccp: Skip SEV and SNP INIT for kdump boot
Posted by Kalra, Ashish 3 months, 1 week ago
On 10/29/2025 5:43 AM, vsntk18@gmail.com wrote:
> Hi,
> 
>    these changes seem to have been overwritten after
>    459daec42ea0c("crypto: ccp - Cache SEV platform status and platform state")
>    has been merged upstream.
> 
>    I can send a patch if that's not been done already. Please let me know.
>

Hi,

I believe that the IOMMU updates for 6.18 (containing this patch) were merged 
after this commit: 

commit 459daec42ea0cf5e276dfb82e90ed91e2db45d9e("crypto: ccp - Cache SEV platform status and platform state")

Thanks,
Ashish
 
> Thanks,
> Vasant
>