Re: [PATCH 2/5] KVM: add a check to ensure grow start value is nonzero
From: Paolo Bonzini
Date: Mon Nov 11 2019 - 08:49:45 EST
On 26/10/19 05:23, Zhenzhong Duan wrote:
> vcpu->halt_poll_ns could be zeroed in certain cases (e.g. by
> halt_poll_ns_shrink). If halt_poll_ns_grow_start is zero,
> vcpu->halt_poll_ns will never be larger than zero.
>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@xxxxxxxxxx>
> ---
> virt/kvm/kvm_main.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 2ca2979..1b6fe3b 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2266,6 +2266,13 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
> goto out;
>
> val *= grow;
> +
> + /*
> + * vcpu->halt_poll_ns needs a nonzero start point to grow if it's zero.
> + */
> + if (!grow_start)
> + grow_start = 1;
> +
> if (val < grow_start)
> val = grow_start;
>
>
Zeroing grow_start will simply disable halt polling. Is that a problem?
Paolo