]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: Don't BUG() the kernel if xa_insert() fails with -EBUSY
authorSean Christopherson <seanjc@google.com>
Wed, 9 Oct 2024 15:04:54 +0000 (08:04 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 16 Dec 2024 22:37:30 +0000 (14:37 -0800)
WARN once instead of triggering a BUG if xa_insert() fails because it
encountered an existing entry.  While KVM guarantees there should be no
existing entry, there's no reason to BUG the kernel, as KVM needs to
gracefully handle failure anyways.

Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20241009150455.1057573-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
virt/kvm/kvm_main.c

index 2e5d3b85b46e2882909b64b50b3c68480adfb508..b855b27a36b65db5f0da217bfaa4c76800598aa6 100644 (file)
@@ -4129,7 +4129,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, unsigned long id)
 
        vcpu->vcpu_idx = atomic_read(&kvm->online_vcpus);
        r = xa_insert(&kvm->vcpu_array, vcpu->vcpu_idx, vcpu, GFP_KERNEL_ACCOUNT);
-       BUG_ON(r == -EBUSY);
+       WARN_ON_ONCE(r == -EBUSY);
        if (r)
                goto unlock_vcpu_destroy;