Skip to content

Commit 46781ea

Browse files
ssuthiku-amdbonzini
authored andcommitted
svm: Do not expose x2APIC when enable AVIC
Since AVIC only virtualizes xAPIC hardware for the guest, this patch disable x2APIC support in guest CPUID. Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent be8ca17 commit 46781ea

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arch/x86/kvm/svm.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4572,14 +4572,26 @@ static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio)
45724572
static void svm_cpuid_update(struct kvm_vcpu *vcpu)
45734573
{
45744574
struct vcpu_svm *svm = to_svm(vcpu);
4575+
struct kvm_cpuid_entry2 *entry;
45754576

45764577
/* Update nrips enabled cache */
45774578
svm->nrips_enabled = !!guest_cpuid_has_nrips(&svm->vcpu);
4579+
4580+
if (!kvm_vcpu_apicv_active(vcpu))
4581+
return;
4582+
4583+
entry = kvm_find_cpuid_entry(vcpu, 1, 0);
4584+
if (entry)
4585+
entry->ecx &= ~bit(X86_FEATURE_X2APIC);
45784586
}
45794587

45804588
static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)
45814589
{
45824590
switch (func) {
4591+
case 0x1:
4592+
if (avic)
4593+
entry->ecx &= ~bit(X86_FEATURE_X2APIC);
4594+
break;
45834595
case 0x80000001:
45844596
if (nested)
45854597
entry->ecx |= (1 << 2); /* Set SVM bit */

0 commit comments

Comments
 (0)