Message ID | 20231016165616.33442-1-nsaenz@amazon.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3606038vqb; Mon, 16 Oct 2023 10:11:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHA3gcIdW8hz9oNYi55dLgrSVev4V0j+dRHSgDdUfIu7g9sAIpB3hrcZJ2663xmhTmsiQJB X-Received: by 2002:a05:6a00:4783:b0:6b3:c72d:b01 with SMTP id dh3-20020a056a00478300b006b3c72d0b01mr9912715pfb.1.1697476296580; Mon, 16 Oct 2023 10:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697476296; cv=none; d=google.com; s=arc-20160816; b=HWOuF17br5Zm5GyT5LdfNshPLN0p7GEH4u4TAjWj8j64Io4SyOPFBgYomV9QixsRNl xNcsi/enSCIiNVeiQg9VAEvrHAljBT6zJYiQdFJIWuLEWFHrMpV60diKl/tyaXaBgkIe HHaiXLuv+JCpf7I53TCarBnrHiUN2zPbUSkt8FbnpC9GZOSCZDNNTLT0SyOr2959UkBg k/2lSpMe0DJ7chgksXjqw1aD1Tq0uxNI1KxIFb9A7/xUHG67IQvK800WSDVcV77p7QLR ciAx7ulAhaMrCmJ5v6c4pQ5iQRDJgpBzPegXGxTVMoPFa/FdOFHY3eXP6a3zSJtSxx/y AZIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=auMjyAtIvReWTmo+5WvQGZtqHXOUxJt+w4yHlsfTNX4=; fh=o9bIVV2wUUIwDU5b42SatzHBlrfwAEbC7OFgkgEyuKc=; b=dsrIibCzeDZqgdn9zJ8DEbI33/ajIO1S7tJ2oedi8da//cNAaJoDvZpE7Gtg3h5wIf LosfLVLx9xCLZiKKN1XSQIWYnZ3GWgqzfaOBNfUsYtlhq+t1GAJkLT1n7UV3bF0rKH15 Iuvcv2aM/Hk+YogamDcmlUD9xF2s1Ta27RgkVVgk+z6EMO5nEOr2zMdPEAxBuKjTSZX6 51jiXbpPAZIyjAaxjnCKEt0sMll1yixRux3JVqMrMYi1FT8bPnu5/FlN56pvSM/sCeQo SXis0LRtkefklTj+of1ixKKTAZpOGCW5zs29Qht89bLsR6/+BmMSmbe5fpUGBzJWyWnh P8vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=YX7cUdTk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id 85-20020a630058000000b005aba9cdf091si8243839pga.579.2023.10.16.10.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 10:11:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=YX7cUdTk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9E3E88068E3D; Mon, 16 Oct 2023 10:11:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233976AbjJPRLS (ORCPT <rfc822;hjfbswb@gmail.com> + 18 others); Mon, 16 Oct 2023 13:11:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233899AbjJPRLC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 16 Oct 2023 13:11:02 -0400 Received: from smtp-fw-52003.amazon.com (smtp-fw-52003.amazon.com [52.119.213.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30EE183E7; Mon, 16 Oct 2023 09:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1697475530; x=1729011530; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=auMjyAtIvReWTmo+5WvQGZtqHXOUxJt+w4yHlsfTNX4=; b=YX7cUdTkHdAJj1ncCZjtcpesO/9DeN5pkVaZUCG0Z/2QuTfEyYDpgrhj HOl2Y649umKBaH55iIP5f7nDA/sBF6G/yoRyK1O3VWhLhI3/Av8shKVid Io9YVNNqeu13MukBC7TINgi2mmQotF71qTG2STScVzPUfY1E9SLNzBpcm c=; X-IronPort-AV: E=Sophos;i="6.03,229,1694736000"; d="scan'208";a="613692706" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-m6i4x-21d8d9f4.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-52003.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 16:58:47 +0000 Received: from smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev (pdx2-ws-svc-p26-lb5-vlan2.pdx.amazon.com [10.39.38.66]) by email-inbound-relay-pdx-2a-m6i4x-21d8d9f4.us-west-2.amazon.com (Postfix) with ESMTPS id 3898B81A9E; Mon, 16 Oct 2023 16:58:45 +0000 (UTC) Received: from EX19MTAEUA001.ant.amazon.com [10.0.17.79:10860] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.17.26:2525] with esmtp (Farcaster) id 6af131f8-1777-4266-95f4-c22af1c82f27; Mon, 16 Oct 2023 16:58:44 +0000 (UTC) X-Farcaster-Flow-ID: 6af131f8-1777-4266-95f4-c22af1c82f27 Received: from EX19D004EUC001.ant.amazon.com (10.252.51.190) by EX19MTAEUA001.ant.amazon.com (10.252.50.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Mon, 16 Oct 2023 16:58:39 +0000 Received: from dev-dsk-nsaenz-1b-189b39ae.eu-west-1.amazon.com (10.13.235.138) by EX19D004EUC001.ant.amazon.com (10.252.51.190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Mon, 16 Oct 2023 16:58:34 +0000 From: Nicolas Saenz Julienne <nsaenz@amazon.com> To: <kvm@vger.kernel.org> CC: <vkuznets@redhat.com>, <seanjc@google.com>, <pbonzini@redhat.com>, <tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>, <dave.hansen@linux.intel.com>, <x86@kernel.org>, <hpa@zytor.com>, <graf@amazon.de>, <rkagan@amazon.de>, <linux-kernel@vger.kernel.org>, <anelkz@amazon.de>, Nicolas Saenz Julienne <nsaenz@amazon.com> Subject: [PATCH v2] KVM: x86: hyper-v: Don't auto-enable stimer during deserialization Date: Mon, 16 Oct 2023 16:56:19 +0000 Message-ID: <20231016165616.33442-1-nsaenz@amazon.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.13.235.138] X-ClientProxiedBy: EX19D042UWA002.ant.amazon.com (10.13.139.17) To EX19D004EUC001.ant.amazon.com (10.252.51.190) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 10:11:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779905317498833042 X-GMAIL-MSGID: 1779932904917893583 |
Series |
[v2] KVM: x86: hyper-v: Don't auto-enable stimer during deserialization
|
|
Commit Message
Nicolas Saenz Julienne
Oct. 16, 2023, 4:56 p.m. UTC
By not honoring the 'stimer->config.enable' state during stimer
deserialization we might introduce spurious timer interrupts. For
example through the following events:
- 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.
- We live migrate the VM.
- 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.
So let's not change the stimer's enable state if the MSR write comes
from user-space.
Fixes: 1f4b34f825e8 ("kvm/x86: Hyper-V SynIC timers")
Signed-off-by: Nicolas Saenz Julienne <nsaenz@amazon.com>
---
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);