Re: [PATCH v2] KVM: SVM: forcibly leave SMM mode on vCPU reset

From: Fedor Pchelkin
Date: Sun Apr 13 2025 - 15:30:13 EST


On Sun, 13. Apr 14:57, Mikhail Lobanov wrote:
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index d5d0c5c3300b..34a002a87c28 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -2231,6 +2231,8 @@ static int shutdown_interception(struct kvm_vcpu *vcpu)
> */
> if (!sev_es_guest(vcpu->kvm)) {
> clear_page(svm->vmcb);
> + if (is_smm(vcpu))
> + kvm_smm_changed(vcpu, false);
> kvm_vcpu_reset(vcpu, true);
> }

This won't compile without CONFIG_KVM_SMM=y being set.

arch/x86/kvm/svm/svm.c: In function ‘shutdown_interception’:
arch/x86/kvm/svm/svm.c:2235:25: error: implicit declaration of function ‘kvm_smm_changed’ [-Wimplicit-function-declaration]
2235 | kvm_smm_changed(vcpu, false);
| ^~~~~~~~~~~~~~~



allmodconfig build which, on the other hand, does have

CONFIG_KVM_AMD=m
CONFIG_KVM_SMM=y

also fails with the patch at the current mainline tip.

ERROR: modpost: "kvm_smm_changed" [arch/x86/kvm/kvm-amd.ko] undefined!
make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1
make[1]: *** [/home/kc/ISP/Kernel/linux-stable-allmod/Makefile:1959: modpost] Error 2
make: *** [Makefile:248: __sub-make] Error 2


Looks like the fix in its current form requires some ifdef'erry and
EXPORT_SYMBOL***, too?