On February 08, 2017 2:51 PM, Tian, Kevin wrote: >> From: Xuquan (Quan Xu) [mailto:xuqu...@huawei.com] >> Sent: Monday, January 23, 2017 6:57 PM >> >> On January 20, 2017 5:09 PM, Quan Xu wrote: >> >btw, for PIR.. I find that there might be a bug in >> >__vmx_deliver_posted_interrupt()... >> >why test_and_set_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu)) ?? >> > >> >static void __vmx_deliver_posted_interrupt(struct vcpu *v) { ... >> > if ( !test_and_set_bit(VCPU_KICK_SOFTIRQ, >> >&softirq_pending(cpu)) ... >> >} >> > >> >Suppose that vCPUx is in guest mode, there are two (even more) >> >interrupts to vCPUx.. >> >As the bit is set when delivers the first interrupt... the second >> >interrupt is pending until next VM entry -- by PIR to vIRR.. >> > >> >> Jan , Kevin >> Correct me if I am wrong... >> >> Quan > >I don't quite understand the point here. Can you elaborate? >
Assumed vCPU is in guest_mode.. When apicv is enabled, hypervisor calls vmx_deliver_posted_intr(), then __vmx_deliver_posted_interrupt() to deliver interrupt, but no vmexit (also no vcpu_kick() ).. In __vmx_deliver_posted_interrupt(), it is __conditional__ to deliver posted interrupt. if posted interrupt is not delivered, the posted interrupt is pending until next VM entry -- by PIR to vIRR.. one condition is : In __vmx_deliver_posted_interrupt(), ' if ( !test_and_set_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu))' .. Specifically, we did verify it by RES interrupt, which is used for smp_reschedule_interrupt.. We even cost more time to deliver RES interrupt than no-apicv in average.. If RES interrupt (no. 1) is delivered by posted way (the vcpu is still guest_mode).. when tries to deliver next-coming RES interrupt (no. 2) by posted way, The next-coming RES interrupt (no. 2) is not delivered, as we set the VCPU_KICK_SOFTIRQ bit when we deliver RES interrupt (no. 1).. Then the next-coming RES interrupt (no. 2) is pending until next VM entry -- by PIR to vIRR.. We can fix it as below(I don't think this is a best one, it is better to set the VCPU_KICK_SOFTIRQ bit, but not test it): --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1846,7 +1846,7 @@ static void __vmx_deliver_posted_interrupt(struct vcpu *v) { unsigned int cpu = v->processor; - if ( !test_and_set_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu)) + if ( !test_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu)) && (cpu != smp_processor_id()) ) send_IPI_mask(cpumask_of(cpu), posted_intr_vector); } To be honest, I really spent several days for the original awkward-description:).. Happy Spring Festival!! Quan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel