KVM: Avoid re-reading kvm->max_halt_poll_ns during halt-polling
authorDavid Matlack <dmatlack@google.com>
Thu, 17 Nov 2022 00:16:56 +0000 (16:16 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 17 Nov 2022 15:49:14 +0000 (10:49 -0500)
commit175d5dc79dcb58d18e11192656eefa27abb3fd33
tree06b7980324a976c97ea31b9660b5b6b57bea7b27
parent97b6847ac10ba753849207e20df74a7c0ea03343
KVM: Avoid re-reading kvm->max_halt_poll_ns during halt-polling

Avoid re-reading kvm->max_halt_poll_ns multiple times during
halt-polling except when it is explicitly useful, e.g. to check if the
max time changed across a halt. kvm->max_halt_poll_ns can be changed at
any time by userspace via KVM_CAP_HALT_POLL.

This bug is unlikely to cause any serious side-effects. In the worst
case one halt polls for shorter or longer than it should, and then is
fixed up on the next halt. Furthmore, this is still possible since
kvm->max_halt_poll_ns are not synchronized with halts.

Fixes: acd05785e48c ("kvm: add capability for halt polling")
Signed-off-by: David Matlack <dmatlack@google.com>
Message-Id: <20221117001657.1067231-3-dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c