Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2638884pxb; Tue, 24 Aug 2021 04:11:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu2CjpPEi/uTxyUfjqG+amKyvELSlfRbwg17Yc551sxe/rC6rj7S/rpLZTen0Fyhe/burV X-Received: by 2002:a05:6e02:1c03:: with SMTP id l3mr14736123ilh.219.1629803459814; Tue, 24 Aug 2021 04:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629803459; cv=none; d=google.com; s=arc-20160816; b=ODXIMgU5WHxUwZwyTTNZ1Pl1GBvRD4jYFgSvwtICIHFYCVkgp74uv5xg+KFAlxSfEH dFUsUnfJpISuE2BNog5pMTmN+YJhWgGKz4zhXsCeLNwaEAyR0G6w9WtuXND+/7cKxl8e TjSHZac9ZSAHaNfW/lF2ZsIz/BndtV2LJc8DkcgYeEq1hFQsXILMkg+8jT69QZzl0q2Y LgKWSxikfFfsNvJy6sEB162w3zPgLbJZlvWVJwb5QeflSiQQjH+RF0FgepO2TFvieS6h O/HPJDpFQunJKv0ZYxBFuefiJnD16CR0+Jglr3g+pA0cFeccLIvtky5ll5+E6VUupYjs 88ng== 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=E3GHy4Vmie6zstBVsI7ZdRWd/192V+Bug2xMrM4mg+c=; b=wtS6qA2WxI4+JTbXRwW9CYZ37q8uKiIcm/1DkA8MI6andNq6oGzzVdbKe7ohWT5ZVi jmdpGq9YBDYmepJ0mulUrVt4+RaDWXyupISjYwHqoBO0/NdgqkXeMpUgmS4ETLvbsj20 rBuDMKlutugOzRPQnrVROg31Wt8zBeJeGI8Ijt8IEonfZXccCRNdzPrEB5N36AApKcKc werFUvMN/JijrQK0n0peR8J0SYiLgvCDOmwHbxYFOfRu7xAgDsKz2t2xCll8Y/3xcpxX jYRiZ/XyXtY6gyYHUbnNtU0E2cF7j6v8YkZh49VtYYoaEd1PYNzhgBzRjpX9qw5F7w2k Cgiw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si17320776jap.72.2021.08.24.04.10.48; Tue, 24 Aug 2021 04:10:59 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236786AbhHXLJY (ORCPT + 99 others); Tue, 24 Aug 2021 07:09:24 -0400 Received: from mga18.intel.com ([134.134.136.126]:3710 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236731AbhHXLJM (ORCPT ); Tue, 24 Aug 2021 07:09:12 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10085"; a="204423845" X-IronPort-AV: E=Sophos;i="5.84,347,1620716400"; d="scan'208";a="204423845" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2021 04:08:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,347,1620716400"; d="scan'208";a="493501648" Received: from lxy-dell.sh.intel.com ([10.239.159.31]) by fmsmga008.fm.intel.com with ESMTP; 24 Aug 2021 04:08:25 -0700 From: Xiaoyao Li To: Paolo Bonzini Cc: Xiaoyao Li , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] KVM: VMX: Use cached vmx->pt_desc.addr_range Date: Tue, 24 Aug 2021 19:07:40 +0800 Message-Id: <20210824110743.531127-3-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210824110743.531127-1-xiaoyao.li@intel.com> References: <20210824110743.531127-1-xiaoyao.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The number of guest's valid PT ADDR MSRs is cached in vmx->pt_desc.addr_range. Use it instead of calculating it again. Signed-off-by: Xiaoyao Li --- arch/x86/kvm/vmx/vmx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index e0a9460e4dab..7ed96c460661 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -2202,8 +2202,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) if (!pt_can_write_msr(vmx)) return 1; index = msr_info->index - MSR_IA32_RTIT_ADDR0_A; - if (index >= 2 * intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_num_address_ranges)) + if (index >= 2 * vmx->pt_desc.addr_range) return 1; if (is_noncanonical_address(data, vcpu)) return 1; -- 2.27.0