[3.16.y-ckt stable] Patch "KVM: MIPS: Fix trace event to save PC directly" has been added to staging queue

Luis Henriques luis.henriques at canonical.com
Thu Mar 19 10:13:00 UTC 2015

This is a note to let you know that I have just added a patch titled

    KVM: MIPS: Fix trace event to save PC directly

to the linux-3.16.y-queue branch of the 3.16.y-ckt extended stable tree 
which can be found at:


This patch is scheduled to be released in version 3.16.7-ckt9.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.16.y-ckt tree, see



>From d48fc17717a72401605b1f7f07ae96926e524c6f Mon Sep 17 00:00:00 2001
From: James Hogan <james.hogan at imgtec.com>
Date: Tue, 24 Feb 2015 11:46:20 +0000
Subject: KVM: MIPS: Fix trace event to save PC directly

commit b3cffac04eca9af46e1e23560a8ee22b1bd36d43 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: 669e846e6c4e ("KVM/MIPS32: MIPS arch specific APIs for KVM")
Signed-off-by: James Hogan <james.hogan at imgtec.com>
Cc: Paolo Bonzini <pbonzini at redhat.com>
Cc: Ralf Baechle <ralf at linux-mips.org>
Cc: Marcelo Tosatti <mtosatti at redhat.com>
Cc: Gleb Natapov <gleb at kernel.org>
Cc: Steven Rostedt <rostedt at goodmis.org>
Cc: Ingo Molnar <mingo at redhat.com>
Cc: linux-mips at linux-mips.org
Cc: kvm at vger.kernel.org
Acked-by: Steven Rostedt <rostedt at goodmis.org>
Signed-off-by: Marcelo Tosatti <mtosatti at redhat.com>
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
 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 bc9e0f406c08..e51621e36152 100644
--- a/arch/mips/kvm/trace.h
+++ b/arch/mips/kvm/trace.h
@@ -26,18 +26,18 @@ TRACE_EVENT(kvm_exit,
 	    TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
 	    TP_ARGS(vcpu, reason),
-			__field(struct kvm_vcpu *, vcpu)
+			__field(unsigned long, pc)
 			__field(unsigned int, reason)

-			__entry->vcpu = vcpu;
+			__entry->pc = vcpu->arch.pc;
 			__entry->reason = reason;

 	    TP_printk("[%s]PC: 0x%08lx",
-		      __entry->vcpu->arch.pc)
+		      __entry->pc)

 #endif /* _TRACE_KVM_H */

More information about the kernel-team mailing list