posted-interrrupt implementation

来源:互联网 发布:网络女歌手名字 编辑:程序博客网 时间:2024/06/05 01:18
http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg00570.html
- Update posted-interrupt descriptor during vCPU schedulingThe basic idea here is:1. When vCPU's state is RUNSTATE_running,        - Set 'NV' to 'posted_intr_vector'.        - Clear 'SN' to accept posted-interrupts.        - Set 'NDST' to the pCPU on which the vCPU will be running.2. When vCPU's state is RUNSTATE_blocked,        - Set 'NV' to ' pi_wakeup_vector ', so we can wake up the          related vCPU when posted-interrupt happens for it.          Please refer to the above section about the new global vector.        - Clear 'SN' to accept posted-interrupts3. When vCPU's state is RUNSTATE_runnable/RUNSTATE_offline,        - Set 'SN' to suppress non-urgent interrupts          (Current, we only support non-urgent interrupts)         When vCPU is in RUNSTATE_runnable or RUNSTATE_offline,         It is not needed to accept posted-interrupt notification event,         since we don't change the behavior of scheduler when the interrupt         occurs, we still need wait the next scheduling of the vCPU.         When external interrupts from assigned devices occur, the interrupts         are recorded in PIR, and will be synced to IRR before VM-Entry.        - Set 'NV' to 'posted_intr_vector'.
 * Send interrupt to vcpu via posted interrupt way. * 1. If target vcpu is running(non-root mode), send posted interrupt * notification to vcpu and hardware will sync PIR to vIRR atomically. * 2. If target vcpu isn't running(root mode), kick it to pick up the * interrupt from PIR in next vmentry. */static void vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu, int vector){        struct vcpu_vmx *vmx = to_vmx(vcpu);        int r;        r = vmx_deliver_nested_posted_interrupt(vcpu, vector);        if (!r)                return;        if (pi_test_and_set_pir(vector, &vmx->pi_desc))                return;        r = pi_test_and_set_on(&vmx->pi_desc);        kvm_make_request(KVM_REQ_EVENT, vcpu);        if (r || !kvm_vcpu_trigger_posted_interrupt(vcpu))                kvm_vcpu_kick(vcpu);}
如果要给某个vcpu发送ipi的话,也可以通过posted interrrupt方式发送,实现主要就是vmx_delivery_posted_interrupt,如果对方vcpu running,直接通过posted_interrupt_nv中断通知对方,上面注释说硬件会自动帮你把pir 拷贝到 virr里。所以我一直没找到guest怎么把pir解析到vir的。
0 0
原创粉丝点击