From: Yang Zhang <yang.z.zhang@xxxxxxxxx> Hi Ingo and Peter, The second patch (2/5 KVM: VMX: Register a new IPI for posted interrupt) tries to register an new IPI for posted interrupt which is used by KVM. Please help to review it. The follwoing patches are adding the Posted Interrupt supporting to KVM: The first patch enables the feature 'acknowledge interrupt on vmexit'.Since it is required by Posted interrupt, we need to enable it firstly. And the subsequent patches are adding the posted interrupt supporting: Posted Interrupt allows APIC interrupts to inject into guest directly without any vmexit. - When delivering a interrupt to guest, if target vcpu is running, update Posted-interrupt requests bitmap and send a notification event to the vcpu. Then the vcpu will handle this interrupt automatically, without any software involvemnt. - If target vcpu is not running or there already a notification event pending in the vcpu, do nothing. The interrupt will be handled by next vm entry NOTE: We don't turn on the Posted Interrupt until the coalesced issue is solved. Changes from v4 to v5: * Add per cpu count for posted IPI handler. * Dont' check irr when delivering interrupt. Since we can not get interrupt coalesced info with Posted Interrupt. So there is no need to check the irr. There is another patch will changed current interrupt coalesced logic. Before it, we will not turn on Posted Interrupt. * Clear outstanding notification bit after call local_irq_disable, but before check request. As Marcelo suggested, we can ensure the IPI not lost in this way * Remove the spinlock. Same as item 2, if not need to get coalesced info, then no need the lock. * Split Posted Interrupt patch to five small patches. * Rebase on top of KVM upstream. Changes from v3 to v4: * Clear up the vmx_handle_external_interrupt() to make the code more cleanliness and clear. * Use lock to protect the access of pir. * Check pending interrupt in pir firstly in vmx_deliver_posted_interrupt(). Since hardware will sync pir->irr, if check irr firstly, then the irr may be modified after the checking, and we also cannot see it in the following check of pir. * Wrap the operation of sync pir to irr to a function kvm_apic_update_irr(), and call it from vmx_sync_pir_to_irr. * Use irr |= pir directly instead using cmpxchg. Since hardware cannot perform pir->irr at this point, so it is safe to use 'or' to sync pir to irr. Changes from v2 to v3: * Add CONFIG_HAVE_KVM check when calling BUILD_INTERRUPT for posted interrupt. * Rename send_notification_event() to deliver_posted_interrupt(). * Modify the algorithm of calculating interrupt coalescence: interrupt will be considered as delivered only when there is no previous interrupt pending in both irr and pir. * Remove using new request to sync pir to irr, use KVM_REQ_EVENT for instead. * Remove the optimization of checking outsanding notification bit after sending posted interrupt to remote cpu. * Embed pi_desc inside struct vmx instead allocating it dynamically. * Rebase on top of KVM upstream. Yang Zhang (5): KVM: VMX: enable acknowledge interupt on vmexit KVM: VMX: Register a new IPI for posted interrupt KVM: VMX: Check the posted interrupt capability KVM: VMX: Add the algorithm of deliver posted interrupt KVM : VMX: Use posted interrupt to deliver virtual interrupt arch/x86/include/asm/entry_arch.h | 4 + arch/x86/include/asm/hardirq.h | 3 + arch/x86/include/asm/hw_irq.h | 1 + arch/x86/include/asm/irq_vectors.h | 5 + arch/x86/include/asm/kvm_host.h | 4 + arch/x86/include/asm/vmx.h | 4 + arch/x86/kernel/entry_64.S | 5 + arch/x86/kernel/irq.c | 22 ++++ arch/x86/kernel/irqinit.c | 4 + arch/x86/kvm/irq.c | 2 +- arch/x86/kvm/lapic.c | 29 +++++- arch/x86/kvm/lapic.h | 2 + arch/x86/kvm/svm.c | 24 ++++ arch/x86/kvm/vmx.c | 205 +++++++++++++++++++++++++++++++---- arch/x86/kvm/x86.c | 8 ++- virt/kvm/kvm_main.c | 1 + 16 files changed, 294 insertions(+), 29 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html