Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1592rwn; Wed, 7 Sep 2022 11:27:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR4IAhzU6DX4Pc4QeAKYZWFfhhuDM40DDsoYnaKvibOCtWmVB2BhNhnGrmjXYgAtGdXwBB5X X-Received: by 2002:a17:906:5a64:b0:741:3586:92f with SMTP id my36-20020a1709065a6400b007413586092fmr3281213ejc.721.1662575252903; Wed, 07 Sep 2022 11:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662575252; cv=none; d=google.com; s=arc-20160816; b=iEx8Cr9kT7hiamoiI3KC6xqvQpc+LbRAUKe3dNPAX3HQqdDUiDTWFwnJqozSACDmfL giptSgNqu136QzBFxV44AvHHvr+XOWmSXjVGOVpqNaqDHepFVTnc2p3cAJk1B8UH7WQn fg35VxLPLBb9XbbOqb7Vdjyet83Nl/p82cugbUmA5Cd485/7RC6Utovio7HR6PfENHdT 7loFj4pDrCeJyFdvmvS387RoocI/vvvofRT8vfVkE7J3DHrdgZiN/VpVlhc1xejCEys4 FADZV0fu/rhbPmji9acErLuVAxZtc+kbtKAFZ0qzdG6mQbbLwc8bcLKI89AklYc56VVl HJYQ== 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=ivGeHU+iK+QNj39TtA8dNEWOqgS/ClEDHBRwSPl15bc=; b=zn6tW6ICOBWlPr1YSzkS/3J8MhBk+hjMWUx1h2goe7xMOCs0oBP3HNOItplhQP3Rk2 uVdCOTE7QSjf8+NVti1KBPxlTy4JuR2F76mzk8cm3wUhk5f009VHIiA9oPE9X5/eM8O8 gYpu/AXYbiMHzQ6Q5kssMY6Huk93vA40NILkaeziL57ab3Rc9WPw61ZFStTk3G4WCK8K XjnF89wMYWfTd1tDeuNguhbj9ad9lkF6KraXF1nKT9zz1Z91IrwEwklpmhaQej8jcawh CLABPd+hqZf3hbl1mqOFVvPU4DLGJFfh3SF24TFI1nFIualOvuakVAYahYzMwiNKIL7B V4ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OUZN0rzt; 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 a13-20020a056402168d00b00445fc3afc57si5722742edv.360.2022.09.07.11.27.08; Wed, 07 Sep 2022 11:27:32 -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=OUZN0rzt; 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 S229769AbiIGRk2 (ORCPT + 99 others); Wed, 7 Sep 2022 13:40:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbiIGRkZ (ORCPT ); Wed, 7 Sep 2022 13:40:25 -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 DB3B74AD74 for ; Wed, 7 Sep 2022 10:40:22 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id a5-20020a17090aa50500b002008eeb040eso1514237pjq.1 for ; Wed, 07 Sep 2022 10:40:22 -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=ivGeHU+iK+QNj39TtA8dNEWOqgS/ClEDHBRwSPl15bc=; b=OUZN0rztVa7Vg8juOl5Mff6QvYKUvRAXTpGQihy/IBMHctfrM0gYKRkQMc3+lk+nLO OfYh/KOYX3pt5q+l8rUE2e/waLHNUnY3D0J5xjFWjKd8UHnTYSUaAqMM5LQ4rj9i1PN4 yc+e/71TQnn/f8lD1IWCLm20uvfx8+17KqCQ63JtBKEocOHmwiKiRNKU/mhdtifZ6osA SVsPznJNvqAwWWnYz0a0OT2oFQC0hcH9qpaEAkj2ZEuqfhnPUliEhoDcUG3D23PWsc/q awLGawm9LeilIwg6pExOylRwho474qqus+30pTkKtPWWjQ6bBDpPc6HNH9XUUTfU4oqD FKTA== 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=ivGeHU+iK+QNj39TtA8dNEWOqgS/ClEDHBRwSPl15bc=; b=Qo7AWAw1sce6ppkpy00A7HXCTQqjzjzKiEvkfOVd4+5m4AJkG9OF9jofNwjoZPLCaG ItzGxEyphkBGxCUel+To5OE32Wi3GtVgFceNBrBmoR6/qhp6LVUVIuhbTI2DARmTEdgl MGeL62UxJnCA7XvTyZTA/y35xs8JEDi/o1Wi7ibFxnsM52fNVHII7zE4uXkvNXhVueXq N5zjMTuymPii2ffrYE8vOQEXE64vpeOw7XtV6rEHSSAfBrfn7vKvG9SrYavpcY0g+kjs +q/G9Qhj/FNjAQh8teYKimZnlw3L/0GfUXYVydu3a+AJFX2M9ebPJC1WXZxBGxaHJwmi Zvtg== X-Gm-Message-State: ACgBeo3wnxXvaf0dDk5zU5J+ldmETA4RDLBhtCq0XrXOBXJi4X4kthvz CWcafVU5CfEZLh8l4u2qT2Q2bw== X-Received: by 2002:a17:902:9887:b0:172:7090:6485 with SMTP id s7-20020a170902988700b0017270906485mr5133597plp.63.1662572422171; Wed, 07 Sep 2022 10:40:22 -0700 (PDT) Received: from google.com (223.103.125.34.bc.googleusercontent.com. [34.125.103.223]) by smtp.gmail.com with ESMTPSA id d9-20020a170902654900b00172ba718ed4sm7687631pln.138.2022.09.07.10.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 10:40:20 -0700 (PDT) Date: Wed, 7 Sep 2022 10:40:16 -0700 From: David Matlack To: Hou Wenlong Cc: kvm@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 6/6] KVM: x86/mmu: Use 1 as the size of gfn range for tlb flushing in FNAME(invlpg)() Message-ID: References: <8baa40dad8496abb2adb1096e0cf50dcc5f66802.1661331396.git.houwenlong.hwl@antgroup.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8baa40dad8496abb2adb1096e0cf50dcc5f66802.1661331396.git.houwenlong.hwl@antgroup.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, T_SCC_BODY_TEXT_LINE,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, Aug 24, 2022 at 05:29:23PM +0800, Hou Wenlong wrote: > Only SP with PG_LEVLE_4K level could be unsync, so the size of gfn range > must be 1. > > Signed-off-by: Hou Wenlong > --- > arch/x86/kvm/mmu/paging_tmpl.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h > index 04149c704d5b..486a3163b1e4 100644 > --- a/arch/x86/kvm/mmu/paging_tmpl.h > +++ b/arch/x86/kvm/mmu/paging_tmpl.h > @@ -937,7 +937,8 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva, hpa_t root_hpa) > > mmu_page_zap_pte(vcpu->kvm, sp, sptep, NULL); > if (is_shadow_present_pte(old_spte)) > - kvm_flush_remote_tlbs_sptep(vcpu->kvm, sptep); > + kvm_flush_remote_tlbs_gfn(vcpu->kvm, > + kvm_mmu_page_get_gfn(sp, sptep - sp->spt), 1); The third argument to kvm_flush_remote_tlbs_gfn() is the level, not the number of pages. But that aside, I don't understand why this patch is necessary. kvm_flush_remote_tlbs_sptep() should already do the right thing. > > if (!rmap_can_add(vcpu)) > break; > -- > 2.31.1 >