diff options
| author | Wanpeng Li <wanpengli@tencent.com> | 2025-11-10 11:32:27 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-01-02 12:57:21 +0100 |
| commit | 2c3719a04b04a251782e77618d4255907ea4bbc8 (patch) | |
| tree | 60f4082751c9f2fa7d44ef9b6b16bf4807bcd71b /virt | |
| parent | 691ff7e13f0d825b91bc50cb4ceb00af2178e9ec (diff) | |
| download | linux-2c3719a04b04a251782e77618d4255907ea4bbc8.tar.gz linux-2c3719a04b04a251782e77618d4255907ea4bbc8.tar.bz2 linux-2c3719a04b04a251782e77618d4255907ea4bbc8.zip | |
KVM: Fix last_boosted_vcpu index assignment bug
commit 32bd348be3fa07b26c5ea6b818a161c142dcc2f2 upstream.
In kvm_vcpu_on_spin(), the loop counter 'i' is incorrectly written to
last_boosted_vcpu instead of the actual vCPU index 'idx'. This causes
last_boosted_vcpu to store the loop iteration count rather than the
vCPU index, leading to incorrect round-robin behavior in subsequent
directed yield operations.
Fix this by using 'idx' instead of 'i' in the assignment.
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20251110033232.12538-7-kernellwp@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'virt')
| -rw-r--r-- | virt/kvm/kvm_main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 01ea4f8351a6..7fea6ba91c1e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4026,7 +4026,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me, bool yield_to_kernel_mode) yielded = kvm_vcpu_yield_to(vcpu); if (yielded > 0) { - WRITE_ONCE(kvm->last_boosted_vcpu, i); + WRITE_ONCE(kvm->last_boosted_vcpu, idx); break; } else if (yielded < 0 && !--try) { break; |
