Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp632320rwl; Thu, 5 Jan 2023 02:15:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXuC/XzWgzPlBoneUAs9Lmio6JYkQVD9/3+wKUAWLn2CXYdZxMd2Y4ObXZ+4nkzlDW4yeh8W X-Received: by 2002:a17:90a:5891:b0:226:620b:6ae5 with SMTP id j17-20020a17090a589100b00226620b6ae5mr17009897pji.22.1672913751248; Thu, 05 Jan 2023 02:15:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672913751; cv=none; d=google.com; s=arc-20160816; b=S7Fx0ZFV88AhI88ZGVWl81U59Vij7NE037+4DksnVTBcBW4B0xD6C+HMbwX6Ws+o6C FOb/8Nwz0PM24cOCnI4JvGQBDjdUWxb0unijkQ/oaHcL8ADtkztZGkl2cL2PYthxlDAq h5bk2U4LtMNkha6JDChLzwKt7G+Adtou/gl12/E6/AUtwfKo6w1m0lwSzmo6lp8PmwrB ut8A8BLFQud66Ab1JrW5EOlLGem1rW8UKRwsuQUBCDfVGssBNYWplJ3I6hwEB4Vgs4Db /Qi3WjZyf3U+ZrbGwdyotlpsxp5awdA3mIEsAildEg5iSG5yY6EX9N0n16DXqmagq8X/ Hmxg== 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=5qbcS2kAh7qKqu1Tcd+kRAYagIvCht+cBr4HMCNf5SE=; b=gTqU4SUuA+1QpKNP1vIeC5Y8kK/NM7+0RAn7s266l6usDwEKDqU2xV2OeYEUiwR2f4 NwffztnEW/b3dUOoHWuHjqWv/8LwW7NKmk7shFW/Yv60vFnjEFpQ82Qkq8gh8B7OPvE/ vcz6iuLN6JD+qOlhUH1PhVlveemC9ZXBcVfLTdB2eid/ebiCa58JHDEfiIQ5JQ2angYv xw3yl3syTfmG3Oyzs4WU/H7aFKuH3Col69b9aLgkX0XsjsYI0qbroSQINj69dd0n2Q9B 89sO6tQvPh2kJboUjYjNurFIPOQsAoZxd4aqD4EL4xlJg6V6DFCImNcUj/GmAL8RLkQG J/ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dxbrMS6o; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oc9-20020a17090b1c0900b00219de90bdc5si1653514pjb.20.2023.01.05.02.15.42; Thu, 05 Jan 2023 02:15:51 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=dxbrMS6o; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232271AbjAEJ6D (ORCPT + 55 others); Thu, 5 Jan 2023 04:58:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231836AbjAEJ5p (ORCPT ); Thu, 5 Jan 2023 04:57:45 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A2994FD5B; Thu, 5 Jan 2023 01:57:44 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id z7so19256172pfq.13; Thu, 05 Jan 2023 01:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5qbcS2kAh7qKqu1Tcd+kRAYagIvCht+cBr4HMCNf5SE=; b=dxbrMS6ocOOad8B62fNsSZS9ih/clJTefmEBMIJ7VgmiirhlnHxz0NsoB+pMRrMjj/ 44P8V6Knx4dXLAF5qyytPrhqM0yMWEekP23utHYQDrhFgqoOCBgocIkda0sYV+KInfxE MODKKso97BdYrspU+q4YJ+/SsyK2vvxteqmQWTayuf/msOByn0VMp7wbQfzLEG06Jl6b RO4Z6G+fLarlApjENWWkCsRowsiq1nrnoN8XRrMNXaFtZM6cNpfjlp9UnC1T8KRmVR8G V8dWLkIjwMajfgY/nhQalmYYHgda+dkHihT1nTEOXnjFpsSRyyWluTzgoSIL9fFAei17 lKYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5qbcS2kAh7qKqu1Tcd+kRAYagIvCht+cBr4HMCNf5SE=; b=NRNttAOQ5iW87M1w4RL2/GugRhUpYjzKSy32RvEWXGb3Ct7xqaGlCbiceuuCBw/AyS QbVimiJwy/gaRiBYePLHFnEYdBGE4v9JwiJCx6otyOJS8CtgL3PsOvKBQ4i+otKdS08w 3ul8UYRCcX10MQUIM2Ev+q0Eobt2Z8j1TnmsfylYgSLhCywUOwV8gI3GslYPceh0D9tR ejqr0aH+ikewwlaQzzvZf4NuUzB+0rFDoQFCgNbzdCjZ79ENXozF0nNnam9H6CbjxI5f Nj3ALAk+RbSGsnqXkXZSfxliiJIjidLBAkAg+QTMgciOMmwjU6a8MkEaBiU1YMGA+bxa soDw== X-Gm-Message-State: AFqh2krspgOG3tSIDzXvbPQ6NdOwbopqbxGzPHmMkR7W4WvZcrGZHVXh IISEKyweR0zyrHhG8gqAggwXOGRo9Kk= X-Received: by 2002:a62:7bcd:0:b0:581:1c64:92bc with SMTP id w196-20020a627bcd000000b005811c6492bcmr38273815pfc.3.1672912663320; Thu, 05 Jan 2023 01:57:43 -0800 (PST) Received: from localhost ([198.11.176.14]) by smtp.gmail.com with ESMTPSA id i2-20020aa796e2000000b00581172f7456sm19549248pfq.56.2023.01.05.01.57.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jan 2023 01:57:42 -0800 (PST) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Lai Jiangshan , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org Subject: [PATCH 2/7] kvm: x86/mmu: Use kvm_mmu_invalidate_gva() in kvm_mmu_invpcid_gva() Date: Thu, 5 Jan 2023 17:58:43 +0800 Message-Id: <20230105095848.6061-3-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20230105095848.6061-1-jiangshanlai@gmail.com> References: <20230105095848.6061-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 From: Lai Jiangshan Use kvm_mmu_invalidate_gva() instead open calls to mmu->invlpg(). No functional change intended. Signed-off-by: Lai Jiangshan --- arch/x86/kvm/mmu/mmu.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 90339b71bd56..b0e7ac6d4e88 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5742,27 +5742,20 @@ EXPORT_SYMBOL_GPL(kvm_mmu_invlpg); void kvm_mmu_invpcid_gva(struct kvm_vcpu *vcpu, gva_t gva, unsigned long pcid) { struct kvm_mmu *mmu = vcpu->arch.mmu; - bool tlb_flush = false; + ulong roots_to_invalidate = 0; uint i; - if (pcid == kvm_get_active_pcid(vcpu)) { - if (mmu->invlpg) - mmu->invlpg(vcpu, gva, mmu->root.hpa); - tlb_flush = true; - } + if (pcid == kvm_get_active_pcid(vcpu)) + roots_to_invalidate |= KVM_MMU_ROOT_CURRENT; for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++) { if (VALID_PAGE(mmu->prev_roots[i].hpa) && - pcid == kvm_get_pcid(vcpu, mmu->prev_roots[i].pgd)) { - if (mmu->invlpg) - mmu->invlpg(vcpu, gva, mmu->prev_roots[i].hpa); - tlb_flush = true; - } + pcid == kvm_get_pcid(vcpu, mmu->prev_roots[i].pgd)) + roots_to_invalidate |= KVM_MMU_ROOT_PREVIOUS(i); } - if (tlb_flush) - static_call(kvm_x86_flush_tlb_gva)(vcpu, gva); - + if (roots_to_invalidate) + kvm_mmu_invalidate_gva(vcpu, mmu, gva, roots_to_invalidate); ++vcpu->stat.invlpg; /* -- 2.19.1.6.gb485710b