On 3/2/26 13:13, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
>
> Use the new snp_prepare_for_snp_init() to initialize SNP from the ccp
> driver instead of at boot time. This means that SNP is not enabled unless
> it is really going to be used (i.e. kvm_amd loads the ccp driver
> automatically).
>
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> arch/x86/virt/svm/sev.c | 2 --
> drivers/crypto/ccp/sev-dev.c | 2 ++
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 8f50538baf7b..aa784542b32d 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -549,8 +549,6 @@ int __init snp_rmptable_init(void)
> if (!setup_rmptable())
> return -ENOSYS;
>
> - snp_prepare_for_snp_init();
> -
> /*
> * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
> * notifier is invoked to do SNP IOMMU shutdown before kdump.
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 096f993974d1..5b1a24b11e3e 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -1375,6 +1375,8 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
> return -EOPNOTSUPP;
> }
>
> + snp_prepare_for_snp_init();
> +
> /* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
> on_each_cpu(snp_set_hsave_pa, NULL, 1);
>