Skip to content

Commit 0a62a03

Browse files
dmebonzini
authored andcommitted
KVM: x86: Get exit_reason as part of kvm_x86_ops.get_exit_info
Extend the get_exit_info static call to provide the reason for the VM exit. Modify relevant trace points to use this rather than extracting the reason in the caller. Signed-off-by: David Edmondson <[email protected]> Reviewed-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent a9d496d commit 0a62a03

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,10 +1412,11 @@ struct kvm_x86_ops {
14121412
void (*write_tsc_multiplier)(struct kvm_vcpu *vcpu, u64 multiplier);
14131413

14141414
/*
1415-
* Retrieve somewhat arbitrary exit information. Intended to be used
1416-
* only from within tracepoints to avoid VMREADs when tracing is off.
1415+
* Retrieve somewhat arbitrary exit information. Intended to
1416+
* be used only from within tracepoints or error paths.
14171417
*/
1418-
void (*get_exit_info)(struct kvm_vcpu *vcpu, u64 *info1, u64 *info2,
1418+
void (*get_exit_info)(struct kvm_vcpu *vcpu, u32 *reason,
1419+
u64 *info1, u64 *info2,
14191420
u32 *exit_int_info, u32 *exit_int_info_err_code);
14201421

14211422
int (*check_intercept)(struct kvm_vcpu *vcpu,

arch/x86/kvm/svm/svm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3362,11 +3362,13 @@ int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code)
33623362
return svm_exit_handlers[exit_code](vcpu);
33633363
}
33643364

3365-
static void svm_get_exit_info(struct kvm_vcpu *vcpu, u64 *info1, u64 *info2,
3365+
static void svm_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
3366+
u64 *info1, u64 *info2,
33663367
u32 *intr_info, u32 *error_code)
33673368
{
33683369
struct vmcb_control_area *control = &to_svm(vcpu)->vmcb->control;
33693370

3371+
*reason = control->exit_code;
33703372
*info1 = control->exit_info_1;
33713373
*info2 = control->exit_info_2;
33723374
*intr_info = control->exit_int_info;
@@ -3383,7 +3385,7 @@ static int handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
33833385
struct kvm_run *kvm_run = vcpu->run;
33843386
u32 exit_code = svm->vmcb->control.exit_code;
33853387

3386-
trace_kvm_exit(exit_code, vcpu, KVM_ISA_SVM);
3388+
trace_kvm_exit(vcpu, KVM_ISA_SVM);
33873389

33883390
/* SEV-ES guests must use the CR write traps to track CR registers. */
33893391
if (!sev_es_guest(vcpu->kvm)) {
@@ -3396,7 +3398,7 @@ static int handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
33963398
if (is_guest_mode(vcpu)) {
33973399
int vmexit;
33983400

3399-
trace_kvm_nested_vmexit(exit_code, vcpu, KVM_ISA_SVM);
3401+
trace_kvm_nested_vmexit(vcpu, KVM_ISA_SVM);
34003402

34013403
vmexit = nested_svm_exit_special(svm);
34023404

arch/x86/kvm/trace.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ TRACE_EVENT(kvm_apic,
288288

289289
#define TRACE_EVENT_KVM_EXIT(name) \
290290
TRACE_EVENT(name, \
291-
TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa), \
292-
TP_ARGS(exit_reason, vcpu, isa), \
291+
TP_PROTO(struct kvm_vcpu *vcpu, u32 isa), \
292+
TP_ARGS(vcpu, isa), \
293293
\
294294
TP_STRUCT__entry( \
295295
__field( unsigned int, exit_reason ) \
@@ -303,11 +303,12 @@ TRACE_EVENT(name, \
303303
), \
304304
\
305305
TP_fast_assign( \
306-
__entry->exit_reason = exit_reason; \
307306
__entry->guest_rip = kvm_rip_read(vcpu); \
308307
__entry->isa = isa; \
309308
__entry->vcpu_id = vcpu->vcpu_id; \
310-
static_call(kvm_x86_get_exit_info)(vcpu, &__entry->info1, \
309+
static_call(kvm_x86_get_exit_info)(vcpu, \
310+
&__entry->exit_reason, \
311+
&__entry->info1, \
311312
&__entry->info2, \
312313
&__entry->intr_info, \
313314
&__entry->error_code); \

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6066,7 +6066,7 @@ bool nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu)
60666066
goto reflect_vmexit;
60676067
}
60686068

6069-
trace_kvm_nested_vmexit(exit_reason.full, vcpu, KVM_ISA_VMX);
6069+
trace_kvm_nested_vmexit(vcpu, KVM_ISA_VMX);
60706070

60716071
/* If L0 (KVM) wants the exit, it trumps L1's desires. */
60726072
if (nested_vmx_l0_wants_exit(vcpu, exit_reason))

arch/x86/kvm/vmx/vmx.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5658,11 +5658,13 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
56585658
static const int kvm_vmx_max_exit_handlers =
56595659
ARRAY_SIZE(kvm_vmx_exit_handlers);
56605660

5661-
static void vmx_get_exit_info(struct kvm_vcpu *vcpu, u64 *info1, u64 *info2,
5661+
static void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
5662+
u64 *info1, u64 *info2,
56625663
u32 *intr_info, u32 *error_code)
56635664
{
56645665
struct vcpu_vmx *vmx = to_vmx(vcpu);
56655666

5667+
*reason = vmx->exit_reason.full;
56665668
*info1 = vmx_get_exit_qual(vcpu);
56675669
if (!(vmx->exit_reason.failed_vmentry)) {
56685670
*info2 = vmx->idt_vectoring_info;
@@ -6814,7 +6816,7 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)
68146816
if (likely(!vmx->exit_reason.failed_vmentry))
68156817
vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
68166818

6817-
trace_kvm_exit(vmx->exit_reason.full, vcpu, KVM_ISA_VMX);
6819+
trace_kvm_exit(vcpu, KVM_ISA_VMX);
68186820

68196821
if (unlikely(vmx->exit_reason.failed_vmentry))
68206822
return EXIT_FASTPATH_NONE;

0 commit comments

Comments
 (0)