Skip to contentSkip to conversation

KVM: x86: add Intel processor trace virtualization mode

PATCH In review Luwei Kang 1 participant 1 message Oct 16, 2017

Subsystems (3)
lore
Share & tools
lore

Luwei Kang

author
#0 lore raw

PATCH 3/9 KVM: x86: add Intel processor trace virtualization mode

From: Chao Peng <[email protected]>

PT virtualization can be work in one of 4 possible modes:
a. system-wide: trace both host/guest and output to host buffer; b. host-only: only trace host and output to host buffer; c. guest-only: only trace guest and output to guest buffer; d. host-guest: trace host/guest simultaneous and output to their
respective buffer.

---
 arch/x86/include/asm/intel_pt.h  |  7 ++++
 arch/x86/include/asm/msr-index.h |  1 +
 arch/x86/include/asm/vmx.h       |  6 +++
 arch/x86/kvm/vmx.c               | 88 ++++++++++++++++++++++++++++++++++++++--
 4 files changed, 98 insertions(+), 4 deletions(-)
arch/x86/include/asm/intel_pt.h +7 -0
index 73c8942..b5dd33c 100644
@@ -1,6 +1,13 @@
 #ifndef _ASM_X86_INTEL_PT_H
 #define _ASM_X86_INTEL_PT_H
 
+enum pt_mode {
+	PT_MODE_SYSTEM = 0,
+	PT_MODE_HOST,
+	PT_MODE_GUEST,
+	PT_MODE_HOST_GUEST,
+};
+
 enum pt_capabilities {
 	PT_CAP_max_subleaf = 0,
 	PT_CAP_cr3_filtering,
arch/x86/include/asm/msr-index.h +1 -0
index 80b26e1..57433e4 100644
@@ -751,6 +751,7 @@
 #define VMX_BASIC_INOUT		0x0040000000000000LLU
 
 /* MSR_IA32_VMX_MISC bits */
+#define MSR_IA32_VMX_MISC_INTEL_PT                 (1ULL << 14)
 #define MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS (1ULL << 29)
 #define MSR_IA32_VMX_MISC_PREEMPTION_TIMER_SCALE   0x1F
 /* AMD-V MSRs */
arch/x86/include/asm/vmx.h +6 -0
index caec841..80e3e22 100644
@@ -76,7 +76,9 @@
 #define SECONDARY_EXEC_SHADOW_VMCS              0x00004000
 #define SECONDARY_EXEC_RDSEED			0x00010000
 #define SECONDARY_EXEC_ENABLE_PML               0x00020000
+#define SECONDARY_EXEC_PT_CONCEAL_VMX		0x00080000
 #define SECONDARY_EXEC_XSAVES			0x00100000
+#define SECONDARY_EXEC_PT_USE_GPA		0x01000000
 #define SECONDARY_EXEC_TSC_SCALING              0x02000000
 
 #define PIN_BASED_EXT_INTR_MASK                 0x00000001
@@ -97,6 +99,8 @@
 #define VM_EXIT_LOAD_IA32_EFER                  0x00200000
 #define VM_EXIT_SAVE_VMX_PREEMPTION_TIMER       0x00400000
 #define VM_EXIT_CLEAR_BNDCFGS                   0x00800000
+#define VM_EXIT_PT_SUPPRESS_PIP			0x01000000
+#define VM_EXIT_CLEAR_IA32_RTIT_CTL		0x02000000
 
 #define VM_EXIT_ALWAYSON_WITHOUT_TRUE_MSR	0x00036dff
 
@@ -108,6 +112,8 @@
 #define VM_ENTRY_LOAD_IA32_PAT			0x00004000
 #define VM_ENTRY_LOAD_IA32_EFER                 0x00008000
 #define VM_ENTRY_LOAD_BNDCFGS                   0x00010000
+#define VM_ENTRY_PT_SUPPRESS_PIP		0x00020000
+#define VM_ENTRY_LOAD_IA32_RTIT_CTL		0x00040000
 
 #define VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR	0x000011ff
 
arch/x86/kvm/vmx.c +84 -4

154 lines not on this page · raw message

Signature · 1 line
1.8.3.1