Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752800AbdLKKQG (ORCPT ); Mon, 11 Dec 2017 05:16:06 -0500 Received: from mga07.intel.com ([134.134.136.100]:25477 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752766AbdLKKP7 (ORCPT ); Mon, 11 Dec 2017 05:15:59 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,391,1508828400"; d="scan'208";a="1495956" From: Luwei Kang To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, linux-kernel@vger.kernel.org, joro@8bytes.org, Luwei Kang Subject: [PATCH V4 06/11] KVM: x86: Add a function to get the number of address ranges Date: Mon, 11 Dec 2017 04:30:52 +0800 Message-Id: <1512937857-10477-7-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512937857-10477-1-git-send-email-luwei.kang@intel.com> References: <1512937857-10477-1-git-send-email-luwei.kang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1664 Lines: 47 CPUID.(EAX=14H,ECX=1H).EAX[2:0] enumerates the number of Intel Processor Trace configurable Address Ranges for filtering. Signed-off-by: Luwei Kang --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/x86.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 6480faa..c120202 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1217,6 +1217,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int idt_index, unsigned long kvm_get_rflags(struct kvm_vcpu *vcpu); void kvm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags); bool kvm_rdpmc(struct kvm_vcpu *vcpu); +unsigned int kvm_get_pt_addr_cnt(void); void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr); void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index faf843c..b19a749 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -991,6 +991,19 @@ bool kvm_rdpmc(struct kvm_vcpu *vcpu) } EXPORT_SYMBOL_GPL(kvm_rdpmc); +unsigned int kvm_get_pt_addr_cnt(void) +{ + unsigned int eax, ebx, ecx, edx; + /* + * - CPUID function 14H, sub-function 1: + * EAX[2:0] enumerates the number of Intel Processor + * Trace configurable Address Ranges for filtering. + */ + cpuid_count(0x14, 1, &eax, &ebx, &ecx, &edx); + return (eax & 0x7); +} +EXPORT_SYMBOL_GPL(kvm_get_pt_addr_cnt); + /* * List of msr numbers which we expose to userspace through KVM_GET_MSRS * and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST. -- 1.8.3.1