Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2340935iof; Wed, 8 Jun 2022 02:56:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9rHA2yy4OyTh7Qu+jYW97ay+5koEGyCSpZZIRe0EqyLgcP/7AUK2+sK3tpCJq7u2wvuc2 X-Received: by 2002:a63:e4a:0:b0:3fc:a85f:8c08 with SMTP id 10-20020a630e4a000000b003fca85f8c08mr29265711pgo.450.1654682208555; Wed, 08 Jun 2022 02:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654682208; cv=none; d=google.com; s=arc-20160816; b=b/iWvJvzDcnCim+RLVdfcer8AvqEpDu3e1Rgd4C5EQdCczet8aPeFcB0e4DOOKl/JD pzmF5ovAFNDtgrvVmca9tXnYCNsZNifSHAkTtYHbp0jxZliK1KzT4OM0DidE8ZV6qxbt p6IEqhEYlJWod9/766EZaCu/4rWl2ZePCdZoQ9pmH5KYGFB7yw8Nw4wmjBz5ktsgpLUc d4Ea3q3p5F6Kvxu8lvPO7y+dUY7vmOHQYrTPKf1VyNmfqBWTJP/yIXnIdq6qjcuYXFKb /aaizfePXCxwoOa20q9QIbkK+S6UZ3psevuX/pdn3S84cNmXDaOXw/HLaO2kVMT+D9kO SnLw== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=ILDvM8TSVfNQxAMgKdb/afVduGh6PmUKef1ZkWVk22c=; b=wnSyS7Vw61l/DO0oV3Mzvy7MThvnPiWIYYwOEpLMuIhcti3uvzjkDkYjv3oLoyvm54 F/w1L5hFSVAeFyNPJytmth03EohQPh0P9f89Y8gagvoyfnA4sv1MpJgBdBLfoAB+uFEo Jt9waOBMb/DMe3bziAzFhf3DsNRHgNUMergwQylMQ5oode7N0/45gIHHnjpKK8q564Gi I6qBdBRQJT5Tw5PJ0nko0GKaH9hreFpmX1axPtEM5V0q2EmTQXWrG8VBAkkccCh57l1T MfwuwW86XN1cigLPcsXExkCtoknOwmGjtYKbDKtQoBsBI/oT3kuceKo/0NsrxHoowHQN YZsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IXa9Umfm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x3-20020aa79a43000000b0051c6c473a94si1005053pfj.107.2022.06.08.02.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 02:56:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IXa9Umfm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F4D6283777; Wed, 8 Jun 2022 02:26:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234580AbiFHJZh (ORCPT + 99 others); Wed, 8 Jun 2022 05:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234421AbiFHJZM (ORCPT ); Wed, 8 Jun 2022 05:25:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7593760EE for ; Wed, 8 Jun 2022 01:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654678023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ILDvM8TSVfNQxAMgKdb/afVduGh6PmUKef1ZkWVk22c=; b=IXa9Umfmyw87Fli6Npg7pqliFWIoQQ+gwHQmL14RpUo8+W7NxkKvievMDv9WWNbkaV11Z0 6hgFuY0Trna9H33sBLMu/zY6kFSHJpfnSks4hSX6xSJXf3v1R7oDR+MgWLhLc92bnX1Kh9 rxfKAuX4HVAg/Z5zbCKuFpK2j+7gJGg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-124-DDN_aOWrNC-OANtkarqC3A-1; Wed, 08 Jun 2022 04:47:00 -0400 X-MC-Unique: DDN_aOWrNC-OANtkarqC3A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DE4EC18A6522; Wed, 8 Jun 2022 08:46:59 +0000 (UTC) Received: from starship (unknown [10.40.194.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 137652026D64; Wed, 8 Jun 2022 08:46:56 +0000 (UTC) Message-ID: <2f21ab3ed17c9b2b2d4996bc04c65672b005d8a5.camel@redhat.com> Subject: Re: [PATCH v6 03/38] KVM: x86: hyper-v: Introduce TLB flush fifo From: Maxim Levitsky To: Vitaly Kuznetsov Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Date: Wed, 08 Jun 2022 11:46:56 +0300 In-Reply-To: <87bkv3mwag.fsf@redhat.com> References: <20220606083655.2014609-1-vkuznets@redhat.com> <20220606083655.2014609-4-vkuznets@redhat.com> <4be614689a902303cef1e5e1889564f965e63baa.camel@redhat.com> <87bkv3mwag.fsf@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2022-06-08 at 09:47 +0200, Vitaly Kuznetsov wrote: > Maxim Levitsky writes: > > > On Mon, 2022-06-06 at 10:36 +0200, Vitaly Kuznetsov wrote: > > > To allow flushing individual GVAs instead of always flushing the > > > whole > > > VPID a per-vCPU structure to pass the requests is needed. Use > > > standard > > > 'kfifo' to queue two types of entries: individual GVA (GFN + up to > > > 4095 > > > following GFNs in the lower 12 bits) and 'flush all'. > > > > Honestly I still don't think I understand why we can't just > > raise KVM_REQ_TLB_FLUSH_GUEST when the guest uses this interface > > to flush everthing, and then we won't need to touch the ring > > at all. > > The main reason is that we need to know what to flush: L1 or > L2. E.g. for VMX, KVM_REQ_TLB_FLUSH_GUEST is basically > > vpid_sync_context(vmx_get_current_vpid(vcpu)); > > which means that if the target vCPU transitions from L1 to L2 or vice > versa before KVM_REQ_TLB_FLUSH_GUEST gets processed we will flush the > wrong VPID. And actually the writer (the vCPU which processes the TLB > flush hypercall) is not anyhow synchronized with the reader (the vCPU > whose TLB needs to be flushed) here so we can't even know if the target > vCPU is in guest more or not. > > With the newly added KVM_REQ_HV_TLB_FLUSH, we always look at the > corresponding FIFO and process 'flush all' accordingly. In case the vCPU > switches between modes, we always raise KVM_REQ_HV_TLB_FLUSH request to > make sure we check. Note: we can't be raising KVM_REQ_TLB_FLUSH_GUEST > instead as it always means 'full tlb flush' and we certainly don't want > that. > OK, that makes sense! Let it be then. Best regards, Maxim Levitsky