KVM: x86: Trace re-injected exceptions
[ Upstream commit a61d7c5432ac5a953bbcec17af031661c2bd201d ] Trace exceptions that are re-injected, not just those that KVM is injecting for the first time. Debugging re-injection bugs is painful enough as is, not having visibility into what KVM is doing only makes things worse. Delay propagating pending=>injected in the non-reinjection path so that the tracing can properly identify reinjected exceptions. Signed-off-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com> Message-Id: <25470690a38b4d2b32b6204875dd35676c65c9f2.1651440202.git.maciej.szmigiero@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Stable-dep-of: 5623f751bd9c ("KVM: x86: Treat #DBs from the emulator as fault-like (code and DR7.GD=1)") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
8364786152
commit
e5d7c6786b
@@ -304,25 +304,29 @@ TRACE_EVENT(kvm_inj_virq,
|
|||||||
* Tracepoint for kvm interrupt injection:
|
* Tracepoint for kvm interrupt injection:
|
||||||
*/
|
*/
|
||||||
TRACE_EVENT(kvm_inj_exception,
|
TRACE_EVENT(kvm_inj_exception,
|
||||||
TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
|
TP_PROTO(unsigned exception, bool has_error, unsigned error_code,
|
||||||
TP_ARGS(exception, has_error, error_code),
|
bool reinjected),
|
||||||
|
TP_ARGS(exception, has_error, error_code, reinjected),
|
||||||
|
|
||||||
TP_STRUCT__entry(
|
TP_STRUCT__entry(
|
||||||
__field( u8, exception )
|
__field( u8, exception )
|
||||||
__field( u8, has_error )
|
__field( u8, has_error )
|
||||||
__field( u32, error_code )
|
__field( u32, error_code )
|
||||||
|
__field( bool, reinjected )
|
||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
__entry->exception = exception;
|
__entry->exception = exception;
|
||||||
__entry->has_error = has_error;
|
__entry->has_error = has_error;
|
||||||
__entry->error_code = error_code;
|
__entry->error_code = error_code;
|
||||||
|
__entry->reinjected = reinjected;
|
||||||
),
|
),
|
||||||
|
|
||||||
TP_printk("%s (0x%x)",
|
TP_printk("%s (0x%x)%s",
|
||||||
__print_symbolic(__entry->exception, kvm_trace_sym_exc),
|
__print_symbolic(__entry->exception, kvm_trace_sym_exc),
|
||||||
/* FIXME: don't print error_code if not present */
|
/* FIXME: don't print error_code if not present */
|
||||||
__entry->has_error ? __entry->error_code : 0)
|
__entry->has_error ? __entry->error_code : 0,
|
||||||
|
__entry->reinjected ? " [reinjected]" : "")
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -8347,6 +8347,11 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu)
|
|||||||
|
|
||||||
static void kvm_inject_exception(struct kvm_vcpu *vcpu)
|
static void kvm_inject_exception(struct kvm_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
|
trace_kvm_inj_exception(vcpu->arch.exception.nr,
|
||||||
|
vcpu->arch.exception.has_error_code,
|
||||||
|
vcpu->arch.exception.error_code,
|
||||||
|
vcpu->arch.exception.injected);
|
||||||
|
|
||||||
if (vcpu->arch.exception.error_code && !is_protmode(vcpu))
|
if (vcpu->arch.exception.error_code && !is_protmode(vcpu))
|
||||||
vcpu->arch.exception.error_code = false;
|
vcpu->arch.exception.error_code = false;
|
||||||
kvm_x86_ops.queue_exception(vcpu);
|
kvm_x86_ops.queue_exception(vcpu);
|
||||||
@@ -8404,13 +8409,6 @@ static void inject_pending_event(struct kvm_vcpu *vcpu, bool *req_immediate_exit
|
|||||||
|
|
||||||
/* try to inject new event if pending */
|
/* try to inject new event if pending */
|
||||||
if (vcpu->arch.exception.pending) {
|
if (vcpu->arch.exception.pending) {
|
||||||
trace_kvm_inj_exception(vcpu->arch.exception.nr,
|
|
||||||
vcpu->arch.exception.has_error_code,
|
|
||||||
vcpu->arch.exception.error_code);
|
|
||||||
|
|
||||||
vcpu->arch.exception.pending = false;
|
|
||||||
vcpu->arch.exception.injected = true;
|
|
||||||
|
|
||||||
if (exception_type(vcpu->arch.exception.nr) == EXCPT_FAULT)
|
if (exception_type(vcpu->arch.exception.nr) == EXCPT_FAULT)
|
||||||
__kvm_set_rflags(vcpu, kvm_get_rflags(vcpu) |
|
__kvm_set_rflags(vcpu, kvm_get_rflags(vcpu) |
|
||||||
X86_EFLAGS_RF);
|
X86_EFLAGS_RF);
|
||||||
@@ -8424,6 +8422,10 @@ static void inject_pending_event(struct kvm_vcpu *vcpu, bool *req_immediate_exit
|
|||||||
}
|
}
|
||||||
|
|
||||||
kvm_inject_exception(vcpu);
|
kvm_inject_exception(vcpu);
|
||||||
|
|
||||||
|
vcpu->arch.exception.pending = false;
|
||||||
|
vcpu->arch.exception.injected = true;
|
||||||
|
|
||||||
can_inject = false;
|
can_inject = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user