Add trace_kvm_userspace_msr and call it when user space reenters kvm after KVM_EXIT_MSR. Add KVM_EXIT_MSR to kvm_trace_exit_reason list. Signed-off-by: Peter Hornyack <peterhornyack@xxxxxxxxxx> --- arch/x86/kvm/trace.h | 28 ++++++++++++++++++++++++++++ arch/x86/kvm/vmx.c | 4 ++++ arch/x86/kvm/x86.c | 1 + include/trace/events/kvm.h | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index 4eae7c35ddf5..6d144d424896 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h @@ -330,6 +330,34 @@ TRACE_EVENT(kvm_msr, #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true) #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true) +TRACE_EVENT(kvm_userspace_msr, + TP_PROTO(u8 direction, u8 handled, u32 index, u64 data), + TP_ARGS(direction, handled, index, data), + + TP_STRUCT__entry( + __field(u8, direction) + __field(u8, handled) + __field(u32, index) + __field(u64, data) + ), + + TP_fast_assign( + __entry->direction = direction; + __entry->handled = handled; + __entry->index = index; + __entry->data = data; + ), + + TP_printk("userspace %s %x = 0x%llx, %s", + __entry->direction == KVM_EXIT_MSR_RDMSR ? "rdmsr" : + __entry->direction == KVM_EXIT_MSR_WRMSR ? "wrmsr" : + "unknown!", + __entry->index, __entry->data, + __entry->handled == KVM_EXIT_MSR_UNHANDLED ? "unhandled" : + __entry->handled == KVM_EXIT_MSR_HANDLED ? "handled" : + "unknown!") +); + /* * Tracepoint for guest CR access. */ diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index ba26d382d785..46d276235f78 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -5500,6 +5500,10 @@ static int vmx_complete_userspace_msr(struct kvm_vcpu *vcpu) { struct msr_data msr; + trace_kvm_userspace_msr(vcpu->run->msr.direction, + vcpu->run->msr.handled, vcpu->run->msr.index, + vcpu->run->msr.data); + if (vcpu->run->msr.index != vcpu->arch.regs[VCPU_REGS_RCX]) { pr_debug("msr.index 0x%x changed, does not match ecx 0x%lx\n", vcpu->run->msr.index, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5c22f4655741..cc74ba1d01e6 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8040,6 +8040,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_inj_virq); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_page_fault); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_msr); +EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_userspace_msr); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_cr); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_nested_vmrun); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_nested_vmexit); diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h index a44062da684b..aa6ce656d658 100644 --- a/include/trace/events/kvm.h +++ b/include/trace/events/kvm.h @@ -14,7 +14,7 @@ ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR), \ ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\ ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI), ERSN(PAPR_HCALL), \ - ERSN(S390_UCONTROL), ERSN(WATCHDOG), ERSN(S390_TSCH) + ERSN(S390_UCONTROL), ERSN(WATCHDOG), ERSN(S390_TSCH), ERSN(MSR) TRACE_EVENT(kvm_userspace_exit, TP_PROTO(__u32 reason, int errno), -- 2.5.0.276.gf5e568e -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html