]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86: Eliminate "handling" of impossible errors during SUSPEND
authorSean Christopherson <seanjc@google.com>
Sat, 1 Feb 2025 01:38:18 +0000 (17:38 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 12 Feb 2025 18:45:54 +0000 (10:45 -0800)
Drop KVM's handling of kvm_set_guest_paused() failure when reacting to a
SUSPEND notification, as kvm_set_guest_paused() only "fails" if the vCPU
isn't using kvmclock, and KVM's notifier callback pre-checks that kvmclock
is active.  I.e. barring some bizarre edge case that shouldn't be treated
as an error in the first place, kvm_arch_suspend_notifier() can't fail.

Reviewed-by: Paul Durrant <paul@xen.org>
Link: https://lore.kernel.org/r/20250201013827.680235-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c

index b83d58f9f0b42db0e3b2291735ecdf4efdc75f95..fa409d540d831b8c9255e970551cdad67b7833f0 100644 (file)
@@ -6905,21 +6905,15 @@ static int kvm_arch_suspend_notifier(struct kvm *kvm)
 {
        struct kvm_vcpu *vcpu;
        unsigned long i;
-       int ret = 0;
-
-       kvm_for_each_vcpu(i, vcpu, kvm) {
-               if (!vcpu->arch.pv_time.active)
-                       continue;
 
-               ret = kvm_set_guest_paused(vcpu);
-               if (ret) {
-                       kvm_err("Failed to pause guest VCPU%d: %d\n",
-                               vcpu->vcpu_id, ret);
-                       break;
-               }
-       }
+       /*
+        * Ignore the return, marking the guest paused only "fails" if the vCPU
+        * isn't using kvmclock; continuing on is correct and desirable.
+        */
+       kvm_for_each_vcpu(i, vcpu, kvm)
+               (void)kvm_set_guest_paused(vcpu);
 
-       return ret ? NOTIFY_BAD : NOTIFY_DONE;
+       return NOTIFY_DONE;
 }
 
 int kvm_arch_pm_notifier(struct kvm *kvm, unsigned long state)