Commit 89fce062 authored by James Hogan's avatar James Hogan Committed by Greg Kroah-Hartman

KVM: MIPS: Fix trace event to save PC directly

commit b3cffac0 upstream.

Currently the guest exit trace event saves the VCPU pointer to the
structure, and the guest PC is retrieved by dereferencing it when the
event is printed rather than directly from the trace record. This isn't
safe as the printing may occur long afterwards, after the PC has changed
and potentially after the VCPU has been freed. Usually this results in
the same (wrong) PC being printed for multiple trace events. It also
isn't portable as userland has no way to access the VCPU data structure
when interpreting the trace record itself.

Lets save the actual PC in the structure so that the correct value is
accessible later.

Fixes: 669e846e ("KVM/MIPS32: MIPS arch specific APIs for KVM")
Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d1feb252
...@@ -24,18 +24,18 @@ TRACE_EVENT(kvm_exit, ...@@ -24,18 +24,18 @@ TRACE_EVENT(kvm_exit,
TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason), TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
TP_ARGS(vcpu, reason), TP_ARGS(vcpu, reason),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct kvm_vcpu *, vcpu) __field(unsigned long, pc)
__field(unsigned int, reason) __field(unsigned int, reason)
), ),
TP_fast_assign( TP_fast_assign(
__entry->vcpu = vcpu; __entry->pc = vcpu->arch.pc;
__entry->reason = reason; __entry->reason = reason;
), ),
TP_printk("[%s]PC: 0x%08lx", TP_printk("[%s]PC: 0x%08lx",
kvm_mips_exit_types_str[__entry->reason], kvm_mips_exit_types_str[__entry->reason],
__entry->vcpu->arch.pc) __entry->pc)
); );
#endif /* _TRACE_KVM_H */ #endif /* _TRACE_KVM_H */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment