Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp134542lfb; Thu, 23 Jun 2022 20:55:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v+VBDbTpNYOrTHq9g9Ve2fCnW5EUIAxRLVxIOThLTUUYpypMYWSVWBYd1G3l22dTXhHV5S X-Received: by 2002:a17:906:7a56:b0:722:df69:3bd5 with SMTP id i22-20020a1709067a5600b00722df693bd5mr10909842ejo.581.1656042945516; Thu, 23 Jun 2022 20:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656042945; cv=none; d=google.com; s=arc-20160816; b=y1y8ZE8h06obv+W8N7GajHn0wcorvDB6UDncrTu4gvfEutkvPhQ/Q8JzpPTZJAGVTg tOwQu8BzTfBgMOtbgjQRAk66L5pDMMe5+7kTUSQ24+YZYrWYFWa/K5TtrGo8WoK8lKYu c4elLpU5UaKgWmoRjDSN0jqDPpFFGC8/nVhGVQLHEa7DINNDRmx28UM0C67g41/HoDZZ ypLm1+q430koFkUeR/SHojOMd9H6OeXhJKBBnDag8SmpLPGAl3kE7cMGLKO0StMmXutV 41mqGTSvpIe2gWs8AfJd7GP2+FEJGcA2nS6zYl/2nj1lrl7nGuMDx6/tzTCjdAlaljIL HVfg== 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=wZKnx0EJXJG8nzTxbdkTLE1yI7tNDLGK81k4pp/gBak=; b=APR3wm7mCnBCvrPMSgE3lcvGgD+YVAVEAtCYu4sTq/dN4XnMVUYO8w1u4QJdJJ2cNX S+JMyP0LP8N2B1ArkJjeUSnOGmxPpQ0AZ8omNAl5+za13uv4wKZEULz3AtHPmKzV83uC Z2SbwOVf0FlN9Kl0xJGR5kocUDoPhDErqfgpMp2rqONakp4R37E+qm2paqhcuskSUsRN Ef6Q2lCcaPkoVhxClo3cOvV9R6v/go+zmnqmOisgITYXxtM2sI8/ASiFrXzkMacNZo0E MD2u6R12JOD32WiQLEP9zHMmBxGY2PhFVk1ocs58ZXIWHXDg2evG9PfsFc8c1652bwj1 wTpA== 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 zm13-20020a170906994d00b00722eeab7122si1005227ejb.407.2022.06.23.20.55.21; Thu, 23 Jun 2022 20:55:45 -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 S230495AbiFXDhT (ORCPT + 99 others); Thu, 23 Jun 2022 23:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbiFXDhM (ORCPT ); Thu, 23 Jun 2022 23:37:12 -0400 Received: from out0-150.mail.aliyun.com (out0-150.mail.aliyun.com [140.205.0.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBF9C53A6F; Thu, 23 Jun 2022 20:37:07 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047208;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---.OBhfXaM_1656041822; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.OBhfXaM_1656041822) by smtp.aliyun-inc.com; Fri, 24 Jun 2022 11:37:03 +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" , Lan Tianyu , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] KVM: x86/mmu: Fix wrong gfn range of tlb flushing in validate_direct_spte() Date: Fri, 24 Jun 2022 11:36:57 +0800 Message-Id: <66dec44acfd5f4c47451c7f4be516edb8fb326a2.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,RCVD_IN_DNSWL_NONE, 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 The spte pointing to the children SP is dropped, so the whole gfn range covered by the children SP should be flushed. Fixes: c3134ce240eed ("KVM: Replace old tlb flush function with new one to flush a specified range.") Signed-off-by: Hou Wenlong --- arch/x86/kvm/mmu/mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 79c6a821ea0d..b8a1f5b46b9d 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -2333,7 +2333,8 @@ static void validate_direct_spte(struct kvm_vcpu *vcpu, u64 *sptep, return; drop_parent_pte(child, sptep); - kvm_flush_remote_tlbs_with_address(vcpu->kvm, child->gfn, 1); + kvm_flush_remote_tlbs_with_address(vcpu->kvm, child->gfn, + KVM_PAGES_PER_HPAGE(child->role.level + 1)); } } -- 2.31.1