Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: Fix last_boosted_vcpu index assignment bug

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>

authored by

Wanpeng Li and committed by
Paolo Bonzini
32bd348b ac3fd01e

+1 -1
+1 -1
virt/kvm/kvm_main.c
··· 4026 4026 4027 4027 yielded = kvm_vcpu_yield_to(vcpu); 4028 4028 if (yielded > 0) { 4029 - WRITE_ONCE(kvm->last_boosted_vcpu, i); 4029 + WRITE_ONCE(kvm->last_boosted_vcpu, idx); 4030 4030 break; 4031 4031 } else if (yielded < 0 && !--try) { 4032 4032 break;