crypto: ccp: Add panic notifier for SEV/SNP firmware shutdown on kdump
authorAshish Kalra <ashish.kalra@amd.com>
Fri, 26 Jan 2024 04:11:20 +0000 (22:11 -0600)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 29 Jan 2024 19:34:19 +0000 (20:34 +0100)
commit8ef979584ea86c247b768f4420148721a842835f
tree7b8bb8ca5c21d1fd4cac6a95a889fc5891f51963
parentf366a8dac1b8fef28a470d4e67b9843ebb8e2a1f
crypto: ccp: Add panic notifier for SEV/SNP firmware shutdown on kdump

Add a kdump safe version of sev_firmware_shutdown() and register it as a
crash_kexec_post_notifier so it will be invoked during panic/crash to do
SEV/SNP shutdown. This is required for transitioning all IOMMU pages to
reclaim/hypervisor state, otherwise re-init of IOMMU pages during
crashdump kernel boot fails and panics the crashdump kernel.

This panic notifier runs in atomic context, hence it ensures not to
acquire any locks/mutexes and polls for PSP command completion instead
of depending on PSP command completion interrupt.

  [ mdr: Remove use of "we" in comments. ]

Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20240126041126.1927228-21-michael.roth@amd.com
arch/x86/include/asm/sev.h
arch/x86/kernel/crash.c
arch/x86/kernel/sev.c
arch/x86/virt/svm/sev.c
drivers/crypto/ccp/sev-dev.c