From: Ashish Kalra <ashish.kalra@amd.com>
If SNP is enabled and initialized in the previous kernel then SNP is
already initialized for kdump boot and attempting SNP INIT again
during kdump boot causes SNP INIT failure and eventually leads to
IOMMU failures.
Skip SNP INIT if doing kdump boot.
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
drivers/crypto/ccp/sev-dev.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 17edc6bf5622..19df68963602 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>
@@ -1114,6 +1115,13 @@ static int __sev_snp_init_locked(int *error)
if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
return -ENODEV;
+ /*
+ * Skip SNP INIT for kdump boot as SNP is already initialized if
+ * SNP is enabled.
+ */
+ if (is_kdump_kernel())
+ return 0;
+
sev = psp->sev_data;
if (sev->snp_initialized)
--
2.34.1
On 7/16/2025 12:57 AM, Ashish Kalra wrote: > From: Ashish Kalra <ashish.kalra@amd.com> > > If SNP is enabled and initialized in the previous kernel then SNP is > already initialized for kdump boot and attempting SNP INIT again > during kdump boot causes SNP INIT failure and eventually leads to > IOMMU failures. > > Skip SNP INIT if doing kdump boot. Just double checking, do we need check for snp_rmptable_init()? -Vasant
Hello Vasant, On 7/16/2025 4:20 AM, Vasant Hegde wrote: > > > On 7/16/2025 12:57 AM, Ashish Kalra wrote: >> From: Ashish Kalra <ashish.kalra@amd.com> >> >> If SNP is enabled and initialized in the previous kernel then SNP is >> already initialized for kdump boot and attempting SNP INIT again >> during kdump boot causes SNP INIT failure and eventually leads to >> IOMMU failures. >> >> Skip SNP INIT if doing kdump boot. > > Just double checking, do we need check for snp_rmptable_init()? > Do you mean adding this check in snp_rmptable_init() ? We already have a check there for kexec boot: snp_rmptable_init() { ... ... /* * Check if SEV-SNP is already enabled, this can happen in case of * kexec boot. */ rdmsrq(MSR_AMD64_SYSCFG, val); if (val & MSR_AMD64_SYSCFG_SNP_EN) goto skip_enable; And we still have to map the RMP table in the kernel as SNP is still enabled and initialized in this case for kdump boot, so that is still required as part of snp_rmptable_init(). Additionally, for this patch i also have to skip SEV INIT similar to what we are doing for SNP INIT as we get SEV INIT failure warnings as SEV is also initialized during this kdump boot similar to SNP. So will be moving this check and skip to _sev_platform_init_locked() to handle both SEV and SNP INIT cases. Thanks, Ashish
Hi Ashish, On 7/17/2025 3:33 AM, Kalra, Ashish wrote: > Hello Vasant, > > On 7/16/2025 4:20 AM, Vasant Hegde wrote: >> >> >> On 7/16/2025 12:57 AM, Ashish Kalra wrote: >>> From: Ashish Kalra <ashish.kalra@amd.com> >>> >>> If SNP is enabled and initialized in the previous kernel then SNP is >>> already initialized for kdump boot and attempting SNP INIT again >>> during kdump boot causes SNP INIT failure and eventually leads to >>> IOMMU failures. >>> >>> Skip SNP INIT if doing kdump boot. >> >> Just double checking, do we need check for snp_rmptable_init()? >> > > Do you mean adding this check in snp_rmptable_init() ? > > We already have a check there for kexec boot: > > snp_rmptable_init() > { > ... > ... > /* > * Check if SEV-SNP is already enabled, this can happen in case of > * kexec boot. > */ > rdmsrq(MSR_AMD64_SYSCFG, val); > if (val & MSR_AMD64_SYSCFG_SNP_EN) > goto skip_enable; Ah Ok. thanks! > > And we still have to map the RMP table in the kernel as SNP is still enabled > and initialized in this case for kdump boot, so that is still required as > part of snp_rmptable_init(). > > Additionally, for this patch i also have to skip SEV INIT similar to what we > are doing for SNP INIT as we get SEV INIT failure warnings as SEV is also > initialized during this kdump boot similar to SNP. Sure thanks! -Vasant
© 2016 - 2025 Red Hat, Inc.