Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1164210rdb; Fri, 1 Dec 2023 08:32:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEcnOEzfWQphaaqeyabG+33Ux5aLCbqLyYd9zy3ydZzWYjRT9jt1WuLvYe/KpLN2PIyoPDG X-Received: by 2002:a17:903:2351:b0:1d0:5933:beac with SMTP id c17-20020a170903235100b001d05933beacmr1855422plh.22.1701448350415; Fri, 01 Dec 2023 08:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701448350; cv=none; d=google.com; s=arc-20160816; b=sZoxCngUYOLNtBgEaYgWILrpWxmC+dX6aoi0kuhvwvD2xeH+VqXTs9XNqjnxTZ0eVf PS15Tg6Fv87k3oVc/Gc1wN+xgO2QXxI7idR10gIaCnge0ZEk3uviX+m1zSc9d3dAIjdU V04mXwCckFAlLqtD9PnYQuK09e0kl5LeXBcL/f3QJPIGt8r/9/KHg4CVVS5Szpjz1iGT TAsJNlo/OXHS96kgIosiaddm/auq9QF3bijNTx1zYEQx5Sdeor8CXYxi+M/u+soGwA/S uDwtUxOg9++wB8EMgQrETQBkMugYlKf1j3Ow8Y2V+IqlDOeWPAqCzwstobWNbitIgrjx 5F2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:cc:to:from:message-id :date:content-transfer-encoding:mime-version:subject:dkim-signature; bh=ZaGh4NUVdUvAF2JRuqkM6YevRneIAqjnG/wz+NwAVWM=; fh=ZFkF3piPwx+igkI8r+2fjg4UsVRsKqr5aSKk5MIraRw=; b=uwbA61YpzV4RUwiH30Bc2UIqdXSLpHO3HMm3wfU/tcrPjsG0a48/HHTemnByX3cdzk fmWSI1ixVONw19qU5RIIn9JUvo3kqN5X3wJ2JXre37Q9gvI2CLEl66/die8vO1ofIx0r x/Zhmnq1MG3gju5mWK1iVjVTTWr3zBesxFxVcCCj4xqN4R+H/tcDZKTjCzr8chNTEL6s bjjI2hyA+q7Q108N0QQt+rbNh3hklCKShLxiyRvqLaY5sNu295tsNrO+U1jeZcVjbBxs CADNG0+VUWixvA4r3CMdBmVv8l2gDxs6dckMpUsrr75XyNIdpCw7+4n13W0Sys8jN+ri njfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=UOoPmUbu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id w16-20020a170902e89000b001c9ce2b6b9esi3528794plg.262.2023.12.01.08.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 08:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=UOoPmUbu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 8D3F080BD4EF; Fri, 1 Dec 2023 08:32:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229640AbjLAQcJ (ORCPT + 99 others); Fri, 1 Dec 2023 11:32:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbjLAQcD (ORCPT ); Fri, 1 Dec 2023 11:32:03 -0500 Received: from smtp-fw-52004.amazon.com (smtp-fw-52004.amazon.com [52.119.213.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7377B1B4; Fri, 1 Dec 2023 08:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1701448329; x=1732984329; h=mime-version:content-transfer-encoding:date:message-id: from:to:cc:references:in-reply-to:subject; bh=ZaGh4NUVdUvAF2JRuqkM6YevRneIAqjnG/wz+NwAVWM=; b=UOoPmUburc8PU00UFJ3fXA5vkXYOiRoa9pyXoMRxXPUcDCSoe5Cp9yKY QlZ/9XWPF+LELoo9/4rQYuwBcPOrpw/hDmL3SNph6h7VRRvwu+11RJdYu 3NiN4v0SljxXjbu/+vu0hnMeBtRNv+fPPkFzPRo+TegCU/lwc7dJRkB9M Y=; X-IronPort-AV: E=Sophos;i="6.04,242,1695686400"; d="scan'208";a="169494766" Subject: Re: [RFC 06/33] KVM: x86: hyper-v: Introduce VTL awareness to Hyper-V's PV-IPIs Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-pdx-2a-m6i4x-1cca8d67.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-52004.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2023 16:32:06 +0000 Received: from smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev (pdx2-ws-svc-p26-lb5-vlan3.pdx.amazon.com [10.39.38.70]) by email-inbound-relay-pdx-2a-m6i4x-1cca8d67.us-west-2.amazon.com (Postfix) with ESMTPS id D2299818A5; Fri, 1 Dec 2023 16:32:03 +0000 (UTC) Received: from EX19MTAEUC001.ant.amazon.com [10.0.43.254:13312] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.26.183:2525] with esmtp (Farcaster) id e5b27342-2f4b-43fa-bd5c-99ff36690156; Fri, 1 Dec 2023 16:32:02 +0000 (UTC) X-Farcaster-Flow-ID: e5b27342-2f4b-43fa-bd5c-99ff36690156 Received: from EX19D004EUC001.ant.amazon.com (10.252.51.190) by EX19MTAEUC001.ant.amazon.com (10.252.51.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 1 Dec 2023 16:32:02 +0000 Received: from localhost (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.40; Fri, 1 Dec 2023 16:31:57 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Date: Fri, 1 Dec 2023 16:31:54 +0000 Message-ID: From: Nicolas Saenz Julienne To: Maxim Levitsky , CC: , , , , , , , , , , , , , , X-Mailer: aerc 0.15.2-182-g389d89a9362e-dirty References: <20231108111806.92604-1-nsaenz@amazon.com> <20231108111806.92604-7-nsaenz@amazon.com> <9249b4b84f7b84da2ea21fbbbabf35f22e5d9f2f.camel@redhat.com> In-Reply-To: <9249b4b84f7b84da2ea21fbbbabf35f22e5d9f2f.camel@redhat.com> X-Originating-IP: [10.13.235.138] X-ClientProxiedBy: EX19D031UWA002.ant.amazon.com (10.13.139.96) 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,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 howler.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 (howler.vger.email [0.0.0.0]); Fri, 01 Dec 2023 08:32:25 -0800 (PST) On Tue Nov 28, 2023 at 7:14 AM UTC, Maxim Levitsky wrote: > On Wed, 2023-11-08 at 11:17 +0000, Nicolas Saenz Julienne wrote: > > HVCALL_SEND_IPI and HVCALL_SEND_IPI_EX allow targeting specific a > > specific VTL. Honour the requests. > > > > Signed-off-by: Nicolas Saenz Julienne > > --- > > arch/x86/kvm/hyperv.c | 24 +++++++++++++++++------- > > arch/x86/kvm/trace.h | 20 ++++++++++++-------- > > include/asm-generic/hyperv-tlfs.h | 6 ++++-- > > 3 files changed, 33 insertions(+), 17 deletions(-) > > > > diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c > > index d4b1b53ea63d..2cf430f6ddd8 100644 > > --- a/arch/x86/kvm/hyperv.c > > +++ b/arch/x86/kvm/hyperv.c > > @@ -2230,7 +2230,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu= , struct kvm_hv_hcall *hc) > > } > > > > static void kvm_hv_send_ipi_to_many(struct kvm *kvm, u32 vector, > > - u64 *sparse_banks, u64 valid_bank_mas= k) > > + u64 *sparse_banks, u64 valid_bank_mas= k, int vtl) > > { > > struct kvm_lapic_irq irq =3D { > > .delivery_mode =3D APIC_DM_FIXED, > > @@ -2245,6 +2245,9 @@ static void kvm_hv_send_ipi_to_many(struct kvm *k= vm, u32 vector, > > valid_bank_mask, sparse_banks= )) > > continue; > > > > + if (kvm_hv_get_active_vtl(vcpu) !=3D vtl) > > + continue; > > Do I understand correctly that this is a temporary limitation? > In other words, can a vCPU running in VTL1 send an IPI to a vCPU running = VTL0, > forcing the target vCPU to do async switch to VTL1? > I think that this is possible. The diff is missing some context. See this simplified implementation (when all_cpus is set in the parent function): static void kvm_hv_send_ipi_to_many(struct kvm *kvm, u32 vector, int vtl) { [...] kvm_for_each_vcpu(i, vcpu, kvm) { if (kvm_hv_get_active_vtl(vcpu) !=3D vtl) continue; kvm_apic_set_irq(vcpu, &irq, NULL); } } With the one vCPU per VTL approach, kvm_for_each_vcpu() will iterate over *all* vCPUs regardless of their VTL. The IPI is targetted at a specific VTL, hence the need to filter. VTL1 -> VTL0 IPIs are supported and happen (although they are extremely rare). Nicolas