Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1796686pxy; Fri, 23 Apr 2021 17:57:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa/Pcz1ijTkgZQFrBnd4UPEBrtOJxp6JS1Bp4Uo4hKjRAOJfC24oWGw3zoxFLPP/8uzHeQ X-Received: by 2002:a17:906:c787:: with SMTP id cw7mr6890271ejb.157.1619225858738; Fri, 23 Apr 2021 17:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619225858; cv=none; d=google.com; s=arc-20160816; b=rWYv0Y+WnFJGCTgkWM2IOn/9EzdLc4c9fS8iSEXznYdrcEb9O6xDy2iLqigWluQ0dZ KVlGXsmP4e2vDE9YRNIXy+Z6f7H5Y1mu5P9DfLNWZmpRcjocbsuqWRua6Aun6ciGE7gE 2UovmkrB+EKfo1OtTvlSuZ+Qc9qWjhoE0kcsLcPViykNBhNkyWBSB+/bWEq4OMaNgzy7 Rb2mmIrVCty6imgEIcqjNIANJcBM5wYs8uW8sfH2rwjCzrog1x/RTWwm96Kv2WI0eBGN HWFAwXEHqGhafBexF1eQUQ7fTB0IvGWVb6Whn8M9gnDjwA5/QbMURifXrHuQn1el/1YG GQpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=R43ABUZ9/Fi53IKsY58euoL+dVYl7LoEC4YFNOGoqao=; b=Hb5zhXK5PVq6/2GvGDlQZ17lGNLggrR3xOX/zOyCu1yDYHP8XdUjrLAHz+2luPSs8O YLyd6ZumtireTo0NJHGT1MPUU+kchaDVlMsp1yIYbkCgDIpW2SsLKJnQ9JWmWkGHuv9U oVu0o4rxUDXxVGi2s69vHGeNlbl/HjOuR8DMbm0i0vG5zl9Qedx5Ucw1mJ48NUsKck8A V7JW6M7off7ehgY7B1UWudh0gZ/W7k7REkk2Onm1vUlg7QFmoYNPf6KLFNpqlqUOW5QB yMJEU3Hnn1jnDHDXAzdmw3i33KvEFChbQlP10KVowOLQ1ZDRFIhk+ePitywLM/srVazr PYjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gXjNOqK1; 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 z2si7053320edd.567.2021.04.23.17.57.15; Fri, 23 Apr 2021 17:57:38 -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=gXjNOqK1; 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 S236103AbhDXA4y (ORCPT + 99 others); Fri, 23 Apr 2021 20:56:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244198AbhDXAzQ (ORCPT ); Fri, 23 Apr 2021 20:55:16 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84FA4C061243 for ; Fri, 23 Apr 2021 17:48:36 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id s34-20020a252d620000b02904e34d3a48abso26210839ybe.13 for ; Fri, 23 Apr 2021 17:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=R43ABUZ9/Fi53IKsY58euoL+dVYl7LoEC4YFNOGoqao=; b=gXjNOqK1L7vM4ncBy6xohX2vvBi4KwcgSkBOQa8L7aBPQfp16D1WJmCV/jdeojHOb3 +DSylbvxS8KAgWscv86gsTLDKq3gjRiTy4ihusv4PEreJ42QGVxpCDxewRnMBBTJuBAy HFzGOqeuT3p+ktZJ6FljmDgd6X3hNhSgFY692LBEoiE4EsJmf2ceP9tNJ5CbIbmqHM9n KkFsE7lyGMYLmTWoYraea9HlpCHVi4V0P2ptJBwM9pft6TPEpT4kUgdOXrLEJJV/bIVA uYGiCZ1YyGIVzV5bglKD3vQhbGUIPZdbEMjV1hh4fEZgbJvuQwLIeQ/K6gRcPp5SLPPx 1dvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=R43ABUZ9/Fi53IKsY58euoL+dVYl7LoEC4YFNOGoqao=; b=UKxe5L0Awk/XJ2vKGZI3IJEX/tnfJqJy8CT55OZxnBpabOkp1PFd2QWwKvoskNDS7t SsSTKKoA5y9J4GTcZxopHlLMsyk4/0RBMAau0xVi73fe31usdzcCF87cv/7YIOCSk6wH DC8XMtiwvbmUD5Kw2AqVCGUVukFW7c/iPCCGQjZe0XEulISgXaSdP0yjBpp+kgBYev/A ls6mPrCjiqRwXD93B18RJ1EqQcdwDgcR52Ef5ZbiJzw8H8Su6hvsCwUMOvun6TE1QxlP jSiW5U6EyDyk5P3A/FbVOGF8JYofB94h8X0/7uJJp+sBvTlDA/DCUuCPLGQLVwLmEfQh zotA== X-Gm-Message-State: AOAM533s2W1KN0X/EbnVufB6L+heJg22ISfkHdqMgFzUbApecNR2sKU/ LY1set8l3UkX/UFxNv3xoQ4TXzRAiVw= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:ad52:3246:e190:f070]) (user=seanjc job=sendgmr) by 2002:a25:840c:: with SMTP id u12mr9012245ybk.345.1619225315623; Fri, 23 Apr 2021 17:48:35 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 23 Apr 2021 17:46:45 -0700 In-Reply-To: <20210424004645.3950558-1-seanjc@google.com> Message-Id: <20210424004645.3950558-44-seanjc@google.com> Mime-Version: 1.0 References: <20210424004645.3950558-1-seanjc@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH 43/43] KVM: x86: Drop pointless @reset_roots from kvm_init_mmu() From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; - } - if (mmu_is_nested(vcpu)) init_kvm_nested_mmu(vcpu); else if (tdp_enabled) @@ -4829,7 +4820,7 @@ kvm_mmu_calc_root_page_role(struct kvm_vcpu *vcpu) void kvm_mmu_reset_context(struct kvm_vcpu *vcpu) { kvm_mmu_unload(vcpu); - kvm_init_mmu(vcpu, true); + kvm_init_mmu(vcpu); } EXPORT_SYMBOL_GPL(kvm_mmu_reset_context); diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 540d43ba2cf4..a0b48a8f32ed 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -406,7 +406,7 @@ static int nested_svm_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, vcpu->arch.cr3 = cr3; kvm_register_mark_available(vcpu, VCPU_EXREG_CR3); - kvm_init_mmu(vcpu, false); + kvm_init_mmu(vcpu); return 0; } diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 9dcdf158a405..3a5b86932a5e 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -1137,7 +1137,7 @@ static int nested_vmx_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, bool ne vcpu->arch.cr3 = cr3; kvm_register_mark_available(vcpu, VCPU_EXREG_CR3); - kvm_init_mmu(vcpu, false); + kvm_init_mmu(vcpu); return 0; } -- 2.31.1.498.g6c1eba8ee3d-goog