Skip to content

Commit 2450c97

Browse files
committed
KVM: SVM: Open code handling of unexpected exits in svm_invoke_exit_handler()
Fold svm_check_exit_valid() and svm_handle_invalid_exit() into their sole caller, svm_invoke_exit_handler(), as having tiny single-use helpers makes the code unncessarily difficult to follow. This will also allow for additional cleanups in svm_invoke_exit_handler(). No functional change intended. Suggested-by: Yosry Ahmed <yosry.ahmed@linux.dev> Reviewed-by: Yosry Ahmed <yosry.ahmed@linux.dev> Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com> Link: https://patch.msgid.link/20251230211347.4099600-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 217463a commit 2450c97

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

arch/x86/kvm/svm/svm.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,23 +3467,13 @@ static void dump_vmcb(struct kvm_vcpu *vcpu)
34673467
sev_free_decrypted_vmsa(vcpu, save);
34683468
}
34693469

3470-
static bool svm_check_exit_valid(u64 exit_code)
3471-
{
3472-
return (exit_code < ARRAY_SIZE(svm_exit_handlers) &&
3473-
svm_exit_handlers[exit_code]);
3474-
}
3475-
3476-
static int svm_handle_invalid_exit(struct kvm_vcpu *vcpu, u64 exit_code)
3477-
{
3478-
dump_vmcb(vcpu);
3479-
kvm_prepare_unexpected_reason_exit(vcpu, exit_code);
3480-
return 0;
3481-
}
3482-
34833470
int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code)
34843471
{
3485-
if (!svm_check_exit_valid(exit_code))
3486-
return svm_handle_invalid_exit(vcpu, exit_code);
3472+
if (exit_code >= ARRAY_SIZE(svm_exit_handlers))
3473+
goto unexpected_vmexit;
3474+
3475+
if (!svm_exit_handlers[exit_code])
3476+
goto unexpected_vmexit;
34873477

34883478
#ifdef CONFIG_MITIGATION_RETPOLINE
34893479
if (exit_code == SVM_EXIT_MSR)
@@ -3502,6 +3492,11 @@ int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code)
35023492
#endif
35033493
#endif
35043494
return svm_exit_handlers[exit_code](vcpu);
3495+
3496+
unexpected_vmexit:
3497+
dump_vmcb(vcpu);
3498+
kvm_prepare_unexpected_reason_exit(vcpu, exit_code);
3499+
return 0;
35053500
}
35063501

35073502
static void svm_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,

0 commit comments

Comments
 (0)