Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2386388rdg; Mon, 16 Oct 2023 02:53:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE4oLyNOer+2ZMFNxrTJ+1lNfCY8g3CAwgUwxhbTsSkM37sPpetuHYlBclHKhw7yxjuJXZf X-Received: by 2002:a17:902:d488:b0:1c8:9832:827f with SMTP id c8-20020a170902d48800b001c89832827fmr22602509plg.20.1697449991515; Mon, 16 Oct 2023 02:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697449991; cv=none; d=google.com; s=arc-20160816; b=geVZLb2v2x2kdzAIVBCHt/NkogyvghUUuSi+1gNCNbtVzmTTeVp0G8bVax6XCnVxY4 6X3lW2pNPNQjYHSzWCE2U192pMk6Szw8Y7a3wtbdyZprRXhev1RN5Dcx6i4lE8YQsZLO RU4X3RaXcpDHOgLrgN/Iinse8DvJOHGkA1UAGgx3Mfjl1SWEc1i/yqwnmu49rv5jGuz7 O2SrpDcyZ4yL2LKxwTGy0B7PjbHRclhWqd6MmTkT89xaqL954Y66YdxQn/XHtHCcexLJ MJ2d01jtBZURoOu4mYSdTHwtaK8DijmCz/sae/OIwWukgvlTEEfNiY5wsNimganfcF12 y2Ww== 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=ButIDiCErNxytD4vraOH8UFxC3RVH0U5V+UvXPw1a7g=; fh=cbrnfej6n378P8uwLXfnJsTsOQkap1sIIK+NjSDLE94=; b=SiKQvhT12jMY5MGb2S/K/gY89r+JNBJ8Xo02zXqIhvsYQrwRyy4XHSu4SiAN33Jrc4 HuJa/4ufjBtppnWZMfnHhXVE7+l79UHZC3+QQcpiHNfMlMS3TKja9L0CtaOcRx/i1xjk G+Z+Tnc4TB4ARUMk29ozAB3qVp8kTrqK9HEVL+7yZR8CogRX6akkAQ+HvwKEh8T0Icir szfqsB/Ud1gtValRdQrYp41zIxWc5bA/AdGUJv3nZ266wcj52vR0Ev57djU/pc4Wc7O5 oVGYSyVN033I59cOQdWXzAbjxtvKFrJi5jGp2z2CpQhzSek4GRZ+DCApoAWWUOiq3Zot En/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="Ssiejja/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id n11-20020a170902968b00b001c9c89fd36dsi9961553plp.203.2023.10.16.02.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 02:53:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="Ssiejja/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 70BEA80B908A; Mon, 16 Oct 2023 02:53:09 -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 S231220AbjJPJwx (ORCPT + 99 others); Mon, 16 Oct 2023 05:52:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbjJPJww (ORCPT ); Mon, 16 Oct 2023 05:52:52 -0400 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FB64EB; Mon, 16 Oct 2023 02:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1697449971; x=1728985971; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ButIDiCErNxytD4vraOH8UFxC3RVH0U5V+UvXPw1a7g=; b=Ssiejja/hK38qWRE9SUEsp772LG8ICprq7eIsIphbjiqmYRc6eM7uGIg fqcXkPLKHKOdm9hNoKOg1DfgKXEZG06Wj3Uz9+fbLsgnDU/IyW2uwHYf0 kw+tlTziA9nbb/bjX3sCs1bRdv1H51AsVYgVCoXDjvykENq2sQ6yRYovt 4=; X-IronPort-AV: E=Sophos;i="6.03,229,1694736000"; d="scan'208";a="362070535" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-m6i4x-529f0975.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:52:37 +0000 Received: from EX19D004EUC001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-iad-1e-m6i4x-529f0975.us-east-1.amazon.com (Postfix) with ESMTPS id 0DFED487FA; Mon, 16 Oct 2023 09:52:33 +0000 (UTC) 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 09:52:29 +0000 From: Nicolas Saenz Julienne To: CC: , , , , , , , , , , , , Nicolas Saenz Julienne Subject: [PATCH] KVM: x86: hyper-v: Don't auto-enable stimer during deserialization Date: Mon, 16 Oct 2023 09:52:17 +0000 Message-ID: <20231016095217.37574-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: EX19D037UWC003.ant.amazon.com (10.13.139.231) To EX19D004EUC001.ant.amazon.com (10.252.51.190) X-Spam-Status: No, score=-0.9 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 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: 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 02:53:09 -0700 (PDT) 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 --- arch/x86/kvm/hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 7c2dac6824e2..9f1deb6aa131 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -729,7 +729,7 @@ static int stimer_set_count(struct kvm_vcpu_hv_stimer *stimer, u64 count, stimer->count = count; if (stimer->count == 0) stimer->config.enable = 0; - else if (stimer->config.auto_enable) + else if (stimer->config.auto_enable && !host) stimer->config.enable = 1; if (stimer->config.enable) -- 2.40.1