KVM: SEV: Hide "struct kvm_sev_info" behind CONFIG_KVM_AMD_SEV=y

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>
This commit is contained in:
Sean Christopherson 2026-03-10 16:48:21 -07:00
parent 4f67cf7e7e
commit 85d2243a21
2 changed files with 7 additions and 1 deletions

View 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;
}

View 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;