Message ID | 20230509135143.1721-1-yan.y.zhao@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2949559vqo; Tue, 9 May 2023 07:59:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6oEqB3B5yLBl9e/0eJFh6sSAcukSKBprb/EOMwWhm43YMFmFzuNCUCwB7URoKvgWECaf1Z X-Received: by 2002:a05:6a00:1805:b0:63c:56f5:5053 with SMTP id y5-20020a056a00180500b0063c56f55053mr24991789pfa.13.1683644398907; Tue, 09 May 2023 07:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683644398; cv=none; d=google.com; s=arc-20160816; b=AOT3ps2kERmCzpXxyH0TqiRLG19KwdqspOgiymICucGjBSa0ZBnuYS2oF6UKpqP3cH A2W8GiL2/Rdkfq3XhiDvyofjv5Ym+9mARaKeuCrqseWkJJPKLAjXQ8ov/ZtDMpzWKpAx 7TAgleyVUrHQhk0dGe64qD6CBbRCsqNKgBLm0/31kjkkQW/ecPTqTTFVFVOAXc9Jk6FP UJ1ppyxtXkPSAT4qo19nHKzYSYKWjib06ULEm+IjEMJb66PALjDCoGHV4kKdg5LjYYYP Xg6dr9JSJEPc/0r5+TIDX6PhnvbF4Cm0nGQTcBMm2Aib9W8rDurENKPVbUbnWedKqSfA dBfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=8voDmQxkJibB3Vb7otzlMpKXA7c89Xww8wWd9HKkFTM=; b=NgoDxZM/7BRpC4yuul2AlfaNgrTW4KUjJVwO7h1B8pfMX30Ll461a7JqJeRzOcCQ0V zb/PS6fM+lNoCAXRVLpqcKaiQxHmW4i9YpXMC6lmdZKBjSCK7+346WmK5zWBBN41j5PS UGd05+ALJF23RymnQ1RUeTX3D+6nqjUkrc13SonTB2oXBPvIEUZGzFBKhJtWfZOruJpA fPf6AY3CijERthGnHo7dU1ElrkqhF1rsUiUT4AeDcw/VcBPr8p/By4r0+kA3BcU5kA+n 4qGOQRcTZYqtEOkkVCjCywf6YYTiATxzy6ziaZpaULKqoPw/DCYDh5B5R9kUY4hb5q2S pTPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GhfN7zDZ; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g10-20020aa796aa000000b0064643d41e25si2525613pfk.387.2023.05.09.07.59.45; Tue, 09 May 2023 07:59:58 -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=@intel.com header.s=Intel header.b=GhfN7zDZ; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235815AbjEIOQo (ORCPT <rfc822;baris.duru.linux@gmail.com> + 99 others); Tue, 9 May 2023 10:16:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235608AbjEIOQn (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 9 May 2023 10:16:43 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F87530D6; Tue, 9 May 2023 07:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683641802; x=1715177802; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=CFYbkufDbUcvakbzS3v4+C+2rYDU17Dc/1vzYarICt0=; b=GhfN7zDZG0Q8lRzwApqCz3NqHUDv6C01Qa+6ZQrdSXeO0q+55no/sm01 32sMiBIm9f8JKojvWevsaHYBkto21MuycZ8zCE6nckKRtk9EqhI2Bh/VK xaaBWq9kFCL2Tsvw7Bdu1lKaIplZ9LPDM2lpV7XxgQBS4u9Zb9DUz95XK x6YVWMHvJHUtKAvM1KqbH9rGBu8sIw96Cx1HfHAv7VVhg2SUkfUB//Sxv NhM5DBAMXaF36QB/Ex4J+GPD6xyVFwgui8Ot3ncCCoDSi2OYfM2yAPocx SYb6UL6mb3lDRaXn8L0y/a2F2XaJqI977rKI4sAeVfN6ekQBDpDYm4KNI A==; X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="349971876" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="349971876" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 07:16:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="945298429" X-IronPort-AV: E=Sophos;i="5.99,262,1677571200"; d="scan'208";a="945298429" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 07:16:40 -0700 From: Yan Zhao <yan.y.zhao@intel.com> To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, Yan Zhao <yan.y.zhao@intel.com> Subject: [PATCH v2 3/6] KVM: x86/mmu: only zap EPT when guest MTRR changes Date: Tue, 9 May 2023 21:51:43 +0800 Message-Id: <20230509135143.1721-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230509134825.1523-1-yan.y.zhao@intel.com> References: <20230509134825.1523-1-yan.y.zhao@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765429108922926878?= X-GMAIL-MSGID: =?utf-8?q?1765429108922926878?= |
Series |
KVM: x86/mmu: refine memtype related mmu zap
|
|
Commit Message
Yan Zhao
May 9, 2023, 1:51 p.m. UTC
Call new helper kvm_zap_gfn_for_memtype() to skip zap mmu if EPT is not
enabled.
When guest MTRR changes and it's desired to zap TDP entries to remove
stale mappings, only do it when EPT is enabled, because only memory type
of EPT leaf is affected by guest MTRR with noncoherent DMA present.
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
---
arch/x86/kvm/mtrr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, May 09, 2023 at 09:51:43PM +0800, Yan Zhao wrote: >Call new helper kvm_zap_gfn_for_memtype() to skip zap mmu if EPT is not >enabled. > >When guest MTRR changes and it's desired to zap TDP entries to remove >stale mappings, only do it when EPT is enabled, because only memory type >of EPT leaf is affected by guest MTRR with noncoherent DMA present. > >Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> >--- > arch/x86/kvm/mtrr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c >index 9fac1ec03463..62ebb9978156 100644 >--- a/arch/x86/kvm/mtrr.c >+++ b/arch/x86/kvm/mtrr.c >@@ -330,7 +330,7 @@ static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) > var_mtrr_range(&mtrr_state->var_ranges[index], &start, &end); > } > >- kvm_zap_gfn_range(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); >+ kvm_zap_gfn_for_memtype(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); I am wondering if the check of shadow_memtype_mask (now inside the kvm_zap_gfn_for_memtype()) should be moved to the beginning of update_mtrr(). Because if EPT isn't enabled, computing @start/@end is useless and can be skipped. > } > > static bool var_mtrr_range_is_valid(struct kvm_mtrr_range *range) >-- >2.17.1 >
On Wed, May 10, 2023 at 01:39:25PM +0800, Chao Gao wrote: > On Tue, May 09, 2023 at 09:51:43PM +0800, Yan Zhao wrote: > >Call new helper kvm_zap_gfn_for_memtype() to skip zap mmu if EPT is not > >enabled. > > > >When guest MTRR changes and it's desired to zap TDP entries to remove > >stale mappings, only do it when EPT is enabled, because only memory type > >of EPT leaf is affected by guest MTRR with noncoherent DMA present. > > > >Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> > >--- > > arch/x86/kvm/mtrr.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > >diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c > >index 9fac1ec03463..62ebb9978156 100644 > >--- a/arch/x86/kvm/mtrr.c > >+++ b/arch/x86/kvm/mtrr.c > >@@ -330,7 +330,7 @@ static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) > > var_mtrr_range(&mtrr_state->var_ranges[index], &start, &end); > > } > > > >- kvm_zap_gfn_range(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); > >+ kvm_zap_gfn_for_memtype(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); > > I am wondering if the check of shadow_memtype_mask (now inside the > kvm_zap_gfn_for_memtype()) should be moved to the beginning of update_mtrr(). > Because if EPT isn't enabled, computing @start/@end is useless and can be > skipped. No, shadow_memtype_mask is not accessible in mtrr.c. It's better to confine it in mmu related files, e.g. mmu/mmu.c, mmu/spte.c > > > } > > > > static bool var_mtrr_range_is_valid(struct kvm_mtrr_range *range) > >-- > >2.17.1 > >
On Wed, 2023-05-10 at 16:00 +0800, Yan Zhao wrote: > On Wed, May 10, 2023 at 01:39:25PM +0800, Chao Gao wrote: > > On Tue, May 09, 2023 at 09:51:43PM +0800, Yan Zhao wrote: > > > Call new helper kvm_zap_gfn_for_memtype() to skip zap mmu if EPT is not > > > enabled. > > > > > > When guest MTRR changes and it's desired to zap TDP entries to remove > > > stale mappings, only do it when EPT is enabled, because only memory type > > > of EPT leaf is affected by guest MTRR with noncoherent DMA present. > > > > > > Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> > > > --- > > > arch/x86/kvm/mtrr.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c > > > index 9fac1ec03463..62ebb9978156 100644 > > > --- a/arch/x86/kvm/mtrr.c > > > +++ b/arch/x86/kvm/mtrr.c > > > @@ -330,7 +330,7 @@ static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) > > > var_mtrr_range(&mtrr_state->var_ranges[index], &start, &end); > > > } > > > > > > - kvm_zap_gfn_range(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); > > > + kvm_zap_gfn_for_memtype(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); > > > > I am wondering if the check of shadow_memtype_mask (now inside the > > kvm_zap_gfn_for_memtype()) should be moved to the beginning of update_mtrr(). > > Because if EPT isn't enabled, computing @start/@end is useless and can be > > skipped. > > No, shadow_memtype_mask is not accessible in mtrr.c. > It's better to confine it in mmu related files, e.g. mmu/mmu.c, > mmu/spte.c > No, I think it should be shadow_memtype_mask. Conceptually, after commit 38bf9d7bf277 ("KVM: x86/mmu: Add shadow mask for effective host MTRR memtype"), I believe in update_mtrr() the check: if (msr == MSR_IA32_CR_PAT || !tdp_enabled || !kvm_arch_has_noncoherent_dma(vcpu->kvm)) return; should be: if (msr == MSR_IA32_CR_PAT || !shadow_memtype_mask || !kvm_arch_has_noncoherent_dma(vcpu->kvm)) return; Because the intention of 'shadow_memtype_mask' is to use it as a dedicated variable to represent hardware has capability to override the host MTRRs (which is the case for EPT), instead of relying on TDP being enabled. That being said, to me it's more reasonable to have a separate patch to replace the '!tdp_enabled' check with '!shadow_memtype_mask' in update_mtrr(), perhaps with a Fixes tag for commit 38bf9d7bf277. The kvm_zap_gfn_range() should be remain unchanged. For the problem that shadow_memtype_mask isn't accessible in mtrr.c I think you can include "mmu/spte.h"? >
On Wed, May 10, 2023 at 06:54:51PM +0800, Huang, Kai wrote: > On Wed, 2023-05-10 at 16:00 +0800, Yan Zhao wrote: > > On Wed, May 10, 2023 at 01:39:25PM +0800, Chao Gao wrote: > > > On Tue, May 09, 2023 at 09:51:43PM +0800, Yan Zhao wrote: > > > > Call new helper kvm_zap_gfn_for_memtype() to skip zap mmu if EPT is not > > > > enabled. > > > > > > > > When guest MTRR changes and it's desired to zap TDP entries to remove > > > > stale mappings, only do it when EPT is enabled, because only memory type > > > > of EPT leaf is affected by guest MTRR with noncoherent DMA present. > > > > > > > > Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> > > > > --- > > > > arch/x86/kvm/mtrr.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c > > > > index 9fac1ec03463..62ebb9978156 100644 > > > > --- a/arch/x86/kvm/mtrr.c > > > > +++ b/arch/x86/kvm/mtrr.c > > > > @@ -330,7 +330,7 @@ static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) > > > > var_mtrr_range(&mtrr_state->var_ranges[index], &start, &end); > > > > } > > > > > > > > - kvm_zap_gfn_range(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); > > > > + kvm_zap_gfn_for_memtype(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); > > > > > > I am wondering if the check of shadow_memtype_mask (now inside the > > > kvm_zap_gfn_for_memtype()) should be moved to the beginning of update_mtrr(). > > > Because if EPT isn't enabled, computing @start/@end is useless and can be > > > skipped. > > > > No, shadow_memtype_mask is not accessible in mtrr.c. > > It's better to confine it in mmu related files, e.g. mmu/mmu.c, > > mmu/spte.c > > > > No, I think it should be shadow_memtype_mask. > > Conceptually, after commit 38bf9d7bf277 ("KVM: x86/mmu: Add shadow mask for > effective host MTRR memtype"), I believe in update_mtrr() the check: > > if (msr == MSR_IA32_CR_PAT || !tdp_enabled || > !kvm_arch_has_noncoherent_dma(vcpu->kvm)) > return; > > should be: > > if (msr == MSR_IA32_CR_PAT || !shadow_memtype_mask || > !kvm_arch_has_noncoherent_dma(vcpu->kvm)) > return; > > Because the intention of 'shadow_memtype_mask' is to use it as a dedicated > variable to represent hardware has capability to override the host MTRRs (which > is the case for EPT), instead of relying on TDP being enabled. > > That being said, to me it's more reasonable to have a separate patch to replace > the '!tdp_enabled' check with '!shadow_memtype_mask' in update_mtrr(), perhaps > with a Fixes tag for commit 38bf9d7bf277. > > The kvm_zap_gfn_range() should be remain unchanged. > > For the problem that shadow_memtype_mask isn't accessible in mtrr.c I think you > can include "mmu/spte.h"? > I agree shadow_memtype_mask is the right value to check but it's indeed internal to kvm mmu. Including "mmu/spte.h" will further include "mmu/mmu_internal.h" What about introduce kvm_mmu_memtye_effective() instead as below? diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index a04577afbc71..173960b1827d 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -254,6 +254,8 @@ static inline bool kvm_shadow_root_allocated(struct kvm *kvm) return smp_load_acquire(&kvm->arch.shadow_root_allocated); } +bool kvm_mmu_memtye_effective(struct kvm *kvm); + #ifdef CONFIG_X86_64 extern bool tdp_mmu_enabled; #else diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 2706754794d1..ff7752d158d7 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -6288,6 +6288,10 @@ void kvm_zap_gfn_for_memtype(struct kvm *kvm, gfn_t gfn_start, gfn_t gfn_end) kvm_zap_gfn_range(kvm, gpa_to_gfn(0), gpa_to_gfn(~0ULL)); } +bool kvm_mmu_memtye_effective(struct kvm *kvm) +{ + return shadow_memtype_mask; +} /* * Invalidate (zap) SPTEs that cover GFNs from gfn_start and up to gfn_end * (not including it) diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c index 5ce5bc0c4971..b6bd147d22a0 100644 --- a/arch/x86/kvm/mtrr.c +++ b/arch/x86/kvm/mtrr.c @@ -313,7 +313,7 @@ static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) int cnt; unsigned long long all; - if (msr == MSR_IA32_CR_PAT || !tdp_enabled || + if (msr == MSR_IA32_CR_PAT || !kvm_mmu_memtye_effective(vcpu->kvm) || !kvm_arch_has_noncoherent_dma(vcpu->kvm)) return;
On Thu, May 11, 2023 at 10:42:13AM +0800, Huang, Kai wrote: > > > > > > > I agree shadow_memtype_mask is the right value to check but it's indeed > > internal to kvm mmu. > > Including "mmu/spte.h" will further include "mmu/mmu_internal.h" > > > > What about introduce kvm_mmu_memtye_effective() instead as below? > > > > [...] > > > > > +bool kvm_mmu_memtye_effective(struct kvm *kvm) > > +{ > > + return shadow_memtype_mask; > > +} > > I don't think it's a good name. shadow_memtype_mask doesn't mean any actual > effective memtype, but just represent those bits that KVM can manipulate to get > an effective memtype for the guest access. > > Instead, it should represent the hardware capability to be able to emulate > guest's MTRR independent from host's MTRR. So, perhaps something like: > > bool kvm_mmu_guest_mtrr_emulatable(); What about kvm_mmu_cap_effective_guest_mtrr()? Guest MTRR is always emulated with vMTRR. > > It's better if Sean can provide input here. > > (Btw, off this topic, I think it's even more reasonable to make > shadow_memtype_mask only be meaningful when tdp_enabled is true, because the > capability to override host MTRR and emulate guest MTRR should be only available > when secondary MMU is turned on). >
> > > > I agree shadow_memtype_mask is the right value to check but it's indeed > internal to kvm mmu. > Including "mmu/spte.h" will further include "mmu/mmu_internal.h" > > What about introduce kvm_mmu_memtye_effective() instead as below? > [...] > > +bool kvm_mmu_memtye_effective(struct kvm *kvm) > +{ > + return shadow_memtype_mask; > +} I don't think it's a good name. shadow_memtype_mask doesn't mean any actual effective memtype, but just represent those bits that KVM can manipulate to get an effective memtype for the guest access. Instead, it should represent the hardware capability to be able to emulate guest's MTRR independent from host's MTRR. So, perhaps something like: bool kvm_mmu_guest_mtrr_emulatable(); It's better if Sean can provide input here. (Btw, off this topic, I think it's even more reasonable to make shadow_memtype_mask only be meaningful when tdp_enabled is true, because the capability to override host MTRR and emulate guest MTRR should be only available when secondary MMU is turned on).
On Thu, 2023-05-11 at 10:31 +0800, Zhao, Yan Y wrote: > On Thu, May 11, 2023 at 10:42:13AM +0800, Huang, Kai wrote: > > > > > > > > > > I agree shadow_memtype_mask is the right value to check but it's indeed > > > internal to kvm mmu. > > > Including "mmu/spte.h" will further include "mmu/mmu_internal.h" > > > > > > What about introduce kvm_mmu_memtye_effective() instead as below? > > > > > > > [...] > > > > > > > > +bool kvm_mmu_memtye_effective(struct kvm *kvm) > > > +{ > > > + return shadow_memtype_mask; > > > +} > > > > I don't think it's a good name. shadow_memtype_mask doesn't mean any actual > > effective memtype, but just represent those bits that KVM can manipulate to get > > an effective memtype for the guest access. > > > > Instead, it should represent the hardware capability to be able to emulate > > guest's MTRR independent from host's MTRR. So, perhaps something like: > > > > bool kvm_mmu_guest_mtrr_emulatable(); > > What about kvm_mmu_cap_effective_guest_mtrr()? > Guest MTRR is always emulated with vMTRR. Fine to me, but again it's better if Sean can provide input. > > > > > It's better if Sean can provide input here. > > > > (Btw, off this topic, I think it's even more reasonable to make > > shadow_memtype_mask only be meaningful when tdp_enabled is true, because the > > capability to override host MTRR and emulate guest MTRR should be only available > > when secondary MMU is turned on). > >
diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c index 9fac1ec03463..62ebb9978156 100644 --- a/arch/x86/kvm/mtrr.c +++ b/arch/x86/kvm/mtrr.c @@ -330,7 +330,7 @@ static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) var_mtrr_range(&mtrr_state->var_ranges[index], &start, &end); } - kvm_zap_gfn_range(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); + kvm_zap_gfn_for_memtype(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end)); } static bool var_mtrr_range_is_valid(struct kvm_mtrr_range *range)