Message ID | 20231108111806.92604-9-nsaenz@amazon.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp842944vqo; Wed, 8 Nov 2023 03:21:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHpbLGk14uVdPKDNuoqVvzZSp44eFHqqurOLaN8pcK0Y6h6SrTKbKa0aqNTufFImd/sOH5 X-Received: by 2002:a05:6a00:21c9:b0:6be:5367:211b with SMTP id t9-20020a056a0021c900b006be5367211bmr1391067pfj.3.1699442517452; Wed, 08 Nov 2023 03:21:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699442517; cv=none; d=google.com; s=arc-20160816; b=Q5mbW3D7DwEB7okmVwIgtdtwByMYCtviUJvksVy6BN4soitsWhDWAZw+09ZO9X+HKU I/Z5QCYZIXqcwYIlcWNyHZwB0T+6AdKC8URBc4gHanFL2+L2W+v0PWLinbqIyTTq5Why mepBVPOB/RiMuHMy2Rsm0UlMMdNKONZiSDYU0fPJg9BoQ0Y5V44uS23sK0jaahIaEQOc Bx/bZau2ssWBDhKAXm22g7dRUwCVsrNrdtLV4HLPLPa2lXAHbMjrlLeEM4Zk9yPxp/6I VlpQBFCethrrD+vRQ4XuKysivH+AwgRwt49ZRClTFzZqaX70fL5WNs8B3lZZHdqkmW28 Y/ow== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cyTCynOmMb0cQQa0wX5d7cLulbacT3tvj9NSCTRwhHI=; fh=Qdq7NqGm5JR9LpctBpXjoRI38Lb2mCk6xy26GEDp1Bg=; b=eyUQ2Yzs3ZOZjSQlcA1A0fKruLqf14weAtCcRUCjK7EYwGtqBflGvc9nIFq2uj412B u2DZY2jVTkwQ+9q1P4ftZtZGHslHIKst5ccd1a1uKDAP+8NQl+sYesi97al+10vi3LlY Yy6Dbz5nxfPPTJ8uifrsPNe18rEUroYerdIvGpdCuEN9NYYKMImMyD/8B5kVzx1rLGrn UxjpXQQ5+mxdWJzHpCMcA6Xd3nnr03emcG6fTTWTx0LZIgHPO5flt1yBZ6WcBx7/wf6/ pI5AdJhxCf0JhuozS3vlaIIwwIR0WwIkdGqeVDpksfGxUA8Ogm8wUocs+upjNFzlWzPN F4mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=uoXdxXqx; 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id t25-20020aa79399000000b006bf2e5f0841si11751400pfe.393.2023.11.08.03.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:21:57 -0800 (PST) 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=uoXdxXqx; 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 CBC228084632; Wed, 8 Nov 2023 03:20:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344648AbjKHLUE (ORCPT <rfc822;jaysivo@gmail.com> + 32 others); Wed, 8 Nov 2023 06:20:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344628AbjKHLTz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 8 Nov 2023 06:19:55 -0500 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0FA91BEB; Wed, 8 Nov 2023 03:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1699442393; x=1730978393; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cyTCynOmMb0cQQa0wX5d7cLulbacT3tvj9NSCTRwhHI=; b=uoXdxXqxTJ+aXNNZAiSwqC9CpZyqE0rCCsnQYVD3oz+KZfPUCxjMgi4v DkfMnOq7N8xKvScGfVrJBv3yt4HvH5QadPHsir17js6YhAczT4/E+p9rz oaY9CCXZCcpgJ/iaZplwBa90b6O131+qYzCpi7o2Pu+rtUv12nNOFpB2p Q=; X-IronPort-AV: E=Sophos;i="6.03,286,1694736000"; d="scan'208";a="366812308" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-m6i4x-f05d30a1.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; 08 Nov 2023 11:19:52 +0000 Received: from smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev (iad7-ws-svc-p70-lb3-vlan3.iad.amazon.com [10.32.235.38]) by email-inbound-relay-iad-1d-m6i4x-f05d30a1.us-east-1.amazon.com (Postfix) with ESMTPS id 23B2F80D5F; Wed, 8 Nov 2023 11:19:48 +0000 (UTC) Received: from EX19MTAEUA002.ant.amazon.com [10.0.10.100:19113] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.43.105:2525] with esmtp (Farcaster) id fbe08b9c-13d3-4e3e-a014-4f60b4421048; Wed, 8 Nov 2023 11:19:48 +0000 (UTC) X-Farcaster-Flow-ID: fbe08b9c-13d3-4e3e-a014-4f60b4421048 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.39; Wed, 8 Nov 2023 11:19:47 +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.39; Wed, 8 Nov 2023 11:19:43 +0000 From: Nicolas Saenz Julienne <nsaenz@amazon.com> To: <kvm@vger.kernel.org> CC: <linux-kernel@vger.kernel.org>, <linux-hyperv@vger.kernel.org>, <pbonzini@redhat.com>, <seanjc@google.com>, <vkuznets@redhat.com>, <anelkz@amazon.com>, <graf@amazon.com>, <dwmw@amazon.co.uk>, <jgowans@amazon.com>, <corbert@lwn.net>, <kys@microsoft.com>, <haiyangz@microsoft.com>, <decui@microsoft.com>, <x86@kernel.org>, <linux-doc@vger.kernel.org>, Nicolas Saenz Julienne <nsaenz@amazon.com> Subject: [RFC 08/33] KVM: x86: Don't use hv_timer if CAP_HYPERV_VSM enabled Date: Wed, 8 Nov 2023 11:17:41 +0000 Message-ID: <20231108111806.92604-9-nsaenz@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231108111806.92604-1-nsaenz@amazon.com> References: <20231108111806.92604-1-nsaenz@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.13.235.138] X-ClientProxiedBy: EX19D033UWC002.ant.amazon.com (10.13.139.196) To EX19D004EUC001.ant.amazon.com (10.252.51.190) 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 (lipwig.vger.email [0.0.0.0]); Wed, 08 Nov 2023 03:20:40 -0800 (PST) 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,T_SCC_BODY_TEXT_LINE, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781994636865797204 X-GMAIL-MSGID: 1781994636865797204 |
Series |
KVM: x86: hyperv: Introduce VSM support
|
|
Commit Message
Nicolas Saenz Julienne
Nov. 8, 2023, 11:17 a.m. UTC
VSM's VTLs are modeled by using a distinct vCPU per VTL. While one VTL
is running the rest of vCPUs are left idle. This doesn't play well with
the approach of tracking emulated timer expiration by using the VMX
preemption timer. Inactive VTL's timers are still meant to run and
inject interrupts regardless of their runstate.
Signed-off-by: Nicolas Saenz Julienne <nsaenz@amazon.com>
---
arch/x86/kvm/lapic.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Comments
On Wed, 2023-11-08 at 11:17 +0000, Nicolas Saenz Julienne wrote: > VSM's VTLs are modeled by using a distinct vCPU per VTL. While one VTL > is running the rest of vCPUs are left idle. This doesn't play well with > the approach of tracking emulated timer expiration by using the VMX > preemption timer. Inactive VTL's timers are still meant to run and > inject interrupts regardless of their runstate. > > Signed-off-by: Nicolas Saenz Julienne <nsaenz@amazon.com> > --- > arch/x86/kvm/lapic.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index f55d216cb2a0..8cc75b24381b 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -152,9 +152,10 @@ static bool kvm_can_post_timer_interrupt(struct kvm_vcpu *vcpu) > > bool kvm_can_use_hv_timer(struct kvm_vcpu *vcpu) > { > - return kvm_x86_ops.set_hv_timer > - && !(kvm_mwait_in_guest(vcpu->kvm) || > - kvm_can_post_timer_interrupt(vcpu)); > + return kvm_x86_ops.set_hv_timer && > + !(kvm_mwait_in_guest(vcpu->kvm) || > + kvm_can_post_timer_interrupt(vcpu)) && > + !(kvm_hv_vsm_enabled(vcpu->kvm)); > } This has to be fixed this way or another. One idea is to introduce new MP state (KVM_MP_STATE_HALTED_USERSPACE), which will be set on vCPUs that belong to inactive VTLs, and then userspace will do KVM_RUN which will block as if it were for halted state but as soon as vCPU becomes unhalted, it will return to the userspace instead of running again. If we go with the approach of using polling on the inactive VTL's vcpus, then we can switch to a software timer just before we start polling. Also note that AVIC/APICv and their IOMMU's have to be treated the same way. It is disabled during vCPU blocking due to the same reasons of vCPU not being assigned a physical CPU. Currently it happens to work because you disable APIC accelerated map, which in turn disables (inhibits) the APICv/AVIC. Once again if we go with the approach of polling, we should ensure that polling does more or less the same things as kvm_vcpu_block does (we should try to share as much code as possible as well). Best regards, Maxim Levitsky > > static bool kvm_use_posted_timer_interrupt(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index f55d216cb2a0..8cc75b24381b 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -152,9 +152,10 @@ static bool kvm_can_post_timer_interrupt(struct kvm_vcpu *vcpu) bool kvm_can_use_hv_timer(struct kvm_vcpu *vcpu) { - return kvm_x86_ops.set_hv_timer - && !(kvm_mwait_in_guest(vcpu->kvm) || - kvm_can_post_timer_interrupt(vcpu)); + return kvm_x86_ops.set_hv_timer && + !(kvm_mwait_in_guest(vcpu->kvm) || + kvm_can_post_timer_interrupt(vcpu)) && + !(kvm_hv_vsm_enabled(vcpu->kvm)); } static bool kvm_use_posted_timer_interrupt(struct kvm_vcpu *vcpu)