* [PATCH] MIPS: KVM: Fix trace event to save PC directly
@ 2015-02-24 11:46 James Hogan
2015-02-24 11:46 ` James Hogan
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: James Hogan @ 2015-02-24 11:46 UTC (permalink / raw)
To: Paolo Bonzini, Ralf Baechle, Marcelo Tosatti
Cc: James Hogan, Gleb Natapov, Steven Rostedt, Ingo Molnar,
linux-mips, kvm, stable
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: 669e846e6c4e ("KVM/MIPS32: MIPS arch specific APIs for KVM")
Signed-off-by: James 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
Cc: <stable@vger.kernel.org> # v3.10+
---
arch/mips/kvm/trace.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/mips/kvm/trace.h b/arch/mips/kvm/trace.h
index c1388d40663b..bd6437f67dc0 100644
--- a/arch/mips/kvm/trace.h
+++ b/arch/mips/kvm/trace.h
@@ -24,18 +24,18 @@ TRACE_EVENT(kvm_exit,
TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
TP_ARGS(vcpu, reason),
TP_STRUCT__entry(
- __field(struct kvm_vcpu *, vcpu)
+ __field(unsigned long, pc)
__field(unsigned int, reason)
),
TP_fast_assign(
- __entry->vcpu = vcpu;
+ __entry->pc = vcpu->arch.pc;
__entry->reason = reason;
),
TP_printk("[%s]PC: 0x%08lx",
kvm_mips_exit_types_str[__entry->reason],
- __entry->vcpu->arch.pc)
+ __entry->pc)
);
#endif /* _TRACE_KVM_H */
--
2.0.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] MIPS: KVM: Fix trace event to save PC directly
2015-02-24 11:46 [PATCH] MIPS: KVM: Fix trace event to save PC directly James Hogan
@ 2015-02-24 11:46 ` James Hogan
2015-02-24 14:10 ` Steven Rostedt
2015-03-02 22:15 ` Marcelo Tosatti
2 siblings, 0 replies; 5+ messages in thread
From: James Hogan @ 2015-02-24 11:46 UTC (permalink / raw)
To: Paolo Bonzini, Ralf Baechle, Marcelo Tosatti
Cc: James Hogan, Gleb Natapov, Steven Rostedt, Ingo Molnar,
linux-mips, kvm, stable
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: 669e846e6c4e ("KVM/MIPS32: MIPS arch specific APIs for KVM")
Signed-off-by: James 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
Cc: <stable@vger.kernel.org> # v3.10+
---
arch/mips/kvm/trace.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/mips/kvm/trace.h b/arch/mips/kvm/trace.h
index c1388d40663b..bd6437f67dc0 100644
--- a/arch/mips/kvm/trace.h
+++ b/arch/mips/kvm/trace.h
@@ -24,18 +24,18 @@ TRACE_EVENT(kvm_exit,
TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
TP_ARGS(vcpu, reason),
TP_STRUCT__entry(
- __field(struct kvm_vcpu *, vcpu)
+ __field(unsigned long, pc)
__field(unsigned int, reason)
),
TP_fast_assign(
- __entry->vcpu = vcpu;
+ __entry->pc = vcpu->arch.pc;
__entry->reason = reason;
),
TP_printk("[%s]PC: 0x%08lx",
kvm_mips_exit_types_str[__entry->reason],
- __entry->vcpu->arch.pc)
+ __entry->pc)
);
#endif /* _TRACE_KVM_H */
--
2.0.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: KVM: Fix trace event to save PC directly
2015-02-24 11:46 [PATCH] MIPS: KVM: Fix trace event to save PC directly James Hogan
2015-02-24 11:46 ` James Hogan
@ 2015-02-24 14:10 ` Steven Rostedt
2015-02-24 14:10 ` Steven Rostedt
2015-03-02 22:15 ` Marcelo Tosatti
2 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2015-02-24 14:10 UTC (permalink / raw)
To: James Hogan
Cc: Paolo Bonzini, Ralf Baechle, Marcelo Tosatti, Gleb Natapov,
Ingo Molnar, linux-mips, kvm, stable
On Tue, 24 Feb 2015 11:46:20 +0000
James Hogan <james.hogan@imgtec.com> wrote:
> Lets save the actual PC in the structure so that the correct value is
> accessible later.
>
> Fixes: 669e846e6c4e ("KVM/MIPS32: MIPS arch specific APIs for KVM")
> Signed-off-by: James 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>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
-- Steve
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: linux-mips@linux-mips.org
> Cc: kvm@vger.kernel.org
> Cc: <stable@vger.kernel.org> # v3.10+
> ---
> arch/mips/kvm/trace.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: KVM: Fix trace event to save PC directly
2015-02-24 14:10 ` Steven Rostedt
@ 2015-02-24 14:10 ` Steven Rostedt
0 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2015-02-24 14:10 UTC (permalink / raw)
To: James Hogan
Cc: Paolo Bonzini, Ralf Baechle, Marcelo Tosatti, Gleb Natapov,
Ingo Molnar, linux-mips, kvm, stable
On Tue, 24 Feb 2015 11:46:20 +0000
James Hogan <james.hogan@imgtec.com> wrote:
> Lets save the actual PC in the structure so that the correct value is
> accessible later.
>
> Fixes: 669e846e6c4e ("KVM/MIPS32: MIPS arch specific APIs for KVM")
> Signed-off-by: James 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>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
-- Steve
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: linux-mips@linux-mips.org
> Cc: kvm@vger.kernel.org
> Cc: <stable@vger.kernel.org> # v3.10+
> ---
> arch/mips/kvm/trace.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: KVM: Fix trace event to save PC directly
2015-02-24 11:46 [PATCH] MIPS: KVM: Fix trace event to save PC directly James Hogan
2015-02-24 11:46 ` James Hogan
2015-02-24 14:10 ` Steven Rostedt
@ 2015-03-02 22:15 ` Marcelo Tosatti
2 siblings, 0 replies; 5+ messages in thread
From: Marcelo Tosatti @ 2015-03-02 22:15 UTC (permalink / raw)
To: James Hogan
Cc: Paolo Bonzini, Ralf Baechle, Gleb Natapov, Steven Rostedt,
Ingo Molnar, linux-mips, kvm, stable
On Tue, Feb 24, 2015 at 11:46:20AM +0000, James Hogan wrote:
> 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.
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-02 22:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-24 11:46 [PATCH] MIPS: KVM: Fix trace event to save PC directly James Hogan
2015-02-24 11:46 ` James Hogan
2015-02-24 14:10 ` Steven Rostedt
2015-02-24 14:10 ` Steven Rostedt
2015-03-02 22:15 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox