Skip to content

Commit 1ff3c89

Browse files
sean-jcbonzini
authored andcommitted
KVM: SVM: Invert handling of SEV and SEV_ES feature flags
Leave SEV and SEV_ES '0' in kvm_cpu_caps by default, and instead set them in sev_set_cpu_caps() if SEV and SEV-ES support are fully enabled. Aside from the fact that sev_set_cpu_caps() is wildly misleading when it *clears* capabilities, this will allow compiling out sev.c without falsely advertising SEV/SEV-ES support in KVM_GET_SUPPORTED_CPUID. Signed-off-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Michael Roth <michael.roth@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20240404121327.3107131-2-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 9bc60f7 commit 1ff3c89

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

arch/x86/kvm/cpuid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ void kvm_set_cpu_caps(void)
771771
kvm_cpu_cap_mask(CPUID_8000_000A_EDX, 0);
772772

773773
kvm_cpu_cap_mask(CPUID_8000_001F_EAX,
774-
0 /* SME */ | F(SEV) | 0 /* VM_PAGE_FLUSH */ | F(SEV_ES) |
774+
0 /* SME */ | 0 /* SEV */ | 0 /* VM_PAGE_FLUSH */ | 0 /* SEV_ES */ |
775775
F(SME_COHERENT));
776776

777777
kvm_cpu_cap_mask(CPUID_8000_0021_EAX,

arch/x86/kvm/svm/sev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,10 +2186,10 @@ void sev_vm_destroy(struct kvm *kvm)
21862186

21872187
void __init sev_set_cpu_caps(void)
21882188
{
2189-
if (!sev_enabled)
2190-
kvm_cpu_cap_clear(X86_FEATURE_SEV);
2191-
if (!sev_es_enabled)
2192-
kvm_cpu_cap_clear(X86_FEATURE_SEV_ES);
2189+
if (sev_enabled)
2190+
kvm_cpu_cap_set(X86_FEATURE_SEV);
2191+
if (sev_es_enabled)
2192+
kvm_cpu_cap_set(X86_FEATURE_SEV_ES);
21932193
}
21942194

21952195
void __init sev_hardware_setup(void)

0 commit comments

Comments
 (0)