Skip to content

Commit 313f636

Browse files
dmatlackbonzini
authored andcommitted
kvm: cap halt polling at exactly halt_poll_ns
When growing halt-polling, there is no check that the poll time exceeds the limit. It's possible for vcpu->halt_poll_ns grow once past halt_poll_ns, and stay there until a halt which takes longer than vcpu->halt_poll_ns. For example, booting a Linux guest with halt_poll_ns=11000: ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 0 (shrink 10000) ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 10000 (grow 0) ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 20000 (grow 10000) Signed-off-by: David Matlack <[email protected]> Fixes: aca6ff2 Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 9522b37 commit 313f636

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

virt/kvm/kvm_main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,9 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
19521952
else
19531953
val *= halt_poll_ns_grow;
19541954

1955+
if (val > halt_poll_ns)
1956+
val = halt_poll_ns;
1957+
19551958
vcpu->halt_poll_ns = val;
19561959
trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, val, old);
19571960
}

0 commit comments

Comments
 (0)