KVM: Remove kvm_make_all_cpus_request_except()
authorVenkatesh Srinivas <venkateshs@chromium.org>
Thu, 4 Apr 2024 23:26:51 +0000 (23:26 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 2 May 2024 14:47:03 +0000 (07:47 -0700)
Remove kvm_make_all_cpus_request_except() as it effectively has no users,
and arguably should never have been added in the first place.

Commit 54163a346d4a ("KVM: Introduce kvm_make_all_cpus_request_except()")
added the "except" variation for use in SVM's AVIC update path, which used
it to skip sending a request to the current vCPU (commit 7d611233b016
("KVM: SVM: Disable AVIC before setting V_IRQ")).

But the AVIC usage of kvm_make_all_cpus_request_except() was essentially a
hack-a-fix that simply squashed the most likely scenario of a racy WARN
without addressing the underlying problem(s).  Commit f1577ab21442 ("KVM:
SVM: svm_set_vintr don't warn if AVIC is active but is about to be
deactivated") eventually fixed the WARN itself, and the "except" usage was
subsequently dropped by df63202fe52b ("KVM: x86: APICv: drop immediate
APICv disablement on current vCPU").

That kvm_make_all_cpus_request_except() hasn't gained any users in the
last ~3 years isn't a coincidence.  If a VM-wide broadcast *needs* to skip
the current vCPU, then odds are very good that there is underlying bug
that could be better fixed elsewhere.

Signed-off-by: Venkatesh Srinivas <venkateshs@chromium.org>
Link: https://lore.kernel.org/r/20240404232651.1645176-1-venkateshs@chromium.org
[sean: rewrite changelog with --verbose]
Signed-off-by: Sean Christopherson <seanjc@google.com>
include/linux/kvm_host.h
virt/kvm/kvm_main.c

index 48f31dcd318a08cd75bddeed9de265501c837c7b..e1555d75a2033b47054eb9f90b1cfd4f48de126e 100644 (file)
@@ -193,8 +193,6 @@ static inline bool is_error_page(struct page *page)
 bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
                                 unsigned long *vcpu_bitmap);
 bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
-bool kvm_make_all_cpus_request_except(struct kvm *kvm, unsigned int req,
-                                     struct kvm_vcpu *except);
 
 #define KVM_USERSPACE_IRQ_SOURCE_ID            0
 #define KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID       1
index 3573c8cd9e11ff8ebd629c56e76210d8451a0d4e..bd04aafcb3c4edd2d05f90f3aa481ef3725e5e01 100644 (file)
@@ -311,8 +311,7 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
        return called;
 }
 
-bool kvm_make_all_cpus_request_except(struct kvm *kvm, unsigned int req,
-                                     struct kvm_vcpu *except)
+bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
 {
        struct kvm_vcpu *vcpu;
        struct cpumask *cpus;
@@ -325,22 +324,14 @@ bool kvm_make_all_cpus_request_except(struct kvm *kvm, unsigned int req,
        cpus = this_cpu_cpumask_var_ptr(cpu_kick_mask);
        cpumask_clear(cpus);
 
-       kvm_for_each_vcpu(i, vcpu, kvm) {
-               if (vcpu == except)
-                       continue;
+       kvm_for_each_vcpu(i, vcpu, kvm)
                kvm_make_vcpu_request(vcpu, req, cpus, me);
-       }
 
        called = kvm_kick_many_cpus(cpus, !!(req & KVM_REQUEST_WAIT));
        put_cpu();
 
        return called;
 }
-
-bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
-{
-       return kvm_make_all_cpus_request_except(kvm, req, NULL);
-}
 EXPORT_SYMBOL_GPL(kvm_make_all_cpus_request);
 
 void kvm_flush_remote_tlbs(struct kvm *kvm)