From: Luwei Kang <luwei.kang@intel.com>
To: xen-devel@lists.xen.org
Cc: kevin.tian@intel.com, sstabellini@kernel.org,
wei.liu2@citrix.com, jbeulich@suse.com,
George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
tim@xen.org, jun.nakajima@intel.com,
Luwei Kang <luwei.kang@intel.com>
Subject: [PATCH RESEND v1 3/7] x86: add intel proecessor trace support for cpuid
Date: Tue, 16 Jan 2018 02:12:29 +0800 [thread overview]
Message-ID: <1516039953-2988-4-git-send-email-luwei.kang@intel.com> (raw)
In-Reply-To: <1516039953-2988-1-git-send-email-luwei.kang@intel.com>
This patch add Intel processor trace support
for cpuid handling.
Signed-off-by: Luwei Kang <luwei.kang@intel.com>
---
tools/libxc/xc_cpuid_x86.c | 12 ++++++++++--
xen/arch/x86/cpuid.c | 22 ++++++++++++++++++++++
xen/arch/x86/domctl.c | 4 ++++
xen/include/asm-x86/cpufeature.h | 1 +
xen/include/asm-x86/cpuid.h | 12 +++++++++++-
xen/include/public/arch-x86/cpufeatureset.h | 1 +
6 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index 25b922e..c39a9cf 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -38,7 +38,7 @@ enum {
#define clear_feature(idx, dst) ((dst) &= ~bitmaskof(idx))
#define set_feature(idx, dst) ((dst) |= bitmaskof(idx))
-#define DEF_MAX_BASE 0x0000000du
+#define DEF_MAX_BASE 0x00000014u
#define DEF_MAX_INTELEXT 0x80000008u
#define DEF_MAX_AMDEXT 0x8000001cu
@@ -471,6 +471,7 @@ static void xc_cpuid_hvm_policy(xc_interface *xch,
case 0x00000002: /* Intel cache info (dumped by AMD policy) */
case 0x00000004: /* Intel cache info (dumped by AMD policy) */
case 0x0000000a: /* Architectural Performance Monitor Features */
+ case 0x00000014: /* Intel Processor Trace Features */
case 0x80000002: /* Processor name string */
case 0x80000003: /* ... continued */
case 0x80000004: /* ... continued */
@@ -757,12 +758,19 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
continue;
}
+ if ( input[0] == 0x14 )
+ {
+ input[1]++;
+ if ( input[1] == 1 )
+ continue;
+ }
+
input[0]++;
if ( !(input[0] & 0x80000000u) && (input[0] > base_max ) )
input[0] = 0x80000000u;
input[1] = XEN_CPUID_INPUT_UNUSED;
- if ( (input[0] == 4) || (input[0] == 7) )
+ if ( (input[0] == 4) || (input[0] == 7) || (input[0] == 0x14) )
input[1] = 0;
else if ( input[0] == 0xd )
input[1] = 1; /* Xen automatically calculates almost everything. */
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 5ee82d3..c3d56fd 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -9,6 +9,7 @@
#include <asm/paging.h>
#include <asm/processor.h>
#include <asm/xstate.h>
+#include <asm/intel_pt.h>
const uint32_t known_features[] = INIT_KNOWN_FEATURES;
const uint32_t special_features[] = INIT_SPECIAL_FEATURES;
@@ -487,7 +488,19 @@ void recalculate_cpuid_policy(struct domain *d)
__clear_bit(X86_FEATURE_VMX, max_fs);
__clear_bit(X86_FEATURE_SVM, max_fs);
}
+
+ /*
+ * Hide Intel Processor trace feature when hardware not support
+ * PT-VMX or intel_pt option is disabled.
+ */
+ if ( !opt_intel_pt )
+ {
+ __clear_bit(X86_FEATURE_INTEL_PT, max_fs);
+ zero_leaves(p->intel_pt.raw, 0, ARRAY_SIZE(p->intel_pt.raw) - 1);
+ }
}
+ else
+ zero_leaves(p->intel_pt.raw, 0, ARRAY_SIZE(p->intel_pt.raw) - 1);
/*
* Allow the toolstack to set HTT, X2APIC and CMP_LEGACY. These bits
@@ -634,6 +647,15 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
*res = p->feat.raw[subleaf];
break;
+ case 0x14:
+ ASSERT(p->intel_pt.max_subleaf < ARRAY_SIZE(p->intel_pt.raw));
+ if ( subleaf > min_t(uint32_t, p->intel_pt.max_subleaf,
+ ARRAY_SIZE(p->intel_pt.raw) - 1) )
+ return;
+
+ *res = p->intel_pt.raw[subleaf];
+ break;
+
case XSTATE_CPUID:
if ( !p->basic.xsave || subleaf >= ARRAY_SIZE(p->xstate.raw) )
return;
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 5973d9f..493cca4 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -101,6 +101,10 @@ static int update_domain_cpuid_info(struct domain *d,
p->feat.raw[ctl->input[1]] = leaf;
break;
+ case 0x14:
+ p->intel_pt.raw[ctl->input[1]] = leaf;
+ break;
+
case XSTATE_CPUID:
p->xstate.raw[ctl->input[1]] = leaf;
break;
diff --git a/xen/include/asm-x86/cpufeature.h b/xen/include/asm-x86/cpufeature.h
index 84cc51d..8956667 100644
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -95,6 +95,7 @@
#define cpu_has_mpx boot_cpu_has(X86_FEATURE_MPX)
#define cpu_has_rdseed boot_cpu_has(X86_FEATURE_RDSEED)
#define cpu_has_smap boot_cpu_has(X86_FEATURE_SMAP)
+#define cpu_has_intel_pt boot_cpu_has(X86_FEATURE_INTEL_PT)
#define cpu_has_sha boot_cpu_has(X86_FEATURE_SHA)
/* CPUID level 0x80000007.edx */
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index d2dd841..39f06aa 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -61,10 +61,11 @@ extern struct cpuidmasks cpuidmask_defaults;
/* Whether or not cpuid faulting is available for the current domain. */
DECLARE_PER_CPU(bool, cpuid_faulting_enabled);
-#define CPUID_GUEST_NR_BASIC (0xdu + 1)
+#define CPUID_GUEST_NR_BASIC (0x14u + 1)
#define CPUID_GUEST_NR_FEAT (0u + 1)
#define CPUID_GUEST_NR_CACHE (5u + 1)
#define CPUID_GUEST_NR_XSTATE (62u + 1)
+#define CPUID_GUEST_NR_INTEL_PT (1u + 1)
#define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1)
#define CPUID_GUEST_NR_EXTD_AMD (0x1cu + 1)
#define CPUID_GUEST_NR_EXTD MAX(CPUID_GUEST_NR_EXTD_INTEL, \
@@ -169,6 +170,15 @@ struct cpuid_policy
} comp[CPUID_GUEST_NR_XSTATE];
} xstate;
+ /* Structured feature leaf: 0x00000014[xx] */
+ union {
+ struct cpuid_leaf raw[CPUID_GUEST_NR_INTEL_PT];
+ struct {
+ /* Subleaf 0. */
+ uint32_t max_subleaf;
+ };
+ } intel_pt;
+
/* Extended leaves: 0x800000xx */
union {
struct cpuid_leaf raw[CPUID_GUEST_NR_EXTD];
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index be6da8e..c35b061 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -215,6 +215,7 @@ XEN_CPUFEATURE(SMAP, 5*32+20) /*S Supervisor Mode Access Prevention */
XEN_CPUFEATURE(AVX512IFMA, 5*32+21) /*A AVX-512 Integer Fused Multiply Add */
XEN_CPUFEATURE(CLFLUSHOPT, 5*32+23) /*A CLFLUSHOPT instruction */
XEN_CPUFEATURE(CLWB, 5*32+24) /*A CLWB instruction */
+XEN_CPUFEATURE(INTEL_PT, 5*32+25) /*H Intel Processor Trace */
XEN_CPUFEATURE(AVX512PF, 5*32+26) /*A AVX-512 Prefetch Instructions */
XEN_CPUFEATURE(AVX512ER, 5*32+27) /*A AVX-512 Exponent & Reciprocal Instrs */
XEN_CPUFEATURE(AVX512CD, 5*32+28) /*A AVX-512 Conflict Detection Instrs */
--
1.8.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-01-15 18:12 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 18:12 [PATCH RESEND v1 0/7] Intel Processor Trace virtulization enabling Luwei Kang
2018-01-15 18:12 ` [PATCH RESEND v1 1/7] x86: add a flag to enable Intel processor trace Luwei Kang
2018-03-09 16:53 ` Wei Liu
2018-03-12 9:25 ` Kang, Luwei
2018-04-26 12:09 ` Wei Liu
2018-04-27 8:22 ` Kang, Luwei
2018-04-27 8:32 ` Wei Liu
2018-04-27 13:03 ` Jan Beulich
2018-04-27 23:16 ` Kang, Luwei
2018-04-26 12:29 ` Jan Beulich
2018-04-27 9:01 ` Kang, Luwei
2018-04-27 12:15 ` Jan Beulich
2018-04-27 23:18 ` Kang, Luwei
2018-01-15 18:12 ` [PATCH RESEND v1 2/7] x86: configure vmcs for Intel processor trace virtualization Luwei Kang
2018-04-26 12:34 ` Jan Beulich
2018-04-28 1:07 ` Kang, Luwei
2018-04-30 7:42 ` Jan Beulich
2018-05-02 7:22 ` Kang, Luwei
2018-05-02 9:09 ` Jan Beulich
2018-05-02 9:22 ` Kang, Luwei
2018-01-15 18:12 ` Luwei Kang [this message]
2018-04-30 15:43 ` [PATCH RESEND v1 3/7] x86: add intel proecessor trace support for cpuid Konrad Rzeszutek Wilk
2018-05-02 7:32 ` Kang, Luwei
2018-01-15 18:12 ` [PATCH RESEND v1 4/7] x86: add intel processor trace context Luwei Kang
2018-04-26 12:11 ` Wei Liu
2018-04-26 12:59 ` Jan Beulich
2018-04-28 1:26 ` Kang, Luwei
2018-01-15 18:12 ` [PATCH RESEND v1 5/7] x86: Implement Intel Processor Trace context switch Luwei Kang
2018-04-26 12:11 ` Wei Liu
2018-04-27 8:53 ` Kang, Luwei
2018-05-02 15:19 ` Wei Liu
2018-05-02 15:43 ` Jan Beulich
2018-05-02 16:15 ` Wei Liu
2018-05-02 16:51 ` Andrew Cooper
2018-05-03 7:27 ` Jan Beulich
2018-05-03 7:26 ` Jan Beulich
2018-05-03 7:51 ` Wei Liu
2018-04-26 13:12 ` Jan Beulich
2018-04-28 2:56 ` Kang, Luwei
2018-01-15 18:12 ` [PATCH RESEND v1 6/7] x86: Implement Intel Processor Trace MSRs read/write Luwei Kang
2018-04-26 13:20 ` Jan Beulich
2018-04-27 12:26 ` Jan Beulich
2018-05-03 5:22 ` Kang, Luwei
2018-05-03 7:33 ` Jan Beulich
2018-05-03 9:40 ` Kang, Luwei
2018-05-03 11:36 ` Jan Beulich
2018-05-04 3:53 ` Kang, Luwei
2018-05-04 12:06 ` Jan Beulich
2018-05-10 9:06 ` Kang, Luwei
2018-01-15 18:12 ` [PATCH RESEND v1 7/7] x86: Disable Intel Processor Trace when VMXON in L1 guest Luwei Kang
2018-01-16 8:41 ` [PATCH RESEND v1 0/7] Intel Processor Trace virtulization enabling Jan Beulich
2018-01-16 9:02 ` Kang, Luwei
2018-01-16 9:30 ` Jan Beulich
2018-01-16 9:45 ` Kang, Luwei
2018-04-26 12:12 ` Wei Liu
2018-05-03 4:06 ` Kang, Luwei
2018-05-03 5:55 ` Razvan Cojocaru
2018-05-03 8:06 ` Wei Liu
2018-05-04 4:10 ` Kang, Luwei
2018-05-03 9:49 ` Kang, Luwei
2018-05-03 10:01 ` Andrew Cooper
2018-05-04 3:08 ` Kang, Luwei
2018-05-10 9:26 ` Kang, Luwei
2018-05-10 9:56 ` Andrew Cooper
2018-05-15 2:50 ` Kang, Luwei
2018-04-30 15:42 ` Konrad Rzeszutek Wilk
2018-05-02 7:27 ` Kang, Luwei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1516039953-2988-4-git-send-email-luwei.kang@intel.com \
--to=luwei.kang@intel.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).