Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp379742rwe; Wed, 24 Aug 2022 02:35:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR4nwYeMvVxVIrn4MmhXoYtCGRPxYBvzimd2UHb85bWMAZM0lWAFqgWjnwF9XVneqk672pVw X-Received: by 2002:a05:6402:510a:b0:43d:ab25:7d68 with SMTP id m10-20020a056402510a00b0043dab257d68mr6739342edd.102.1661333752685; Wed, 24 Aug 2022 02:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661333752; cv=none; d=google.com; s=arc-20160816; b=obO4phzHYT+dhpGr4FsZRmfT96Y7nC1sOEM3nA1ZvUSKPXNMDY9UwRZMiGN9B4oqqc 4G1q2IYYyJYrj8nNJ2mZUhj9egRpexJ+9jidaMMnNVjs6ft5vhORS0N6LXYWMgszr4R8 xJVsT/2lrPkCpiJW5oB/VWeG1WVqBptlfF4SCoxDtv3APEmLQEKMG1fM/112VhGf4RJo sMWlQjkEPL/7r2tR9vhe9yyMDPnhJidYTwt2ZQRN4kd4WRgBVDLWP2/6ll2cScCuHHSl 81UhvjcQnbVHQKpBhPzHkR1U0i60h23CgnLrTWF9oAewAvz1PhT1rlLWbKc1PywyC7yE evAA== 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=QKzRRRI6ECb/aCWKs42wJb7bWdhsjVCxnEG1KGvuWbo=; b=b3OgQHo8pkjIOKdIiC6I8vfYOfb3KkmhoNI7yFwiX5QZduVsW614fjgRSErptYp84c CE5xIAIs1O+LbLyIsJo43xpakcnsinmibB5qqtvX7OOkzuyDRoRisvoYSJyo2VidnY04 j5oxRG8DKDlSwcD8XpY4uOgIKMQoi87KfOQ/xVqPsoq2duA96W5s/2zBJL8aBGeDCFxU i+mFtF6/sTV9yeP2qsApPhALk/nA9NTNLr6WljJTaJZ65UZBKtDuoZxub1OU7QBwhiH1 0+AaDp3OGdfZ4davp1u04QDuli+BoyVUn3YpohA81FMvHsix/yoHpiKE37YP+E3+XW/p BN/A== 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 qf18-20020a1709077f1200b00732f74749d1si1602079ejc.911.2022.08.24.02.35.26; Wed, 24 Aug 2022 02:35:52 -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 S236375AbiHXJaI (ORCPT + 99 others); Wed, 24 Aug 2022 05:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236262AbiHXJ3v (ORCPT ); Wed, 24 Aug 2022 05:29:51 -0400 Received: from out0-138.mail.aliyun.com (out0-138.mail.aliyun.com [140.205.0.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0116571BD7; Wed, 24 Aug 2022 02:29:49 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R351e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047199;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---.P-kQI16_1661333366; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.P-kQI16_1661333366) by smtp.aliyun-inc.com; Wed, 24 Aug 2022 17:29:26 +0800 From: "Hou Wenlong" To: kvm@vger.kernel.org Cc: David Matlack , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] KVM: x86/mmu: Reduce gfn range of tlb flushing in tdp_mmu_map_handle_target_level() Date: Wed, 24 Aug 2022 17:29:20 +0800 Message-Id: <85f889ce6eb6b330d86fa74c6e84d22d98ddc2cf.1661331396.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 bf2ccf9debca..08b7932122ec 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1071,8 +1071,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