]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: ensure APICv is considered inactive if there is no APIC
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 30 Nov 2021 12:37:45 +0000 (07:37 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 2 Dec 2021 09:12:11 +0000 (04:12 -0500)
commit856f87c04016f5c500b2d4e76ffc1442d81b8219
treec669580c30f5a082940b346cb4ed1260c640fc86
parentb0a49046b5c2f04261a98608c592679b4edb48e9
KVM: ensure APICv is considered inactive if there is no APIC

kvm_vcpu_apicv_active() returns false if a virtual machine has no in-kernel
local APIC, however kvm_apicv_activated might still be true if there are
no reasons to disable APICv; in fact it is quite likely that there is none
because APICv is inhibited by specific configurations of the local APIC
and those configurations cannot be programmed.  This triggers a WARN:

   WARN_ON_ONCE(kvm_apicv_activated(vcpu->kvm) != kvm_vcpu_apicv_active(vcpu));

To avoid this, introduce another cause for APICv inhibition, namely the
absence of an in-kernel local APIC.  This cause is enabled by default,
and is dropped by either KVM_CREATE_IRQCHIP or the enabling of
KVM_CAP_IRQCHIP_SPLIT.

Reported-by: Ignat Korchagin <ignat@cloudflare.com>
Fixes: 3abdf8fbb784 ("KVM: x86: Move SVM's APICv sanity check to common x86", 2021-10-22)
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Tested-by: Ignat Korchagin <ignat@cloudflare.com>
Message-Id: <20211130123746.293379-1-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/svm/avic.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c