* [PATCH] KVM: Trace exception injection
@ 2010-03-11 11:03 Avi Kivity
2010-03-11 11:09 ` Gleb Natapov
0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2010-03-11 11:03 UTC (permalink / raw)
To: kvm
Often an exception can help point out where things start to go wrong.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
arch/x86/kvm/trace.h | 32 ++++++++++++++++++++++++++++++++
arch/x86/kvm/x86.c | 3 +++
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index d10b359..32c912c 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -219,6 +219,38 @@ TRACE_EVENT(kvm_inj_virq,
TP_printk("irq %u", __entry->irq)
);
+#define EXS(x) { x##_VECTOR, "#" #x }
+
+#define kvm_trace_sym_exc \
+ EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM), \
+ EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF), \
+ EXS(MF), EXS(MC)
+
+/*
+ * Tracepoint for kvm interrupt injection:
+ */
+TRACE_EVENT(kvm_inj_exception,
+ TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
+ TP_ARGS(exception, has_error, error_code),
+
+ TP_STRUCT__entry(
+ __field( u8, exception )
+ __field( u8, has_error )
+ __field( u32, error_code )
+ ),
+
+ TP_fast_assign(
+ __entry->exception = exception;
+ __entry->has_error = has_error;
+ __entry->error_code = error_code;
+ ),
+
+ TP_printk("%s (0x%x)",
+ __print_symbolic(__entry->exception, kvm_trace_sym_exc),
+ /* FIXME: don't print error_code if not present */
+ __entry->has_error ? __entry->error_code : 0)
+);
+
/*
* Tracepoint for page fault.
*/
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 66609f6..bcf52d1 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4231,6 +4231,9 @@ static void inject_pending_event(struct kvm_vcpu *vcpu)
{
/* try to reinject previous events if any */
if (vcpu->arch.exception.pending) {
+ trace_kvm_inj_exception(vcpu->arch.exception.nr,
+ vcpu->arch.exception.has_error_code,
+ vcpu->arch.exception.error_code);
kvm_x86_ops->queue_exception(vcpu, vcpu->arch.exception.nr,
vcpu->arch.exception.has_error_code,
vcpu->arch.exception.error_code);
--
1.7.0.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] KVM: Trace exception injection
2010-03-11 11:03 [PATCH] KVM: Trace exception injection Avi Kivity
@ 2010-03-11 11:09 ` Gleb Natapov
2010-03-11 11:51 ` Avi Kivity
0 siblings, 1 reply; 5+ messages in thread
From: Gleb Natapov @ 2010-03-11 11:09 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
On Thu, Mar 11, 2010 at 01:03:12PM +0200, Avi Kivity wrote:
> Often an exception can help point out where things start to go wrong.
>
Adding guest rip where exception happened will be useful too.
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
> arch/x86/kvm/trace.h | 32 ++++++++++++++++++++++++++++++++
> arch/x86/kvm/x86.c | 3 +++
> 2 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
> index d10b359..32c912c 100644
> --- a/arch/x86/kvm/trace.h
> +++ b/arch/x86/kvm/trace.h
> @@ -219,6 +219,38 @@ TRACE_EVENT(kvm_inj_virq,
> TP_printk("irq %u", __entry->irq)
> );
>
> +#define EXS(x) { x##_VECTOR, "#" #x }
> +
> +#define kvm_trace_sym_exc \
> + EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM), \
> + EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF), \
> + EXS(MF), EXS(MC)
> +
> +/*
> + * Tracepoint for kvm interrupt injection:
> + */
> +TRACE_EVENT(kvm_inj_exception,
> + TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
> + TP_ARGS(exception, has_error, error_code),
> +
> + TP_STRUCT__entry(
> + __field( u8, exception )
> + __field( u8, has_error )
> + __field( u32, error_code )
> + ),
> +
> + TP_fast_assign(
> + __entry->exception = exception;
> + __entry->has_error = has_error;
> + __entry->error_code = error_code;
> + ),
> +
> + TP_printk("%s (0x%x)",
> + __print_symbolic(__entry->exception, kvm_trace_sym_exc),
> + /* FIXME: don't print error_code if not present */
> + __entry->has_error ? __entry->error_code : 0)
> +);
> +
> /*
> * Tracepoint for page fault.
> */
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 66609f6..bcf52d1 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4231,6 +4231,9 @@ static void inject_pending_event(struct kvm_vcpu *vcpu)
> {
> /* try to reinject previous events if any */
> if (vcpu->arch.exception.pending) {
> + trace_kvm_inj_exception(vcpu->arch.exception.nr,
> + vcpu->arch.exception.has_error_code,
> + vcpu->arch.exception.error_code);
> kvm_x86_ops->queue_exception(vcpu, vcpu->arch.exception.nr,
> vcpu->arch.exception.has_error_code,
> vcpu->arch.exception.error_code);
> --
> 1.7.0.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Gleb.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] KVM: Trace exception injection
2010-03-11 11:09 ` Gleb Natapov
@ 2010-03-11 11:51 ` Avi Kivity
2010-03-11 12:31 ` Gleb Natapov
0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2010-03-11 11:51 UTC (permalink / raw)
To: Gleb Natapov; +Cc: kvm
On 03/11/2010 01:09 PM, Gleb Natapov wrote:
> On Thu, Mar 11, 2010 at 01:03:12PM +0200, Avi Kivity wrote:
>
>> Often an exception can help point out where things start to go wrong.
>>
>>
> Adding guest rip where exception happened will be useful too.
>
You get that from the previous kvm_exit trace.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: Trace exception injection
2010-03-11 11:51 ` Avi Kivity
@ 2010-03-11 12:31 ` Gleb Natapov
2010-03-11 12:32 ` Avi Kivity
0 siblings, 1 reply; 5+ messages in thread
From: Gleb Natapov @ 2010-03-11 12:31 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
On Thu, Mar 11, 2010 at 01:51:30PM +0200, Avi Kivity wrote:
> On 03/11/2010 01:09 PM, Gleb Natapov wrote:
> >On Thu, Mar 11, 2010 at 01:03:12PM +0200, Avi Kivity wrote:
> >>Often an exception can help point out where things start to go wrong.
> >>
> >Adding guest rip where exception happened will be useful too.
>
> You get that from the previous kvm_exit trace.
>
Not in a case of emulation ;)
--
Gleb.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: Trace exception injection
2010-03-11 12:31 ` Gleb Natapov
@ 2010-03-11 12:32 ` Avi Kivity
0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2010-03-11 12:32 UTC (permalink / raw)
To: Gleb Natapov; +Cc: kvm
On 03/11/2010 02:31 PM, Gleb Natapov wrote:
> On Thu, Mar 11, 2010 at 01:51:30PM +0200, Avi Kivity wrote:
>
>> On 03/11/2010 01:09 PM, Gleb Natapov wrote:
>>
>>> On Thu, Mar 11, 2010 at 01:03:12PM +0200, Avi Kivity wrote:
>>>
>>>> Often an exception can help point out where things start to go wrong.
>>>>
>>>>
>>> Adding guest rip where exception happened will be useful too.
>>>
>> You get that from the previous kvm_exit trace.
>>
>>
> Not in a case of emulation ;)
>
Then we need an emulator trace. I have it in a branch somewhere, will
reactivate it after your stuff goes in.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-03-11 12:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-11 11:03 [PATCH] KVM: Trace exception injection Avi Kivity
2010-03-11 11:09 ` Gleb Natapov
2010-03-11 11:51 ` Avi Kivity
2010-03-11 12:31 ` Gleb Natapov
2010-03-11 12:32 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox