]> git.baikalelectronics.ru Git - kernel.git/commitdiff
kvm: x86: hyperv: Use APICv update request interface
authorSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Thu, 14 Nov 2019 20:15:13 +0000 (14:15 -0600)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 5 Feb 2020 14:17:43 +0000 (15:17 +0100)
Since disabling APICv has to be done for all vcpus on AMD-based
system, adopt the newly introduced kvm_request_apicv_update()
interface, and introduce a new APICV_INHIBIT_REASON_HYPERV.

Also, remove the kvm_vcpu_deactivate_apicv() since no longer used.

Cc: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/hyperv.c
arch/x86/kvm/svm.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c

index 19a7d0d3a5fa7aea9f93e5cb77bc2404066e27de..90bfe8becc562fa9b5404be4dc91be378c293988 100644 (file)
@@ -876,6 +876,7 @@ enum kvm_irqchip_mode {
 };
 
 #define APICV_INHIBIT_REASON_DISABLE    0
+#define APICV_INHIBIT_REASON_HYPERV     1
 
 struct kvm_arch {
        unsigned long n_used_mmu_pages;
@@ -1483,7 +1484,6 @@ gpa_t kvm_mmu_gva_to_gpa_write(struct kvm_vcpu *vcpu, gva_t gva,
 gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva,
                                struct x86_exception *exception);
 
-void kvm_vcpu_deactivate_apicv(struct kvm_vcpu *vcpu);
 bool kvm_apicv_activated(struct kvm *kvm);
 void kvm_apicv_init(struct kvm *kvm, bool enable);
 void kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu);
index 4df1c965bf1a934c7318e16a2d69aa2a817992ca..a86fda7a1d03bc64819dd918521e5fbb57118702 100644 (file)
@@ -776,9 +776,10 @@ int kvm_hv_activate_synic(struct kvm_vcpu *vcpu, bool dont_zero_synic_pages)
 
        /*
         * Hyper-V SynIC auto EOI SINT's are
-        * not compatible with APICV, so deactivate APICV
+        * not compatible with APICV, so request
+        * to deactivate APICV permanently.
         */
-       kvm_vcpu_deactivate_apicv(vcpu);
+       kvm_request_apicv_update(vcpu->kvm, false, APICV_INHIBIT_REASON_HYPERV);
        synic->active = true;
        synic->dont_zero_synic_pages = dont_zero_synic_pages;
        return 0;
index 3c211933a0a766b788ed627f205159b2ee0fdf68..3b87ccd320d1838731fa602e813523ad32ad8d78 100644 (file)
@@ -7318,7 +7318,8 @@ static bool svm_apic_init_signal_blocked(struct kvm_vcpu *vcpu)
 
 static bool svm_check_apicv_inhibit_reasons(ulong bit)
 {
-       ulong supported = BIT(APICV_INHIBIT_REASON_DISABLE);
+       ulong supported = BIT(APICV_INHIBIT_REASON_DISABLE) |
+                         BIT(APICV_INHIBIT_REASON_HYPERV);
 
        return supported & BIT(bit);
 }
index 7ba8de3325be772c9a5cb6e6d23487a19707f0af..678edbd6e278b16259e2746b525d66fb6f405fc0 100644 (file)
@@ -7712,7 +7712,8 @@ static __exit void hardware_unsetup(void)
 
 static bool vmx_check_apicv_inhibit_reasons(ulong bit)
 {
-       ulong supported = BIT(APICV_INHIBIT_REASON_DISABLE);
+       ulong supported = BIT(APICV_INHIBIT_REASON_DISABLE) |
+                         BIT(APICV_INHIBIT_REASON_HYPERV);
 
        return supported & BIT(bit);
 }
index d2f15cbe2634a27d78bc9bf9049f3ac388aa84ac..52edf0bb46e5cf8d8a82780888740952b542f7fd 100644 (file)
@@ -7457,19 +7457,6 @@ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid)
        kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq, NULL);
 }
 
-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);
-}
-
 bool kvm_apicv_activated(struct kvm *kvm)
 {
        return (READ_ONCE(kvm->arch.apicv_inhibit_reasons) == 0);