diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index dee62362a360..24029ecc77b1 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1437,6 +1438,13 @@ static int svm_check_nested_events(struct kvm_vcpu *vcpu) bool block_nested_events = block_nested_exceptions || kvm_event_needs_reinjection(vcpu); + if (kvm_test_request(KVM_REQ_TRIPLE_FAULT, vcpu)) { + if (block_nested_exceptions) // or events? + return -EBUSY; + nested_svm_triple_fault(vcpu); + return 0; + } + if (lapic_in_kernel(vcpu) && test_bit(KVM_APIC_INIT, &apic->pending_events)) { if (block_nested_events) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 6329a306856b..7ca99e746808 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4114,6 +4114,13 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu) bool block_nested_events = block_nested_exceptions || kvm_event_needs_reinjection(vcpu); + if (kvm_test_request(KVM_REQ_TRIPLE_FAULT, vcpu)) { + if (block_nested_exceptions) // or events? + return -EBUSY; + nested_vmx_triple_fault(vcpu); + return 0; + } + if (lapic_in_kernel(vcpu) && test_bit(KVM_APIC_INIT, &apic->pending_events)) { if (block_nested_events) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8746530930d5..9094c5efd493 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10203,11 +10203,6 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu) int kvm_check_nested_events(struct kvm_vcpu *vcpu) { - if (kvm_test_request(KVM_REQ_TRIPLE_FAULT, vcpu)) { - kvm_x86_ops.nested_ops->triple_fault(vcpu); - return 1; - } - return kvm_x86_ops.nested_ops->check_events(vcpu); } @@ -10285,6 +10280,12 @@ static int kvm_check_and_inject_events(struct kvm_vcpu *vcpu, else r = 0; + if (kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)) { + vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN; + vcpu->mmio_needed = 0; + return -ENXIO; + } + /* * Re-inject exceptions and events *especially* if immediate entry+exit * to/from L2 is needed, as any event that has already been injected @@ -10781,15 +10782,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) goto out; } if (kvm_test_request(KVM_REQ_TRIPLE_FAULT, vcpu)) { - if (is_guest_mode(vcpu)) - kvm_x86_ops.nested_ops->triple_fault(vcpu); - - if (kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)) { - vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN; - vcpu->mmio_needed = 0; - r = 0; - goto out; - } + kvm_make_request(KVM_REQ_EVENT, vcpu); } if (kvm_check_request(KVM_REQ_APF_HALT, vcpu)) { /* Page is swapped out. Do synthetic halt */