Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1035778imm; Mon, 21 May 2018 19:59:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZplpOJk+2fUqvY1psejIGGo7WsjliDqib6oFkxK/BytQMzWfiHFMmW2vJKLZ0jIWFGwmsdw X-Received: by 2002:a62:e0cf:: with SMTP id d76-v6mr22441007pfm.52.1526957975932; Mon, 21 May 2018 19:59:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526957975; cv=none; d=google.com; s=arc-20160816; b=AdiDVgaxOYY/oYkWaEgaBN9RxTViCxVGSNCecC4KmRd0ZW0R8NwBRNNziMxl8zFB1i USmH0ww97P/qu1pPDgcCAMHlN2Uj6UBXmByBwvQ0a2IK5dJBey/qNKCFGID/ebTQNfQu 6DPpyOJPgBbcMDjeRRV9gRB+dw+L4OLtwAgbfDntbAA50+Q8lqS1dOdyWlinjYRMt535 w02Z67oojE7lgAS/HBQOssB1gfBv98N1B5rjwFUyMqsnwNU0xJSqtu9SS8wq7k7ezH4P kSJA+MOB6HcIY5NzCEzyMdFZspkKBdo4fIeQ2qZ5fcZt1Pc75BjYD3enuCfriw0Yc2JO BbfA== 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=HesOCEyxFqq3MsNFsdYebCiWzMTq5BkyrPLXLMYsNqw=; b=KhvgyaZl8kuLwGXJn56hbudJ0orskTXC8Fm9QnBrPtH06a+U20hOOrmZuXOEIaZc1W ccO2p8sY0wJ89c758hgfCj9vxyMFWXVfyuTPrS2axfF+OYecGdtaa7a4hKNZoqbGbHE9 BoxKJ7/hdx3zQ+5H383GCVF9fcABGzvAjEzV2lKSLfRTXXtaavkgt+RubXHH6LRRkedc KC86FbarLwnCyahhM+Rvizu4XDyZKBkCkMPcwv1c4bXAkTinTE1ihEuc77/Gs7/0AWhJ 39BNe4RBATLqVL9uNuoA342Tcjiz6D+nKFtSdnoH7DDbdWxL2Nk7EwrO84NIPheOytoQ hQ7w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19-v6si14873337plo.287.2018.05.21.19.59.21; Mon, 21 May 2018 19:59: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752703AbeEVC6X (ORCPT + 99 others); Mon, 21 May 2018 22:58:23 -0400 Received: from mga12.intel.com ([192.55.52.136]:49734 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751186AbeEVC6U (ORCPT ); Mon, 21 May 2018 22:58:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2018 19:58:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,428,1520924400"; d="scan'208";a="201335949" Received: from skx-d.bj.intel.com ([10.238.154.68]) by orsmga004.jf.intel.com with ESMTP; 21 May 2018 19:58:14 -0700 From: Luwei Kang To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, chao.p.peng@linux.intel.com, thomas.lendacky@amd.com, bp@suse.de, Kan.liang@intel.com, Janakarajan.Natarajan@amd.com, dwmw@amazon.co.uk, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, mathieu.poirier@linaro.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pbonzini@redhat.com, rkrcmar@redhat.com, david@redhat.com, bsd@redhat.com, yu.c.zhang@linux.intel.com, joro@8bytes.org, Luwei Kang Subject: [PATCH v9 05/12] perf/x86/intel/pt: Introduce a new function to get capability of Intel PT Date: Tue, 22 May 2018 12:52:08 +0800 Message-Id: <1526964735-16566-6-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1526964735-16566-1-git-send-email-luwei.kang@intel.com> References: <1526964735-16566-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 New function pt_cap_decode() will be invoked in KVM to check if a specific capability is available in KVM guest. Another function pt_cap_get() can only check the hardware capabilities but this may different with KVM guest because some features may not be exposed to guest. 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 f65f97a..18a2e80 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_decode(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_decode); + +u32 pt_cap_get(enum pt_capabilities cap) +{ + return pt_cap_decode(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..9c71453 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_decode(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_decode(u32 *caps, enum pt_capabilities cap) { return 0; } #endif #endif /* _ASM_X86_INTEL_PT_H */ -- 1.8.3.1