aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index a45bcac45645..738262595706 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5821,8 +5821,10 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu)
5821 kvm_x86_ops->update_cr8_intercept(vcpu, tpr, max_irr); 5821 kvm_x86_ops->update_cr8_intercept(vcpu, tpr, max_irr);
5822} 5822}
5823 5823
5824static void inject_pending_event(struct kvm_vcpu *vcpu) 5824static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win)
5825{ 5825{
5826 int r;
5827
5826 /* try to reinject previous events if any */ 5828 /* try to reinject previous events if any */
5827 if (vcpu->arch.exception.pending) { 5829 if (vcpu->arch.exception.pending) {
5828 trace_kvm_inj_exception(vcpu->arch.exception.nr, 5830 trace_kvm_inj_exception(vcpu->arch.exception.nr,
@@ -5832,17 +5834,23 @@ static void inject_pending_event(struct kvm_vcpu *vcpu)
5832 vcpu->arch.exception.has_error_code, 5834 vcpu->arch.exception.has_error_code,
5833 vcpu->arch.exception.error_code, 5835 vcpu->arch.exception.error_code,
5834 vcpu->arch.exception.reinject); 5836 vcpu->arch.exception.reinject);
5835 return; 5837 return 0;
5836 } 5838 }
5837 5839
5838 if (vcpu->arch.nmi_injected) { 5840 if (vcpu->arch.nmi_injected) {
5839 kvm_x86_ops->set_nmi(vcpu); 5841 kvm_x86_ops->set_nmi(vcpu);
5840 return; 5842 return 0;
5841 } 5843 }
5842 5844
5843 if (vcpu->arch.interrupt.pending) { 5845 if (vcpu->arch.interrupt.pending) {
5844 kvm_x86_ops->set_irq(vcpu); 5846 kvm_x86_ops->set_irq(vcpu);
5845 return; 5847 return 0;
5848 }
5849
5850 if (is_guest_mode(vcpu) && kvm_x86_ops->check_nested_events) {
5851 r = kvm_x86_ops->check_nested_events(vcpu, req_int_win);
5852 if (r != 0)
5853 return r;
5846 } 5854 }
5847 5855
5848 /* try to inject new event if pending */ 5856 /* try to inject new event if pending */
@@ -5859,6 +5867,7 @@ static void inject_pending_event(struct kvm_vcpu *vcpu)
5859 kvm_x86_ops->set_irq(vcpu); 5867 kvm_x86_ops->set_irq(vcpu);
5860 } 5868 }
5861 } 5869 }
5870 return 0;
5862} 5871}
5863 5872
5864static void process_nmi(struct kvm_vcpu *vcpu) 5873static void process_nmi(struct kvm_vcpu *vcpu)
@@ -5963,10 +5972,10 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
5963 goto out; 5972 goto out;
5964 } 5973 }
5965 5974
5966 inject_pending_event(vcpu); 5975 if (inject_pending_event(vcpu, req_int_win) != 0)
5967 5976 req_immediate_exit = true;
5968 /* enable NMI/IRQ window open exits if needed */ 5977 /* enable NMI/IRQ window open exits if needed */
5969 if (vcpu->arch.nmi_pending) 5978 else if (vcpu->arch.nmi_pending)
5970 req_immediate_exit = 5979 req_immediate_exit =
5971 kvm_x86_ops->enable_nmi_window(vcpu) != 0; 5980 kvm_x86_ops->enable_nmi_window(vcpu) != 0;
5972 else if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win) 5981 else if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win)
@@ -7296,6 +7305,9 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
7296 7305
7297int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) 7306int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
7298{ 7307{
7308 if (is_guest_mode(vcpu) && kvm_x86_ops->check_nested_events)
7309 kvm_x86_ops->check_nested_events(vcpu, false);
7310
7299 return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE && 7311 return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE &&
7300 !vcpu->arch.apf.halted) 7312 !vcpu->arch.apf.halted)
7301 || !list_empty_careful(&vcpu->async_pf.done) 7313 || !list_empty_careful(&vcpu->async_pf.done)