]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.10.72/kvm-mips-fix-trace-event-to-save-pc-directly.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.10.72 / kvm-mips-fix-trace-event-to-save-pc-directly.patch
CommitLineData
26b5eebe
GKH
1From b3cffac04eca9af46e1e23560a8ee22b1bd36d43 Mon Sep 17 00:00:00 2001
2From: James Hogan <james.hogan@imgtec.com>
3Date: Tue, 24 Feb 2015 11:46:20 +0000
4Subject: KVM: MIPS: Fix trace event to save PC directly
5
6From: James Hogan <james.hogan@imgtec.com>
7
8commit b3cffac04eca9af46e1e23560a8ee22b1bd36d43 upstream.
9
10Currently the guest exit trace event saves the VCPU pointer to the
11structure, and the guest PC is retrieved by dereferencing it when the
12event is printed rather than directly from the trace record. This isn't
13safe as the printing may occur long afterwards, after the PC has changed
14and potentially after the VCPU has been freed. Usually this results in
15the same (wrong) PC being printed for multiple trace events. It also
16isn't portable as userland has no way to access the VCPU data structure
17when interpreting the trace record itself.
18
19Lets save the actual PC in the structure so that the correct value is
20accessible later.
21
22Fixes: 669e846e6c4e ("KVM/MIPS32: MIPS arch specific APIs for KVM")
23Signed-off-by: James Hogan <james.hogan@imgtec.com>
24Cc: Paolo Bonzini <pbonzini@redhat.com>
25Cc: Ralf Baechle <ralf@linux-mips.org>
26Cc: Marcelo Tosatti <mtosatti@redhat.com>
27Cc: Gleb Natapov <gleb@kernel.org>
28Cc: Steven Rostedt <rostedt@goodmis.org>
29Cc: Ingo Molnar <mingo@redhat.com>
30Cc: linux-mips@linux-mips.org
31Cc: kvm@vger.kernel.org
32Acked-by: Steven Rostedt <rostedt@goodmis.org>
33Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
34Signed-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 */