KVM: SVM: Compile sev.c if and only if CONFIG_KVM_AMD_SEV=y
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 4 Apr 2024 12:13:12 +0000 (08:13 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 11 Apr 2024 17:08:21 +0000 (13:08 -0400)
commit0d7bf5e5b00a131cc02ecadbbf42563c0721aaeb
treef6d8846e9b9618be791029ce6877b09a73fed794
parent1ff3c89032a8f241502a0ba8a95fe0133707a061
KVM: SVM: Compile sev.c if and only if CONFIG_KVM_AMD_SEV=y

Stop compiling sev.c when CONFIG_KVM_AMD_SEV=n, as the number of #ifdefs
in sev.c is getting ridiculous, and having #ifdefs inside of SEV helpers
is quite confusing.

To minimize #ifdefs in code flows, #ifdef away only the kvm_x86_ops hooks
and the #VMGEXIT handler. Stubs are also restricted to functions that
check sev_enabled and to the destruction functions sev_free_cpu() and
sev_vm_destroy(), where the style of their callers is to leave checks
to the callers.  Most call sites instead rely on dead code elimination
to take care of functions that are guarded with sev_guest() or
sev_es_guest().

Signed-off-by: Sean Christopherson <seanjc@google.com>
Co-developed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20240404121327.3107131-3-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/Makefile
arch/x86/kvm/svm/sev.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/svm.h