On 24/12/2017 17:13, Liran Alon wrote: > +static bool vmx_cpu_has_nested_posted_interrupt(struct kvm_vcpu *vcpu) > +{ > + struct vcpu_vmx *vmx = to_vmx(vcpu); > + > + return (vcpu->arch.apicv_active && > + is_guest_mode(vcpu) && > + vmx->nested.pi_pending && > + vmx->nested.pi_desc && > + pi_test_on(vmx->nested.pi_desc)); > +} > + > /* > * Set up the vmcs's constant host-state fields, i.e., host-state fields that > * will not change in the lifetime of the guest. > @@ -12142,6 +12153,8 @@ static int enable_smi_window(struct kvm_vcpu *vcpu) > .deliver_posted_interrupt = vmx_deliver_posted_interrupt, > .complete_nested_posted_interrupt = > vmx_complete_nested_posted_interrupt, > + .cpu_has_nested_posted_interrupt = > + vmx_cpu_has_nested_posted_interrupt, > > .set_tss_addr = vmx_set_tss_addr, > .get_tdp_level = get_ept_level, > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index fa088951afc9..a840f2c9bd66 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -8542,7 +8542,8 @@ static inline bool kvm_vcpu_has_events(struct kvm_vcpu *vcpu) > return true; > > if (kvm_arch_interrupt_allowed(vcpu) && > - kvm_cpu_has_interrupt(vcpu)) > + (kvm_cpu_has_interrupt(vcpu) || > + kvm_x86_ops->cpu_has_nested_posted_interrupt(vcpu))) > return true; kvm_cpu_has_interrupt ultimately calls apic_has_interrupt_for_ppr, which calls kvm_x86_ops->sync_pir_to_irr. You already have + if (is_guest_mode(vcpu)) + kvm_x86_ops->complete_nested_posted_interrupt(vcpu); earlier in the series right after a call to kvm_x86_ops->sync_pir_to_irr. So I wonder if: 1) kvm_x86_ops->complete_nested_posted_interrupt would do the job here as well, removing the need for the new kvm_x86_ops member; 2) The call to kvm_x86_ops->complete_nested_posted_interrupt actually applies to all callers of sync_pir_to_irr, which would remove the need for that other kvm_x86_ops member. I'm leaning towards applying patches 1-4, what do you think? Paolo