Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp130037lfb; Thu, 23 Jun 2022 20:43:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t3bosQGkXVUlAvbsqqDeLTe8Fl/rmYgLUb0dq21Uw6R2ztMfwdZLkRYhLlRax4cTUVWNP2 X-Received: by 2002:a05:6402:1854:b0:435:7f6e:e553 with SMTP id v20-20020a056402185400b004357f6ee553mr14854675edy.282.1656042195662; Thu, 23 Jun 2022 20:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656042195; cv=none; d=google.com; s=arc-20160816; b=zWSnhU9Uwyw/sHsTajuqi+tqYrSGX7MXvOwtfVrv9ERPurkuX05mIPeS/z1YdisuAZ OKb646Nxq7r1ndP4r3/2mTlb+3o4TS5gfOCqdj+3t0qQhn18Qqd0OgpILE/OfqoXSg1n U37D3KlAMBIH4fNJMlyzrGkzS2m/hykptT5MbjnxU5sel3+GepaRf51OMJNyJfCrBbgW pfL+HX2CQpMZmqZ+tFcYs9oijhzKPTiLssXbAK5U6D7ptGl8/ihVeWjJGgH1po/UhTnu VfOCrwTLibWfNLoyQEX8/KlUTySOvCf8Hs2aKCQhsTcCJ/1IpDNa6dxp0utDr+STjKwl NKog== 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; bh=eWHGuAVLDnO3TktWr1bQXVjKV0ccSpoi0ctIv9w5s6g=; b=c4q9W+J2UxgJb9rJtZmXUhPT4RBppdaQ9waECTOSk5Ax2vBjM+Hye1pR8PKeo3m6UA qicHIICKUEtY3n9ykiJPDJCcg72nT8I4OLcYFhpg00Iq6j64bR3J/MQOUmV9iVFOMj/z ZlipneX/LBSf/igIkS8TD7QNIWLG22MkP7A09fDCldGqsg0Q4FCmNgxxKjvq5ZEpnO1T zsUXOh0sIwKZ5Q+AYcNzCjt1Y+xHS/m0EytxIHdKYE2Ls9+zBk8UgY8/dVr6kNBVsxIY Qq943pS78Xv4yN6D7qyaX64SpFkXyazrDh3FdM/jZ9/J9v74OCvbd3EHvILOr0L61uwN rGPw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a056402190700b0042dd469b483si2166952edz.146.2022.06.23.20.42.51; Thu, 23 Jun 2022 20:43:15 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230383AbiFXDhR (ORCPT + 99 others); Thu, 23 Jun 2022 23:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbiFXDhM (ORCPT ); Thu, 23 Jun 2022 23:37:12 -0400 Received: from out0-145.mail.aliyun.com (out0-145.mail.aliyun.com [140.205.0.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB8C753A70; Thu, 23 Jun 2022 20:37:08 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R381e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047206;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---.OBfZx3-_1656041825; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.OBfZx3-_1656041825) by smtp.aliyun-inc.com; Fri, 24 Jun 2022 11:37:05 +0800 From: "Hou Wenlong" To: kvm@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH 3/5] KVM: x86/mmu: Reduce gfn range of tlb flushing in tdp_mmu_map_handle_target_level() Date: Fri, 24 Jun 2022 11:36:59 +0800 Message-Id: <1b95b17331e6a863f8336e305df936b0d164b688.1656039275.git.houwenlong.hwl@antgroup.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 Since the children SP is zapped, the gfn range of tlb flushing should be the range covered by children SP not parent SP. Replace sp->gfn which is the base gfn of parent SP with iter->gfn and use the correct size of gfn range for children SP to reduce tlb flushing range. Signed-off-by: Hou Wenlong --- arch/x86/kvm/mmu/tdp_mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index f3a430d64975..85838ae169b8 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1075,8 +1075,8 @@ static int tdp_mmu_map_handle_target_level(struct kvm_vcpu *vcpu, return RET_PF_RETRY; else if (is_shadow_present_pte(iter->old_spte) && !is_last_spte(iter->old_spte, iter->level)) - kvm_flush_remote_tlbs_with_address(vcpu->kvm, sp->gfn, - KVM_PAGES_PER_HPAGE(iter->level + 1)); + kvm_flush_remote_tlbs_with_address(vcpu->kvm, iter->gfn, + KVM_PAGES_PER_HPAGE(iter->level)); /* * If the page fault was caused by a write but the page is write -- 2.31.1