]>
Commit | Line | Data |
---|---|---|
26b5eebe GKH |
1 | From b3cffac04eca9af46e1e23560a8ee22b1bd36d43 Mon Sep 17 00:00:00 2001 |
2 | From: James Hogan <james.hogan@imgtec.com> | |
3 | Date: Tue, 24 Feb 2015 11:46:20 +0000 | |
4 | Subject: KVM: MIPS: Fix trace event to save PC directly | |
5 | ||
6 | From: James Hogan <james.hogan@imgtec.com> | |
7 | ||
8 | commit b3cffac04eca9af46e1e23560a8ee22b1bd36d43 upstream. | |
9 | ||
10 | Currently the guest exit trace event saves the VCPU pointer to the | |
11 | structure, and the guest PC is retrieved by dereferencing it when the | |
12 | event is printed rather than directly from the trace record. This isn't | |
13 | safe as the printing may occur long afterwards, after the PC has changed | |
14 | and potentially after the VCPU has been freed. Usually this results in | |
15 | the same (wrong) PC being printed for multiple trace events. It also | |
16 | isn't portable as userland has no way to access the VCPU data structure | |
17 | when interpreting the trace record itself. | |
18 | ||
19 | Lets save the actual PC in the structure so that the correct value is | |
20 | accessible later. | |
21 | ||
22 | Fixes: 669e846e6c4e ("KVM/MIPS32: MIPS arch specific APIs for KVM") | |
23 | Signed-off-by: James Hogan <james.hogan@imgtec.com> | |
24 | Cc: Paolo Bonzini <pbonzini@redhat.com> | |
25 | Cc: Ralf Baechle <ralf@linux-mips.org> | |
26 | Cc: Marcelo Tosatti <mtosatti@redhat.com> | |
27 | Cc: Gleb Natapov <gleb@kernel.org> | |
28 | Cc: Steven Rostedt <rostedt@goodmis.org> | |
29 | Cc: Ingo Molnar <mingo@redhat.com> | |
30 | Cc: linux-mips@linux-mips.org | |
31 | Cc: kvm@vger.kernel.org | |
32 | Acked-by: Steven Rostedt <rostedt@goodmis.org> | |
33 | Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> | |
34 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
35 | ||
36 | --- | |
37 | arch/mips/kvm/trace.h | 6 +++--- | |
38 | 1 file changed, 3 insertions(+), 3 deletions(-) | |
39 | ||
40 | --- a/arch/mips/kvm/trace.h | |
41 | +++ b/arch/mips/kvm/trace.h | |
42 | @@ -26,18 +26,18 @@ TRACE_EVENT(kvm_exit, | |
43 | TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason), | |
44 | TP_ARGS(vcpu, reason), | |
45 | TP_STRUCT__entry( | |
46 | - __field(struct kvm_vcpu *, vcpu) | |
47 | + __field(unsigned long, pc) | |
48 | __field(unsigned int, reason) | |
49 | ), | |
50 | ||
51 | TP_fast_assign( | |
52 | - __entry->vcpu = vcpu; | |
53 | + __entry->pc = vcpu->arch.pc; | |
54 | __entry->reason = reason; | |
55 | ), | |
56 | ||
57 | TP_printk("[%s]PC: 0x%08lx", | |
58 | kvm_mips_exit_types_str[__entry->reason], | |
59 | - __entry->vcpu->arch.pc) | |
60 | + __entry->pc) | |
61 | ); | |
62 | ||
63 | #endif /* _TRACE_KVM_H */ |