Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sean Christopherson" <seanjc@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/5] KVM: Reject attempts to lock all vCPUs if vCPU creation is in-progress
Date: Mon, 14 Sep 2026 18:24:15 +0000	[thread overview]
Message-ID: <20260914182416.4D4011F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914181223.289061-2-seanjc@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Redundant manual check for vCPU creation left behind in ARM VGIC initialization.
--

commit 62db20a1fe5b1f9f44f668c005957e7cf68b7547
Author: Sean Christopherson <seanjc@google.com>

KVM: Reject attempts to lock all vCPUs if vCPU creation is in-progress

This commit updates KVM to reject attempts to lock all vCPUs while vCPU
creation is in progress by adding checks inside kvm_trylock_all_vcpus()
and kvm_lock_all_vcpus(). It also opportunistically drops existing manual
checks that precede or follow locking all vCPUs.

> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 65eb26a0520d8..78cc090435be5 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1363,6 +1363,9 @@ int kvm_trylock_all_vcpus(struct kvm *kvm)
>  
>  	lockdep_assert_held(&kvm->lock);
>  
> +	if (kvm_is_vcpu_creation_in_progress(kvm))
> +		return -EBUSY;
> +

[Severity: Low]
Was the manual check in arch/arm64/kvm/vgic/vgic-init.c missed during the
cleanup of redundant in-progress vCPU creation checks?

The commit message notes that existing manual checks are being dropped, but
in kvm_vgic_create(), there is still a manual check immediately following the
kvm_trylock_all_vcpus() call:

arch/arm64/kvm/vgic/vgic-init.c:kvm_vgic_create() {
        ...
        ret = kvm_trylock_all_vcpus(kvm);
        if (ret)
                return ret;

        ret = -EBUSY;
        if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus))
                goto out_unlock;
        ...
}

Because this condition is now evaluated inside the preceding
kvm_trylock_all_vcpus() call, this manual check in kvm_vgic_create() appears
to be left as dead code and will never evaluate to true.

>  	kvm_for_each_vcpu(i, vcpu, kvm)
>  		if (!mutex_trylock_nest_lock(&vcpu->mutex, &kvm->lock))
>  			goto out_unlock;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260914181223.289061-1-seanjc@google.com?part=1

  reply	other threads:[~2026-09-14 18:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 18:12 [PATCH 0/5] KVM: Serialize vCPU creation and revert vcpu_ids tracking Sean Christopherson
2026-09-14 18:12 ` [PATCH 1/5] KVM: Reject attempts to lock all vCPUs if vCPU creation is in-progress Sean Christopherson
2026-09-14 18:24   ` sashiko-bot [this message]
2026-09-14 18:12 ` [PATCH 2/5] KVM: Protect all of kvm_vm_ioctl_create_vcpu() with kvm->lock Sean Christopherson
2026-09-14 18:37   ` sashiko-bot
2026-09-14 18:12 ` [PATCH 3/5] KVM: Move check for existing vCPU ID to the top of vCPU creation Sean Christopherson
2026-09-14 18:12 ` [PATCH 4/5] Revert "KVM: Check for duplicate vcpu_id as early as possible" Sean Christopherson
2026-09-14 18:12 ` [PATCH 5/5] KVM: WARN if vCPU creation is in-progress when locking all vCPUs Sean Christopherson
2026-09-14 18:39 ` [PATCH 0/5] KVM: Serialize vCPU creation and revert vcpu_ids tracking Christian Borntraeger
2026-09-15 13:13 ` Jean-Christophe Guillain
2026-09-21 13:57 ` Thorsten Leemhuis
2026-09-21 14:00   ` Paolo Bonzini
2026-09-21 14:11     ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260914182416.4D4011F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox