Skip to content

Commit

Permalink
KVM: SVM: Create trace events for VMGEXIT MSR protocol processing
Browse files Browse the repository at this point in the history
Add trace events for entry to and exit from VMGEXIT MSR protocol
processing. The vCPU will be common for the trace events. The MSR
protocol processing is guided by the GHCB GPA in the VMCB, so the GHCB
GPA will represent the input and output values for the entry and exit
events, respectively. Additionally, the exit event will contain the
return code for the event.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Message-Id: <c5b3b440c3e0db43ff2fc02813faa94fa54896b0.1607620209.git.thomas.lendacky@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Tom Lendacky authored and Paolo Bonzini committed Dec 15, 2020
1 parent d523ab6 commit 59e38b5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arch/x86/kvm/svm/sev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,9 @@ static int sev_handle_vmgexit_msr_protocol(struct vcpu_svm *svm)

ghcb_info = control->ghcb_gpa & GHCB_MSR_INFO_MASK;

trace_kvm_vmgexit_msr_protocol_enter(svm->vcpu.vcpu_id,
control->ghcb_gpa);

switch (ghcb_info) {
case GHCB_MSR_SEV_INFO_REQ:
set_ghcb_msr(svm, GHCB_MSR_SEV_INFO(GHCB_VERSION_MAX,
Expand Down Expand Up @@ -1591,6 +1594,9 @@ static int sev_handle_vmgexit_msr_protocol(struct vcpu_svm *svm)
ret = -EINVAL;
}

trace_kvm_vmgexit_msr_protocol_exit(svm->vcpu.vcpu_id,
control->ghcb_gpa, ret);

return ret;
}

Expand Down
44 changes: 44 additions & 0 deletions arch/x86/kvm/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,50 @@ TRACE_EVENT(kvm_vmgexit_exit,
__entry->info1, __entry->info2)
);

/*
* Tracepoint for the start of VMGEXIT MSR procotol processing
*/
TRACE_EVENT(kvm_vmgexit_msr_protocol_enter,
TP_PROTO(unsigned int vcpu_id, u64 ghcb_gpa),
TP_ARGS(vcpu_id, ghcb_gpa),

TP_STRUCT__entry(
__field(unsigned int, vcpu_id)
__field(u64, ghcb_gpa)
),

TP_fast_assign(
__entry->vcpu_id = vcpu_id;
__entry->ghcb_gpa = ghcb_gpa;
),

TP_printk("vcpu %u, ghcb_gpa %016llx",
__entry->vcpu_id, __entry->ghcb_gpa)
);

/*
* Tracepoint for the end of VMGEXIT MSR procotol processing
*/
TRACE_EVENT(kvm_vmgexit_msr_protocol_exit,
TP_PROTO(unsigned int vcpu_id, u64 ghcb_gpa, int result),
TP_ARGS(vcpu_id, ghcb_gpa, result),

TP_STRUCT__entry(
__field(unsigned int, vcpu_id)
__field(u64, ghcb_gpa)
__field(int, result)
),

TP_fast_assign(
__entry->vcpu_id = vcpu_id;
__entry->ghcb_gpa = ghcb_gpa;
__entry->result = result;
),

TP_printk("vcpu %u, ghcb_gpa %016llx, result %d",
__entry->vcpu_id, __entry->ghcb_gpa, __entry->result)
);

#endif /* _TRACE_KVM_H */

#undef TRACE_INCLUDE_PATH
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -11316,3 +11316,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_avic_ga_log);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_apicv_update_request);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_vmgexit_enter);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_vmgexit_exit);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_vmgexit_msr_protocol_enter);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_vmgexit_msr_protocol_exit);

0 comments on commit 59e38b5

Please sign in to comment.