2.12.2.2 SEV-SNP COMPLETION_WAIT Store Restrictions On systems that are SNP-enabled, the store address associated with any host COMPLETION_WAIT command (s=1) is restricted. The Store Address must fall within the address range specified by the Completion Store Base and Completion Store Limit registers. When the system is SNP-enabled, the memory within this range will be marked in the RMP using a special immutable state by the PSP. This memory region will be readable by the CPU but not writable. 2.12.2.3 SEV-SNP Exclusion Range Restrictions The exclusion range feature is not supported on systems that are SNP-enabled. Additionally, the Exclusion Base and Exclusion Range Limit registers are re-purposed to act as the Completion Store Base and Limit registers. Therefore, we need to disable IOMMU SNP enforcement with SNP_SHUTDOWN_EX command before the kdump kernel starts booting as we can't setup IOMMU CWB again in kdump as SEV-SNP exclusion base and range limit registers are locked as IOMMU SNP support is still enabled. I tried to use the previous kernel's CWB (cmd_sem) as below: static int __init alloc_cwwb_sem(struct amd_iommu *iommu) { if (!is_kdump_kernel()) iommu->cmd_sem = iommu_alloc_4k_pages(iommu, GFP_KERNEL, 1); else { if (check_feature(FEATURE_SNP)) { u64 cwwb_sem_paddr; cwwb_sem_paddr = readq(iommu->mmio_base + MMIO_EXCL_BASE_OFFSET); iommu->cmd_sem = iommu_phys_to_virt(cwwb_sem_paddr); return iommu->cmd_sem ? 0 : -ENOMEM; } } return iommu->cmd_sem ? 0 : -ENOMEM; } I tried this, but this fails as i believe the kdump kernel will not have these previous kernel's allocated IOMMU CWB in the kernel direct map : [ 1.708959] AMD-Vi: in alloc_cwwb_sem kdump kernel [ 1.714327] AMD-Vi: in alloc_cwwb_sem SNP feature enabled, cmd_sem_paddr 0x100805000, cmd_sem_vaddr 0xffff9f5340805000 [ 1.726309] AMD-Vi: in alloc_cwwb_sem kdump kernel [ 1.731676] AMD-Vi: in alloc_cwwb_sem SNP feature enabled, cmd_sem_paddr 0x1050051000, cmd_sem_vaddr 0xffff9f6290051000 [ 1.743742] AMD-Vi: in alloc_cwwb_sem kdump kernel [ 1.749109] AMD-Vi: in alloc_cwwb_sem SNP feature enabled, cmd_sem_paddr 0x1050052000, cmd_sem_vaddr 0xffff9f6290052000 [ 1.761177] AMD-Vi: in alloc_cwwb_sem kdump kernel [ 1.766542] AMD-Vi: in alloc_cwwb_sem SNP feature enabled, cmd_sem_paddr 0x100808000, cmd_sem_vaddr 0xffff9f5340808000 [ 1.778509] AMD-Vi: in alloc_cwwb_sem kdump kernel [ 1.783877] AMD-Vi: in alloc_cwwb_sem SNP feature enabled, cmd_sem_paddr 0x1050053000, cmd_sem_vaddr 0xffff9f6290053000 [ 1.795942] AMD-Vi: in alloc_cwwb_sem kdump kernel [ 1.801300] AMD-Vi: in alloc_cwwb_sem SNP feature enabled, cmd_sem_paddr 0x100809000, cmd_sem_vaddr 0xffff9f5340809000 [ 1.813268] AMD-Vi: in alloc_cwwb_sem kdump kernel [ 1.818636] AMD-Vi: in alloc_cwwb_sem SNP feature enabled, cmd_sem_paddr 0x1050054000, cmd_sem_vaddr 0xffff9f6290054000 [ 1.830701] AMD-Vi: in alloc_cwwb_sem kdump kernel [ 1.836069] AMD-Vi: in alloc_cwwb_sem SNP feature enabled, cmd_sem_paddr 0x10080a000, cmd_sem_vaddr 0xffff9f534080a000 [ 1.848039] AMD-Vi: early_amd_iommu_init: irq remaping enabled [ 1.855431] AMD-Vi: in early_enable_iommus [ 1.860032] AMD-Vi: Translation is already enabled - trying to copy translation structures [ 1.869812] AMD-Vi: Copied DEV table from previous kernel. [ 1.875958] AMD-Vi: in build_completion_wait, paddr = 0x100805000 [ 1.882766] BUG: unable to handle page fault for address: ffff9f5340805000 [ 1.890441] #PF: supervisor read access in kernel mode [ 1.896177] #PF: error_code(0x0000) - not-present page .... I think that memremap(..,..,MEMREMAP_WB) will also fail for the same reason as memremap(.., MEMREMAP_WB) for the RAM region will again use the kernel directmap. So it looks like we need to support IOMMU_SNP_SHUTDOWN with SNP_SHUTDOWN_EX command before kdump kernel starts booting. Thanks, Ashish _______________________________________________ kexec mailing list kexec@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/kexec