mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
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>
This commit is contained in:
parent
217463aa32
commit
2450c97745
|
|
@ -3467,23 +3467,13 @@ static void dump_vmcb(struct kvm_vcpu *vcpu)
|
|||
sev_free_decrypted_vmsa(vcpu, save);
|
||||
}
|
||||
|
||||
static bool svm_check_exit_valid(u64 exit_code)
|
||||
{
|
||||
return (exit_code < ARRAY_SIZE(svm_exit_handlers) &&
|
||||
svm_exit_handlers[exit_code]);
|
||||
}
|
||||
|
||||
static int svm_handle_invalid_exit(struct kvm_vcpu *vcpu, u64 exit_code)
|
||||
{
|
||||
dump_vmcb(vcpu);
|
||||
kvm_prepare_unexpected_reason_exit(vcpu, exit_code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code)
|
||||
{
|
||||
if (!svm_check_exit_valid(exit_code))
|
||||
return svm_handle_invalid_exit(vcpu, exit_code);
|
||||
if (exit_code >= ARRAY_SIZE(svm_exit_handlers))
|
||||
goto unexpected_vmexit;
|
||||
|
||||
if (!svm_exit_handlers[exit_code])
|
||||
goto unexpected_vmexit;
|
||||
|
||||
#ifdef CONFIG_MITIGATION_RETPOLINE
|
||||
if (exit_code == SVM_EXIT_MSR)
|
||||
|
|
@ -3502,6 +3492,11 @@ int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code)
|
|||
#endif
|
||||
#endif
|
||||
return svm_exit_handlers[exit_code](vcpu);
|
||||
|
||||
unexpected_vmexit:
|
||||
dump_vmcb(vcpu);
|
||||
kvm_prepare_unexpected_reason_exit(vcpu, exit_code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void svm_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user