Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2033362rwd; Thu, 15 Jun 2023 20:46:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ilc3ayvGnLqXSxl1DI7RWvAwFq7mEF2T/q0dULTJXUv2RUPtel1pjUPmrQwvpNQ4PVBan X-Received: by 2002:a05:6a00:14d2:b0:65e:fca6:f2cf with SMTP id w18-20020a056a0014d200b0065efca6f2cfmr908846pfu.26.1686887213708; Thu, 15 Jun 2023 20:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686887213; cv=none; d=google.com; s=arc-20160816; b=F1wVd7urZF0H9tbWS1bN5IkIEYpMi/PIu2uMAaccrX4H6HHki4yy2cqRRpqI8oQ8pa ZPQz+ZJDplTLxz3tNDgN8agdarHpvE9R/QtnD8ZAKvsPNohXRkE6slInsJXNPoF1nUCf ZfH8JE2QALlASbvfVXQYBK1pbFm8KXGuNk1TheL/1a9C1iXL+Gnxik7d0vQYaGwPwAC9 RNd+dqgkeCW+StAj3lNSMggbqRVjslTlUTlmUI/MXeT/SObwT8sJSuoWEbLOklSFdYjc +GmlZHyCxZQSAxTR4XBZX8sU2D2Bk5UpTw8XBto6GYonLNOTv8ncMOB/WCt/kEwngZhB p3MA== 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=U2ErjbX7EBw0e8HHSrKEUNHzvWQtsibcN2HjvsyCgFI=; b=pEiljjmNJttAwVZ+mPqCCR+uGIh3ggdGQRD/1Wp/kpEZCduBQGh3U13sItch1Waxxr mmdBG3GQVMrLpWkfImIF1c19fEVdSjQODLCDq8cqrF9ZCQnxT2EN26cCDWzkUnROUdzE tuyQ1hGNHew3W7OoPOiKLsDg+YBIT/8cB9R3P74QQzVviolqTNLXeXRhaYeCNBVzpDr7 BRq13prOGwfgDdUsf4ekKdiXffAanjFO7vpo5hCTXCHukbuICVrLObWah13T7aU3ohk/ iPCcrt/QIqitWcMWf4K3cBszSglGg6dbJCfieJb0XKeBQm2pER0WQ0VwlrwHrbxh+jl2 ciQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ia6WMJWV; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y205-20020a6264d6000000b00666a28f1f44si2230017pfb.368.2023.06.15.20.46.40; Thu, 15 Jun 2023 20:46:53 -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=Ia6WMJWV; 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 S241506AbjFPDBz (ORCPT + 99 others); Thu, 15 Jun 2023 23:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239232AbjFPDB3 (ORCPT ); Thu, 15 Jun 2023 23:01:29 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40D5A2D5D; Thu, 15 Jun 2023 20:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686884487; x=1718420487; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=a7dmPZNYlw0iNOFy5IcfL4+fWnLVVuU7MOzfbP4iSGY=; b=Ia6WMJWV6tXEYCm5UdM5e2keTCJaQvAMkQMdKdw1x4otOE7w1FpYLfIP 0jlCj/GrIwfRrHrHGZVZMQSaICC1JmI0TnI43VaVBkyIwz5Ppm04qE0eD iD+jnY45hoC+GtHllHeXIH0U0AQMc4k1BMQQj+m6hyF05/ubanXibBzH9 F7VuTE6Ogr3oMz1rGKClBdW/9mz5aBSfH08sOX11Ys2/nDk7bj4tehavF ojOgnpfcMx/Ln0YBEED9xXjOVXPkhTBFrmtHnvQNdVL+vjUAo+wi+Nl2E yDrdTS3nn9iXzP8IcoWCTPRD+ednb+TgDVzGvhuM29EvZE+Kq42BopcfF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="348809733" X-IronPort-AV: E=Sophos;i="6.00,246,1681196400"; d="scan'208";a="348809733" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 20:01:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="857213580" X-IronPort-AV: E=Sophos;i="6.00,246,1681196400"; d="scan'208";a="857213580" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 20:01:24 -0700 From: Yan Zhao To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, chao.gao@intel.com, kai.huang@intel.com, robert.hoo.linux@gmail.com, Yan Zhao Subject: [PATCH v3 04/11] KVM: x86/mmu: Use KVM honors guest MTRRs helper when update mtrr Date: Fri, 16 Jun 2023 10:36:14 +0800 Message-Id: <20230616023614.7261-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230616023101.7019-1-yan.y.zhao@intel.com> References: <20230616023101.7019-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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: X-Mailing-List: linux-kernel@vger.kernel.org Call helper to check if guest MTRRs are honored by KVM MMU before calculation and zapping. Guest MTRRs only affect TDP memtypes when TDP honors guest MTRRs, there's no meaning to do the calculation and zapping otherwise. Suggested-by: Chao Gao Suggested-by: Sean Christopherson Cc: Kai Huang Signed-off-by: Yan Zhao --- 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 3eb6e7f47e96..a67c28a56417 100644 --- a/arch/x86/kvm/mtrr.c +++ b/arch/x86/kvm/mtrr.c @@ -320,7 +320,7 @@ static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) struct kvm_mtrr *mtrr_state = &vcpu->arch.mtrr_state; gfn_t start, end; - if (!tdp_enabled || !kvm_arch_has_noncoherent_dma(vcpu->kvm)) + if (!kvm_mmu_honors_guest_mtrrs(vcpu->kvm)) return; if (!mtrr_is_enabled(mtrr_state) && msr != MSR_MTRRdefType) -- 2.17.1