Skip to content

Commit 32bd348

Browse files
Wanpeng Libonzini
authored andcommitted
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>
1 parent ac3fd01 commit 32bd348

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

virt/kvm/kvm_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4026,7 +4026,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me, bool yield_to_kernel_mode)
40264026

40274027
yielded = kvm_vcpu_yield_to(vcpu);
40284028
if (yielded > 0) {
4029-
WRITE_ONCE(kvm->last_boosted_vcpu, i);
4029+
WRITE_ONCE(kvm->last_boosted_vcpu, idx);
40304030
break;
40314031
} else if (yielded < 0 && !--try) {
40324032
break;

0 commit comments

Comments
 (0)