Commit 7a4bca85 authored by Maxim Levitsky's avatar Maxim Levitsky Committed by Paolo Bonzini

KVM: SVM: split svm_handle_invalid_exit

Split the check for having a vmexit handler to svm_check_exit_valid,
and make svm_handle_invalid_exit only handle a vmexit that is
already not valid.
Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20210811122927.900604-2-mlevitsk@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 9653f2da
...@@ -3236,12 +3236,14 @@ static void dump_vmcb(struct kvm_vcpu *vcpu) ...@@ -3236,12 +3236,14 @@ static void dump_vmcb(struct kvm_vcpu *vcpu)
"excp_to:", save->last_excp_to); "excp_to:", save->last_excp_to);
} }
static int svm_handle_invalid_exit(struct kvm_vcpu *vcpu, u64 exit_code) static bool svm_check_exit_valid(struct kvm_vcpu *vcpu, u64 exit_code)
{ {
if (exit_code < ARRAY_SIZE(svm_exit_handlers) && return (exit_code < ARRAY_SIZE(svm_exit_handlers) &&
svm_exit_handlers[exit_code]) svm_exit_handlers[exit_code]);
return 0; }
static int svm_handle_invalid_exit(struct kvm_vcpu *vcpu, u64 exit_code)
{
vcpu_unimpl(vcpu, "svm: unexpected exit reason 0x%llx\n", exit_code); vcpu_unimpl(vcpu, "svm: unexpected exit reason 0x%llx\n", exit_code);
dump_vmcb(vcpu); dump_vmcb(vcpu);
vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
...@@ -3249,14 +3251,13 @@ static int svm_handle_invalid_exit(struct kvm_vcpu *vcpu, u64 exit_code) ...@@ -3249,14 +3251,13 @@ static int svm_handle_invalid_exit(struct kvm_vcpu *vcpu, u64 exit_code)
vcpu->run->internal.ndata = 2; vcpu->run->internal.ndata = 2;
vcpu->run->internal.data[0] = exit_code; vcpu->run->internal.data[0] = exit_code;
vcpu->run->internal.data[1] = vcpu->arch.last_vmentry_cpu; vcpu->run->internal.data[1] = vcpu->arch.last_vmentry_cpu;
return 0;
return -EINVAL;
} }
int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code) int svm_invoke_exit_handler(struct kvm_vcpu *vcpu, u64 exit_code)
{ {
if (svm_handle_invalid_exit(vcpu, exit_code)) if (!svm_check_exit_valid(vcpu, exit_code))
return 0; return svm_handle_invalid_exit(vcpu, exit_code);
#ifdef CONFIG_RETPOLINE #ifdef CONFIG_RETPOLINE
if (exit_code == SVM_EXIT_MSR) if (exit_code == SVM_EXIT_MSR)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment