Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3252647rdg; Tue, 17 Oct 2023 08:53:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMULudvv/Czzn3OOXusysES8WcoxneZ0sVFcht5yMT/qiAd2gFsSBOPtQ3+oGvoF9mwJQq X-Received: by 2002:a05:6a21:35c9:b0:17a:e2dd:ea39 with SMTP id ba9-20020a056a2135c900b0017ae2ddea39mr2209590pzc.5.1697558023862; Tue, 17 Oct 2023 08:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697558023; cv=none; d=google.com; s=arc-20160816; b=KtT9McMmg/f/6sL1j2rbjAXZ/kMhjzWA5Oel5KW8SBEMywFhhgpH1D4mQ4fZofLe16 VdtiJyW48TFm58Gw1QP4OHeG4+i14su7meRxXXpBO5KZ/rpf6PwFXT/cjY+xIUeDuTGK Hch6jz1KzMZL6PfuNQRaYoxI227SwXmzALuOUBdSr18ZF7aiiwCyiqs50FBCxFmFODsq fnCLi/Evk9+FdwbzXJniP7wExzZqO9zAHoC/zR0E/DDJWJWH8zgd3VRVGLEtW6m+CQgB RItd+AjBWC1CYXJcL+0jBNCbH6+UjcRjWm3I1Z9GBX5TEToCd08MkpnzjQoUvZiNnDBz 3XUA== 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=I7FWWa7aQS2aYUzbRv0vGUR8vIS4wtaPLaLNjNSlUB4=; fh=BiBrsvioCliaE/AIk5OfVH/KI/ndwelJdw/6TJ9q9Z8=; b=MuH0g4HYAGZTMM/PpPL4nPg3rNou++Grr7sv3DYS+V09sOcJECn6E6aH0I0YgWx7L4 KlOvcrlF+ZO5H/S5LEGqg3CgXNzUbtQaOASI+oJOuCqoX7PNdY9L2OE8PA6VFTUT1hg8 9Bmfw7obS8tjcmFtsPQwxIF+1LpYSnfse9P09Fz8rcQB+kE9OMke/g1Fizbt6zfs7AB8 Q3ej+NjZDQg0pBl/biZdD2dJxpTW457PHiKLzIhEIw5MHx1F96hhU9fJ5WULryKGODyE HiWtV3KvOWzXPLcijDow30/EiAHKszVovnCFMFd9Y15d6VtBR1dF07L1g1EADGA4BjUY rzRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=EqJWlODh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id j63-20020a638042000000b00537c6c285a0si68993pgd.167.2023.10.17.08.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 08:53:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=EqJWlODh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 9EB8A8025436; Tue, 17 Oct 2023 08:53:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344161AbjJQPxc (ORCPT + 99 others); Tue, 17 Oct 2023 11:53:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235088AbjJQPx2 (ORCPT ); Tue, 17 Oct 2023 11:53:28 -0400 Received: from smtp-fw-9106.amazon.com (smtp-fw-9106.amazon.com [207.171.188.206]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD31DF5; Tue, 17 Oct 2023 08:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1697558008; x=1729094008; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=I7FWWa7aQS2aYUzbRv0vGUR8vIS4wtaPLaLNjNSlUB4=; b=EqJWlODhGEw+Ghs6lR6J1mf0xVlEnGI+7AUrJHUwwLN84c3EeDfiVNM+ S1jPzR2+UoyGaXDxXG4uA5UltcClUFmhoNYrUbABCsDcyh3j27KkuSr7F nCLuQwa3ZiaseWFZWYkGfyzs1mseTSMMoXlAY5smt6OqzRoQpW0DmOqwx k=; X-IronPort-AV: E=Sophos;i="6.03,232,1694736000"; d="scan'208";a="678249753" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-pdx-2b-m6i4x-a893d89c.us-west-2.amazon.com) ([10.25.36.210]) by smtp-border-fw-9106.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 15:53:21 +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-2b-m6i4x-a893d89c.us-west-2.amazon.com (Postfix) with ESMTPS id 01F3040D73; Tue, 17 Oct 2023 15:53:19 +0000 (UTC) Received: from EX19MTAEUA002.ant.amazon.com [10.0.17.79:40649] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.17.120:2525] with esmtp (Farcaster) id 7d3a7ec6-0eb4-43ae-9e87-2bdb149c100e; Tue, 17 Oct 2023 15:53:18 +0000 (UTC) X-Farcaster-Flow-ID: 7d3a7ec6-0eb4-43ae-9e87-2bdb149c100e Received: from EX19D004EUC001.ant.amazon.com (10.252.51.190) by EX19MTAEUA002.ant.amazon.com (10.252.50.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Tue, 17 Oct 2023 15:53:18 +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; Tue, 17 Oct 2023 15:53:13 +0000 From: Nicolas Saenz Julienne To: CC: , , , , , , , , , , , , , Nicolas Saenz Julienne , Subject: [PATCH v3] KVM: x86: hyper-v: Don't auto-enable stimer on write from user-space Date: Tue, 17 Oct 2023 15:51:02 +0000 Message-ID: <20231017155101.40677-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: EX19D036UWB003.ant.amazon.com (10.13.139.172) 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 17 Oct 2023 08:53:41 -0700 (PDT) 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@vger.kernel.org Fixes: 1f4b34f825e8 ("kvm/x86: Hyper-V SynIC timers") Signed-off-by: Nicolas Saenz Julienne --- 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); -- 2.40.1