Received: by 10.213.65.68 with SMTP id h4csp864688imn; Tue, 20 Mar 2018 18:12:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELu+juJTS31bpT9eAcvZ1Cx1BPs7f1pDhMHIA+hL0Afj6yaNFlMY7gLrrA33tylwaRypCMHY X-Received: by 10.99.55.1 with SMTP id e1mr9185365pga.237.1521594755921; Tue, 20 Mar 2018 18:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521594755; cv=none; d=google.com; s=arc-20160816; b=svlBB+MTgz7qIHN/EYq6PeLwBIRg9esTYrWR6yyvSOK5VIJLDmAbxGHIz50KrHuSKT AvcsJ3E5EgR3IFt1vDZ9NZSujQ75YigZh6O2bo8ibxaqzgbA6LKQe+PMVZfNUoC9TLnj vfG5OoX8xDmfrPcrrdK/p/L9JoQPVdb15ATte2TVXxu2wfbgZ+9892FGPRu5PRonEe5W X1Oq/EGhs8eQAKo2NC/s9vSzS4pqZCbwhJ/zZh0XcNM4snlt/bifX5Bc76ipAUTJpzHf ss8d4W/UEtVbpRN0zrSRtC14kmh9iD+Dgu2hX9t+7s3WB/f+maSOot0NlAJNbvvUBL2L OR5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Gqf+QY6kOZQBDwlh40IBIAKa7AP+AUdd4VhaDsAI1oA=; b=huPdOaiS5FEeLGRePa35FGrlOD6sCMq2F1fTfL2BwxQnu8Bg519Nu/dx0kc7d1fgzC Di/lJISd9OglbL8ajwNeReXbAAHUbgR7TwFBAWS4QeHut40oEa5Fr9mjHsIPIviSRNNj wwjklGDCaayLV8T/og56egsMnFfAvEhQ0MEo24+EG5EE01W6Cnd3Rw8TKSblDpwfqWAe +oWk0GW0HpFwcmu3S3PKi2VZ9RGtpNn+XHNfgacr1CRGgNKSupO0DbNA+ZMXQFPpghFc xfiAroBqsUqVi2RnFgilaU08YRAGh+4nNZYUNQslMmPgfEMrcF8C97RvcAdN8bIlP/x9 zBjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o5si1953765pgp.16.2018.03.20.18.12.22; Tue, 20 Mar 2018 18:12:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751877AbeCUBL1 (ORCPT + 99 others); Tue, 20 Mar 2018 21:11:27 -0400 Received: from mga09.intel.com ([134.134.136.24]:19664 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751629AbeCUBLK (ORCPT ); Tue, 20 Mar 2018 21:11:10 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2018 18:11:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,338,1517904000"; d="scan'208";a="39779351" Received: from vmm.bj.intel.com ([10.238.135.172]) by fmsmga001.fm.intel.com with ESMTP; 20 Mar 2018 18:11:07 -0700 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 v6 03/11] perf/x86/intel/pt: Introduce a new function to get the capability of Intel PT Date: Tue, 20 Mar 2018 19:21:50 +0800 Message-Id: <1521544918-31084-4-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521544918-31084-1-git-send-email-luwei.kang@intel.com> References: <1521544918-31084-1-git-send-email-luwei.kang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because of the guest CPUID information may different with host(some bits may mask off in guest) so introduce a new function to get the capability of Intel PT. Signed-off-by: Luwei Kang --- arch/x86/events/intel/pt.c | 10 ++++++++-- arch/x86/include/asm/intel_pt.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index d89dd8c..c66eb90 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -76,14 +76,20 @@ PT_CAP(psb_periods, 1, CPUID_EBX, 0xffff0000), }; -u32 pt_cap_get(enum pt_capabilities cap) +u32 __pt_cap_get(u32 *caps, enum pt_capabilities cap) { struct pt_cap_desc *cd = &pt_caps[cap]; - u32 c = pt_pmu.caps[cd->leaf * PT_CPUID_REGS_NUM + cd->reg]; + u32 c = caps[cd->leaf * PT_CPUID_REGS_NUM + cd->reg]; unsigned int shift = __ffs(cd->mask); return (c & cd->mask) >> shift; } +EXPORT_SYMBOL_GPL(__pt_cap_get); + +u32 pt_cap_get(enum pt_capabilities cap) +{ + return __pt_cap_get(pt_pmu.caps, cap); +} EXPORT_SYMBOL_GPL(pt_cap_get); static ssize_t pt_cap_show(struct device *cdev, diff --git a/arch/x86/include/asm/intel_pt.h b/arch/x86/include/asm/intel_pt.h index 2de4db0..3a4f524 100644 --- a/arch/x86/include/asm/intel_pt.h +++ b/arch/x86/include/asm/intel_pt.h @@ -27,9 +27,11 @@ enum pt_capabilities { #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL) void cpu_emergency_stop_pt(void); extern u32 pt_cap_get(enum pt_capabilities cap); +extern u32 __pt_cap_get(u32 *caps, enum pt_capabilities cap); #else static inline void cpu_emergency_stop_pt(void) {} static inline u32 pt_cap_get(enum pt_capabilities cap) { return 0; } +static u32 __pt_cap_get(u32 *caps, enum pt_capabilities cap) { return 0; } #endif #endif /* _ASM_X86_INTEL_PT_H */ -- 1.8.3.1