Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5687913rwb; Wed, 21 Sep 2022 10:57:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Xcj0gg0Qxs6TN7ofa3jgcMnDOtJoql5H7wC19JfzTZI4vNOLk27CuogeH3k/qSEXG4k3D X-Received: by 2002:a17:907:72c8:b0:77f:e3f1:db2a with SMTP id du8-20020a17090772c800b0077fe3f1db2amr22017930ejc.198.1663783042238; Wed, 21 Sep 2022 10:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663783042; cv=none; d=google.com; s=arc-20160816; b=cRHWuIz/crE/W60r2UOY/36gooBm/hP788NbmfAcqFenFNpq0XCuqMcmutKYzaiLgV WQGKi4yw0SmWzLM1tqsFIrYZV7fjuJAhacVSnCFWrT9cFFhuSZH9SkTbW8MjdjCPfGJW dzTyZR4lXyDXGGUT5wptAQ3egUIpmhPeRusrW5PP5zOFcR4cPDR0GjzYDyXP3Uc/59JT 9RqRKzmDTBcywU0Of38ydksqb+YPH6GJqHsx6DZD42JpJLk9DZQe2ixuI3JHd/YPnHlb eCQQzYqWFnOJVJRoJSOTlsLOBzCxDVPPCRMDMNt3LhV+gn9fQCPuY+BP4byfB4V+GuTU 0Qzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XOa4aurffGm0tCv2VayZ1RuwmmJV/QHgF+XodULO/e4=; b=u29T/nyb+DkqapCIaCsissziAfia13Bz0puEiwtNT5wiJCjKv7beI7sLsWJFGDrmwn OoYSNP/1xS7d2tyKupgP8/ify5Rqud4UrZ+eK+ObRBwmLlMyhghDsrlcQdje7A6DH+H9 2VdahtyvM5lHCy4v6JjGzzsFIF/FWUvpJEisT/SxDpVfIC958UVdHRCm1hk7Xk/gOryj ycAh/li2q2Sf8NH1RCvP33Lk7aA2mK+vV4yS8D1BYyoDk9Ro5CX+9ChtjYKfgSjiKhx+ pSPrBl44QVIxDA0UJtoapK1AaMsVIeIMMkABhWF+37gMFjSYz4Ne/dnpkYhnAq6XR6Rx iW1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=M1thJhs3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w3-20020a056402128300b004542d6cbc47si2675138edv.521.2022.09.21.10.56.56; Wed, 21 Sep 2022 10:57:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=M1thJhs3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbiIURB1 (ORCPT + 99 others); Wed, 21 Sep 2022 13:01:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230403AbiIURAj (ORCPT ); Wed, 21 Sep 2022 13:00:39 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 268836E889 for ; Wed, 21 Sep 2022 10:00:38 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id a5-20020a17090aa50500b002008eeb040eso3819111pjq.1 for ; Wed, 21 Sep 2022 10:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=XOa4aurffGm0tCv2VayZ1RuwmmJV/QHgF+XodULO/e4=; b=M1thJhs3crptdcTk9AppPMG4GQTA+ygwGlHofw5z+VfZQZzJzJRuWgcYw7wA6BJReQ 4c/ax5qtQesPHD6rKMfjnzVcGgn05tLTCPaGLf2qaezxvI3hVaSXXZBXutYZfYAemGji Lak86dQ6DnlPGIc4MIUIt33+x4D/WKGPUgbvID95muAzoiMdPwhfqQF1JG5juAe7r+c5 3u2gyKd2+b0NVJRe6jPFyRG2Xz+KqDIjqnzG0F9H0s/2LMRE8Yho3PZPz5HvL6PP3wt5 xQN3OgVAAk+5nCKTImUjnWiN2LIiGq7DTqD7lCWE5IzK/gjwCQmLySJmIqpT6yWMJrlL q9ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=XOa4aurffGm0tCv2VayZ1RuwmmJV/QHgF+XodULO/e4=; b=VBThwYCeAzl6UNeclnvq1gykoc07EhXgJBEJ9gnRQu/CKzGiWRT9OILlcSPo9o7CW4 HRmXzTmRm8SR73rRUMFUZ/nkAEo+z7JqRYraNc9VwDrZHW0Yx6E8icYb/2Kw7Qv/9Fvs 3p9oE4jvjDHyKUpwYTly39n3gv41F67HJeSpBOvj3HJh6erHrHkcGEVKcvlaDdCro7X9 9RKtvvyc9ySL7B7JJloY/HFdUEG72aEqysOQKXOFv9W9El+MjZ+qdMgENp60MhTJUwQ9 GAFWrT0gax4VboWf2NJranstF2Bk1RxdgRXadwquch20lq39IcQqbI9RhBAI1zrDmW6G yg2g== X-Gm-Message-State: ACrzQf0brHhi4xvK7IN/+CXL4fLcgDGhm5/97ISYUExFMb4dgvxz+04L 5w4LcorqloHwrzGfmmTH3mCabg== X-Received: by 2002:a17:90a:9f07:b0:203:5a3:1d25 with SMTP id n7-20020a17090a9f0700b0020305a31d25mr10962125pjp.74.1663779637571; Wed, 21 Sep 2022 10:00:37 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id i9-20020a17090332c900b00176b63535ccsm2291536plr.193.2022.09.21.10.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 10:00:37 -0700 (PDT) Date: Wed, 21 Sep 2022 17:00:33 +0000 From: Sean Christopherson To: Vitaly Kuznetsov Cc: kvm@vger.kernel.org, Paolo Bonzini , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 05/39] KVM: x86: hyper-v: Handle HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST{,EX} calls gently Message-ID: References: <20220921152436.3673454-1-vkuznets@redhat.com> <20220921152436.3673454-6-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220921152436.3673454-6-vkuznets@redhat.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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, Sep 21, 2022, Vitaly Kuznetsov wrote: > void kvm_hv_vcpu_flush_tlb(struct kvm_vcpu *vcpu) > { > struct kvm_vcpu_hv_tlb_flush_fifo *tlb_flush_fifo; > struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); > + u64 entries[KVM_HV_TLB_FLUSH_FIFO_SIZE]; > + int i, j, count; > + gva_t gva; > > - kvm_vcpu_flush_tlb_guest(vcpu); > - > - if (!hv_vcpu) > + if (!tdp_enabled || !hv_vcpu) { > + kvm_vcpu_flush_tlb_guest(vcpu); > return; > + } > > tlb_flush_fifo = &hv_vcpu->tlb_flush_fifo; > > + count = kfifo_out(&tlb_flush_fifo->entries, entries, KVM_HV_TLB_FLUSH_FIFO_SIZE); > + > + for (i = 0; i < count; i++) { > + if (entries[i] == KVM_HV_TLB_FLUSHALL_ENTRY) > + goto out_flush_all; > + > + /* > + * Lower 12 bits of 'address' encode the number of additional > + * pages to flush. > + */ > + gva = entries[i] & PAGE_MASK; > + for (j = 0; j < (entries[i] & ~PAGE_MASK) + 1; j++) > + static_call(kvm_x86_flush_tlb_gva)(vcpu, gva + j * PAGE_SIZE); > + > + ++vcpu->stat.tlb_flush; > + } > + return; > + > +out_flush_all: > + kvm_vcpu_flush_tlb_guest(vcpu); > kfifo_reset_out(&tlb_flush_fifo->entries); > } If kvm_vcpu_flush_tlb_guest() is done as a fallback, then this can use -ENOSPC, which again I like from a documentation perspective. out_flush_all: kfifo_reset_out(&tlb_flush_fifo->entries); return -ENOSPC;