Received: by 10.223.185.116 with SMTP id b49csp2080702wrg; Sun, 4 Mar 2018 17:58:07 -0800 (PST) X-Google-Smtp-Source: AG47ELuAZWa2MxvWzZr2yFteZYaeuiftu1M6wbf/TU2UbSj4mQyjj33b4jzVvktONR8gE8607zbi X-Received: by 10.98.137.90 with SMTP id v87mr13612944pfd.80.1520215087628; Sun, 04 Mar 2018 17:58:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520215087; cv=none; d=google.com; s=arc-20160816; b=rOhOTOJW+4nEqX/TPJRGrtVLEx/w2xzDn9bnnfrCDBD51zp2XOmEMKR6iytnTdeAUi OQbu0jc1kXfGMQwYWEcFCrhM4a5AvH2ab64Gryqr3objf7d79yJ59SDrRY/fTzvorWmV qHucX47FmCH8hqgqYdkxMU702rBzq956HvhSHbbgTkb0eJku/RB7H8FZX+OWwqq/2wWL ybtGRfnqjvkc6svzKKcE0KDFFdvkv4jeYyDLkOADvgSrC00CiJ6yIqD+FMZ673Re6VjQ o7znYhudkzkassrFmzAKJRpJgzvUZ2eTaxZ8YJkT/2vmVScPt6O5JYCvTMkCPNNtKBW/ tG4g== 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=T9ckvGRsLgXuGsRAEqqiKBzetfqAYcILqTPwyBP1XSk=; b=Sgz04aXlrKl4uq4oeXwrvFNZcxZ1BZiqobhpQf5jrzodVgO+xZAk7+YVKR817YbCif qcuAnEMTU8Ur/Z5psaYVNXp7T3EZMOKGJMk5Z3pv4Jia+KrC4AgvxIFGhJM3SRYYCdOV 8FeV0rK2dP9KvztFk/Y6iH+t2UKtFQqqbo2/HfmVqA0Xj/Wet9vHF68lMc86mbAukTJS DH5TOI9gSOpefWGAzXk2Z2vAHuoutGBVIj3Q/5OLAnWCSq9Xuus97Qx85pgTqfnZSasD VwB584hG9T5JI6Ir/8N4QCLJdoJMHZ9MgOAYwWNp+KXm82uCpjFpXPELHvTmAn56Gopl WygA== 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 p79si7990352pfk.91.2018.03.04.17.57.53; Sun, 04 Mar 2018 17:58:07 -0800 (PST) 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 S932530AbeCEB47 (ORCPT + 99 others); Sun, 4 Mar 2018 20:56:59 -0500 Received: from mga14.intel.com ([192.55.52.115]:39574 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932119AbeCEB45 (ORCPT ); Sun, 4 Mar 2018 20:56:57 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2018 17:56:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,425,1515484800"; d="scan'208";a="21986063" Received: from vmm.bj.intel.com ([10.238.135.172]) by fmsmga008.fm.intel.com with ESMTP; 04 Mar 2018 17:56:55 -0800 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 v5 03/11] perf/x86/intel/pt: Introduce a new function to get the capability of Intel PT Date: Sun, 4 Mar 2018 20:07:13 +0800 Message-Id: <1520165241-15819-4-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520165241-15819-1-git-send-email-luwei.kang@intel.com> References: <1520165241-15819-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 diffrent with with host(some bits may mask off in guest) so introduce a new function pt_cap_get_ex() 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, 12 insertions(+) diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index d89dd8c..817104e 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -86,6 +86,16 @@ u32 pt_cap_get(enum pt_capabilities cap) } EXPORT_SYMBOL_GPL(pt_cap_get); +u32 pt_cap_get_ex(u32 *caps, enum pt_capabilities cap) +{ + struct pt_cap_desc *cd = &pt_caps[cap]; + 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_ex); + static ssize_t pt_cap_show(struct device *cdev, struct device_attribute *attr, char *buf) diff --git a/arch/x86/include/asm/intel_pt.h b/arch/x86/include/asm/intel_pt.h index 2de4db0..486e11f 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_ex(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_ex(u32 *caps, enum pt_capabilities cap) { return 0; } #endif #endif /* _ASM_X86_INTEL_PT_H */ -- 1.8.3.1