]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
KVM: x86: cull apicv code when userspace irqchip is requested
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 30 Jan 2019 16:18:59 +0000 (17:18 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 20 Feb 2019 21:48:21 +0000 (22:48 +0100)
Currently apicv_active can be true even if in-kernel LAPIC
emulation is disabled.  Avoid this by properly initializing
it in kvm_arch_vcpu_init, and then do not do anything to
deactivate APICv when it is actually not used

(Currently APICv is only deactivated by SynIC code that in turn
is only reachable when in-kernel LAPIC is in use.  However, it is
cleaner if kvm_vcpu_deactivate_apicv avoids relying on this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c

index e67ecf25e69087ff6aa8711001a59b175477a3b1..a1fb99f2131713b9f23696be1699b15dbf2a1632 100644 (file)
@@ -7055,6 +7055,13 @@ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid)
 
 void kvm_vcpu_deactivate_apicv(struct kvm_vcpu *vcpu)
 {
+       if (!lapic_in_kernel(vcpu)) {
+               WARN_ON_ONCE(vcpu->arch.apicv_active);
+               return;
+       }
+       if (!vcpu->arch.apicv_active)
+               return;
+
        vcpu->arch.apicv_active = false;
        kvm_x86_ops->refresh_apicv_exec_ctrl(vcpu);
 }
@@ -9005,7 +9012,6 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
        struct page *page;
        int r;
 
-       vcpu->arch.apicv_active = kvm_x86_ops->get_enable_apicv(vcpu);
        vcpu->arch.emulate_ctxt.ops = &emulate_ops;
        if (!irqchip_in_kernel(vcpu->kvm) || kvm_vcpu_is_reset_bsp(vcpu))
                vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
@@ -9026,6 +9032,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
                goto fail_free_pio_data;
 
        if (irqchip_in_kernel(vcpu->kvm)) {
+               vcpu->arch.apicv_active = kvm_x86_ops->get_enable_apicv(vcpu);
                r = kvm_create_lapic(vcpu);
                if (r < 0)
                        goto fail_mmu_destroy;