[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87bkcx6xv3.fsf@redhat.com>
Date: Tue, 17 Oct 2023 18:02:24 +0200
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Nicolas Saenz Julienne <nsaenz@...zon.com>, kvm@...r.kernel.org
Cc: seanjc@...gle.com, pbonzini@...hat.com, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com,
x86@...nel.org, hpa@...or.com, graf@...zon.de, rkagan@...zon.de,
linux-kernel@...r.kernel.org, anelkz@...zon.de,
Nicolas Saenz Julienne <nsaenz@...zon.com>,
stable@...r.kernel.org
Subject: Re: [PATCH v3] KVM: x86: hyper-v: Don't auto-enable stimer on write
from user-space
Nicolas Saenz Julienne <nsaenz@...zon.com> writes:
> Don't apply the stimer's counter side effects when modifying its
> value from user-space, as this may trigger spurious interrupts.
>
> For example:
> - The stimer is configured in auto-enable mode.
> - The stimer's count is set and the timer enabled.
> - The stimer expires, an interrupt is injected.
> - The VM is live migrated.
> - The stimer config and count are deserialized, auto-enable is ON, the
> stimer is re-enabled.
> - The stimer expires right away, and injects an unwarranted interrupt.
>
> Cc: stable@...r.kernel.org
> Fixes: 1f4b34f825e8 ("kvm/x86: Hyper-V SynIC timers")
> Signed-off-by: Nicolas Saenz Julienne <nsaenz@...zon.com>
> ---
>
> Changes since v2:
> - reword commit message/subject.
>
> Changes since v1:
> - Cover all 'stimer->config.enable' updates.
>
> arch/x86/kvm/hyperv.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index 7c2dac6824e2..238afd7335e4 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -727,10 +727,12 @@ static int stimer_set_count(struct kvm_vcpu_hv_stimer *stimer, u64 count,
>
> stimer_cleanup(stimer);
> stimer->count = count;
> - if (stimer->count == 0)
> - stimer->config.enable = 0;
> - else if (stimer->config.auto_enable)
> - stimer->config.enable = 1;
> + if (!host) {
> + if (stimer->count == 0)
> + stimer->config.enable = 0;
> + else if (stimer->config.auto_enable)
> + stimer->config.enable = 1;
> + }
>
> if (stimer->config.enable)
> stimer_mark_pending(stimer, false);
LGTM, thanks!
Reviewed-by: Vitaly Kuznetsov <vkuznets@...hat.com>
--
Vitaly
Powered by blists - more mailing lists