[PATCH v2 5/5] KVM: VMX: Switch PEBS records output to Intel PT buffer

From: Luwei Kang
Date: Thu Mar 19 2020 - 02:36:10 EST


Switch PEBS records output to Intel PT buffer when PEBS is enabled
in KVM guest by Intel PT.

Signed-off-by: Luwei Kang <luwei.kang@xxxxxxxxx>
---
arch/x86/kvm/vmx/vmx.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index c6d9a87..ec74656 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -921,6 +921,7 @@ void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
{
int i, j = 0;
struct msr_autoload *m = &vmx->msr_autoload;
+ struct kvm_pmu *pmu = vcpu_to_pmu(&vmx->vcpu);

switch (msr) {
case MSR_EFER:
@@ -952,6 +953,8 @@ void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
* guest's memory.
*/
wrmsrl(MSR_IA32_PEBS_ENABLE, 0);
+ if ((pmu->pebs_enable & PEBS_OUTPUT_MASK) == PEBS_OUTPUT_PT)
+ guest_val |= PEBS_OUTPUT_PT;
}

i = vmx_find_msr_index(&m->guest, msr);
--
1.8.3.1