]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SEV: Hide "struct kvm_sev_info" behind CONFIG_KVM_AMD_SEV=y
authorSean Christopherson <seanjc@google.com>
Tue, 10 Mar 2026 23:48:21 +0000 (16:48 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 9 Apr 2026 19:00:18 +0000 (12:00 -0700)
Bury "struct kvm_sev_info" behind CONFIG_KVM_AMD_SEV=y to make it harder
for SEV specific code to sneak into common SVM code.

No functional change intended.

Link: https://patch.msgid.link/20260310234829.2608037-14-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/svm.h

index 261e563b9bab4c5f0618d9772bb0167e7b7e625a..20d36f78104c9b25f304f2fd3ccf9202d5f16092 100644 (file)
@@ -4245,8 +4245,10 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
 
 static int svm_vcpu_pre_run(struct kvm_vcpu *vcpu)
 {
+#ifdef CONFIG_KVM_AMD_SEV
        if (to_kvm_sev_info(vcpu->kvm)->need_init)
                return -EINVAL;
+#endif
 
        return 1;
 }
index 089726eb06b21196ab097d4800e9038b2e74cd59..242a65400341741f1168197f3df1a6c560e11269 100644 (file)
@@ -92,6 +92,7 @@ enum {
 /* TPR and CR2 are always written before VMRUN */
 #define VMCB_ALWAYS_DIRTY_MASK ((1U << VMCB_INTR) | (1U << VMCB_CR2))
 
+#ifdef CONFIG_KVM_AMD_SEV
 struct kvm_sev_info {
        bool active;            /* SEV enabled guest */
        bool es_active;         /* SEV-ES enabled guest */
@@ -117,6 +118,7 @@ struct kvm_sev_info {
        cpumask_var_t have_run_cpus; /* CPUs that have done VMRUN for this VM. */
        bool snp_certs_enabled; /* SNP certificate-fetching support. */
 };
+#endif
 
 struct kvm_svm {
        struct kvm kvm;
@@ -127,7 +129,9 @@ struct kvm_svm {
        u64 *avic_physical_id_table;
        struct hlist_node hnode;
 
+#ifdef CONFIG_KVM_AMD_SEV
        struct kvm_sev_info sev_info;
+#endif
 };
 
 struct kvm_vcpu;
@@ -365,12 +369,12 @@ static __always_inline struct kvm_svm *to_kvm_svm(struct kvm *kvm)
        return container_of(kvm, struct kvm_svm, kvm);
 }
 
+#ifdef CONFIG_KVM_AMD_SEV
 static __always_inline struct kvm_sev_info *to_kvm_sev_info(struct kvm *kvm)
 {
        return &to_kvm_svm(kvm)->sev_info;
 }
 
-#ifdef CONFIG_KVM_AMD_SEV
 static __always_inline bool ____sev_guest(struct kvm *kvm)
 {
        return to_kvm_sev_info(kvm)->active;