Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1021049pxj; Thu, 27 May 2021 18:08:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUMUMYztm/8i0D9+VsgeZDQjeUEf191a1smKNgBvs/rBhTDcXkKC04gqFVznBmiAafCwtV X-Received: by 2002:a17:907:961e:: with SMTP id gb30mr6841212ejc.58.1622164087626; Thu, 27 May 2021 18:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622164087; cv=none; d=google.com; s=arc-20160816; b=yjFqtBR34ueApN/hPa+/2GtVjlEhk42yQ9L5jU0qUcoHCkbf9Xin7LKqYSxVmDSNtp bD54DWwB7ejpzuppQ0a1jfo/yxzkN/KxiwB9mtVLKmE3iGIjdAIvGCf0DIDWKMJ5QsP3 z0wZqpIgEXRHYLfDBsRp98MzvTtPwWV2sqIL9pvQDl0Lwg3zyaqb6U58zu/x5vi9v3y0 uIJTxnyyMHYaD1xYszxNyrCIw76aLlVSU8XAJoae5NkSTqlLhKwrzrIMOJ2hmupHHxZ3 34nqBtviT/v2WOzhF+lCRaL1vgFZnJtSIWp9oiEahmgk79j05/KcNVxrbcMLgzMxQ7I8 FxlA== 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:to:from:date:dkim-signature; bh=RE1qcP7vRIDhMC+4p2UKC8eKad09zvQ8yhQM/ragHj8=; b=VECMJlabDrJeJjbMB48OCP1fcaUbsBYU0WsT3te1qlBu8ykLmnaNrwtMnbH7Fmyps3 8Yq/PSzxey8UWrZB5/SXNjhyHKFEiHJ/Dohm5ZjXlp4w9fBJyFt73yMd3Mn1JRvspVzb gXqlABO0IU9B2dWs1UMtmbfhZ5A2vPjTMVGDt40ulxe3/ZpGX1GlXsM1cqMfvfOz0nqg yeDJS2AzVoXkuJZxFqNjc1n7Gj8aM4FpreApkJSmHWnmfu11/Z1cW2r7pjDyBFIL33zg ONswR7rMV1TP0oGnK6CTCgT14JFDlpfY2w5vJoNbLTiB2KBeV95wMI2d+GwXazQEKS2L N4jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qLKb8Jgi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg8si4093185ejb.592.2021.05.27.18.07.44; Thu, 27 May 2021 18:08:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qLKb8Jgi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234364AbhE0TNQ (ORCPT + 99 others); Thu, 27 May 2021 15:13:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234301AbhE0TNQ (ORCPT ); Thu, 27 May 2021 15:13:16 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFB4BC061760 for ; Thu, 27 May 2021 12:11:41 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 27so675954pgy.3 for ; Thu, 27 May 2021 12:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RE1qcP7vRIDhMC+4p2UKC8eKad09zvQ8yhQM/ragHj8=; b=qLKb8JgiNEKyopizIPmcyaNgma9muoqIc9lRad1LH0VqqoQ5mjTChUbotc4AbndIvg mX5GqBuqdwLcm5G9Ni6/RmGDxvhj3EbZzwFDCx2Xbik4+QoU+RVj+Nk3PD9CjvgJ5r8i sKsldL31c5wfm2dJM+R/vkzG3qdkkL+56LSwt0mbAKGYVpJgVco8hn7Dnv4emuwvvnLX 7GDOceUUV1ZMZAzgINptnSRgrQ7oSoOk2obk1mOmkorFerFPSK3S4FO5v+qYygM/EOEO 9Ma4SS2/KRZ0A299gNY4XensWaQyHVUlMvL2ttjCQS89DS6ngIVgchzPpjKnRmGb9giG RHUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RE1qcP7vRIDhMC+4p2UKC8eKad09zvQ8yhQM/ragHj8=; b=Npux/nfaDtvCNXaVwdwR6vL3x9p2j/j8JErJampMOzYffklFTlQ3z6jE0ER8BSE8SS jCXUuGqSxuIRL+Lha+89Vz1JFy/KfNLzEWz9uJ7OcU4txsC6atEC/Fkfh4UfoPca4FMp o4hAhmYYIg9KZ7EgE4in1IwUKXyufSVtyk0DeOcfB385dFbNvrCXBmJqj+imAm/Tgq/o +6yW/rWooPREh+R80NhD05uZp6WxmU3LKZZu1ZtOwitwinFnZeYVpmVmKUW7iiJNYqlp RDSh1GHiy5CFGlgdoLPNCPMvwXrgVuMu4H6Kn6u5CPdxltjPwgTATy6MAfeLdIhCM51c 5aOQ== X-Gm-Message-State: AOAM5309ZlhZh8T7nx0Y2BAMOAX+QNnc1ubCYekASi/gxFVN3ujecv7W HXmbawU1nL26ZZwvi+FoiODaDQ== X-Received: by 2002:a63:1b0b:: with SMTP id b11mr5135456pgb.410.1622142701157; Thu, 27 May 2021 12:11:41 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id f18sm2423360pjh.55.2021.05.27.12.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 12:11:40 -0700 (PDT) Date: Thu, 27 May 2021 19:11:36 +0000 From: Sean Christopherson To: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 43/43] KVM: x86: Drop pointless @reset_roots from kvm_init_mmu() Message-ID: References: <20210424004645.3950558-1-seanjc@google.com> <20210424004645.3950558-44-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210424004645.3950558-44-seanjc@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 23, 2021, Sean Christopherson wrote: > Remove the @reset_roots param from kvm_init_mmu(), the one user, > kvm_mmu_reset_context() has already unloaded the MMU and thus freed and > invalidated all roots. This also happens to be why the reset_roots=true > paths doesn't leak roots; they're already invalid. > > No functional change intended. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/mmu.h | 2 +- > arch/x86/kvm/mmu/mmu.c | 13 ++----------- > arch/x86/kvm/svm/nested.c | 2 +- > arch/x86/kvm/vmx/nested.c | 2 +- > 4 files changed, 5 insertions(+), 14 deletions(-) > > diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h > index 88d0ed5225a4..63b49725fb24 100644 > --- a/arch/x86/kvm/mmu.h > +++ b/arch/x86/kvm/mmu.h > @@ -65,7 +65,7 @@ void kvm_mmu_set_ept_masks(bool has_ad_bits, bool has_exec_only); > void > reset_shadow_zero_bits_mask(struct kvm_vcpu *vcpu, struct kvm_mmu *context); > > -void kvm_init_mmu(struct kvm_vcpu *vcpu, bool reset_roots); > +void kvm_init_mmu(struct kvm_vcpu *vcpu); > void kvm_init_shadow_npt_mmu(struct kvm_vcpu *vcpu, u32 cr0, u32 cr4, u32 efer, > gpa_t nested_cr3); > void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly, > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 930ac8a7e7c9..ff3e200b32dd 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -4793,17 +4793,8 @@ static void init_kvm_nested_mmu(struct kvm_vcpu *vcpu) > update_last_nonleaf_level(vcpu, g_context); > } > > -void kvm_init_mmu(struct kvm_vcpu *vcpu, bool reset_roots) > +void kvm_init_mmu(struct kvm_vcpu *vcpu) > { > - if (reset_roots) { > - uint i; > - > - vcpu->arch.mmu->root_hpa = INVALID_PAGE; > - > - for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++) > - vcpu->arch.mmu->prev_roots[i] = KVM_MMU_ROOT_INFO_INVALID; Egad! This is wrong. mmu->root_hpa is guaranteed to be INVALID_PAGE, but the prev_roots are not! I'll drop this patch and do cleanup of this code in a separate series. > - } > - > if (mmu_is_nested(vcpu)) > init_kvm_nested_mmu(vcpu); > else if (tdp_enabled)