Commit 81601495 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: x86: Use kvm_queue_exception_e() to queue #DF

Queue #DF by recursing on kvm_multiple_exception() by way of
kvm_queue_exception_e() instead of open coding the behavior.  This will
allow KVM to Just Work when a future commit moves exception interception
checks (for L2 => L1) into kvm_multiple_exception().

No functional change intended.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
Link: https://lore.kernel.org/r/20220830231614.3580124-17-seanjc@google.comSigned-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 72c14e00
...@@ -667,25 +667,22 @@ static void kvm_multiple_exception(struct kvm_vcpu *vcpu, ...@@ -667,25 +667,22 @@ static void kvm_multiple_exception(struct kvm_vcpu *vcpu,
} }
class1 = exception_class(prev_nr); class1 = exception_class(prev_nr);
class2 = exception_class(nr); class2 = exception_class(nr);
if ((class1 == EXCPT_CONTRIBUTORY && class2 == EXCPT_CONTRIBUTORY) if ((class1 == EXCPT_CONTRIBUTORY && class2 == EXCPT_CONTRIBUTORY) ||
|| (class1 == EXCPT_PF && class2 != EXCPT_BENIGN)) { (class1 == EXCPT_PF && class2 != EXCPT_BENIGN)) {
/* /*
* Generate double fault per SDM Table 5-5. Set * Synthesize #DF. Clear the previously injected or pending
* exception.pending = true so that the double fault * exception so as not to incorrectly trigger shutdown.
* can trigger a nested vmexit.
*/ */
vcpu->arch.exception.pending = true;
vcpu->arch.exception.injected = false; vcpu->arch.exception.injected = false;
vcpu->arch.exception.has_error_code = true; vcpu->arch.exception.pending = false;
vcpu->arch.exception.vector = DF_VECTOR;
vcpu->arch.exception.error_code = 0; kvm_queue_exception_e(vcpu, DF_VECTOR, 0);
vcpu->arch.exception.has_payload = false; } else {
vcpu->arch.exception.payload = 0;
} else
/* replace previous exception with a new one in a hope /* replace previous exception with a new one in a hope
that instruction re-execution will regenerate lost that instruction re-execution will regenerate lost
exception */ exception */
goto queue; goto queue;
}
} }
void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr) void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr)
......
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