Skip to contentSkip to conversation

inject call back irq when there are event pending

PATCH New Xiaofeng Ling 1 participant 1 message Sep 5, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 5/6 inject call back irq when there are event pending

Inject call back irq when there are event pending.
If there are still event pending after dealing with the device model evtchn, then these are for virtual device(ctrl_if, xenbus, blfront,etc) so inject the call back irq.
The irq handler in event channel pci device will deliver the event to frontend driver.

xen/arch/x86/vmx_io.c +49 -0
diff -r 287d36b46fa3 xen/arch/x86/vmx_io.c
@@ -631,6 +631,51 @@
     return ((eflags & X86_EFLAGS_IF) == 0);
 }
 
+int vmx_event_to_irq(struct vcpu *v)
+{
+
+    global_iodata_t *spg;
+    unsigned long callback_irq;
+
+    spg = &get_sp(v->domain)->sp_global;
+
+    callback_irq = v->domain->arch.vmx_platform.callback_irq;
+    if(unlikely( callback_irq == 0)) {
+        printk("try to inject callback =0!!!\n");
+        printk("pending: %x, sel: %x, pending[0]:%x\n",
+               v->vcpu_info->evtchn_upcall_pending,
+               v->vcpu_info->evtchn_pending_sel,
+               v->domain->shared_info->evtchn_pending[0]);
+        return 0;
+    }
+
+    /*
+     * the event is only for guest, just set callback interrupt
+     * bit  and return
+     */
+
+    return test_and_set_bit(callback_irq, &spg->pic_intr[0]);
+
+}
+
+void vmx_check_guest_event(struct vcpu *v)
+{
+
+    int port = iopacket_port(v->domain);
+
+    if (!v->domain->shared_info->evtchn_pending[port>>5])
+        clear_bit(port>>5, &v->vcpu_info->evtchn_pending_sel);
+
+    /* Note: VMX domains may need upcalls as well */
+    if (!v->vcpu_info->evtchn_pending_sel)
+        v->vcpu_info->evtchn_upcall_pending = 0;
+
+    if(event_pending(v) && !v->vcpu_info->callback_mask &&
+       !test_bit(port, &v->domain->shared_info->evtchn_pending[0]) )
+        vmx_event_to_irq(v);
+}
+
+
 asmlinkage void vmx_intr_assist(void)
 {
     int intr_type = 0;
@@ -640,6 +685,10 @@
 
     highest_vector = find_highest_pending_irq(v, &intr_type);
     __vmread(CPU_BASED_VM_EXEC_CONTROL, &cpu_exec_control);
+
+    vmx_check_guest_event(v); /*inject para-device call back irq*/
+
+    highest_vector = find_highest_pending_irq(v, &intr_type);
 
     if (highest_vector == -1) {
         disable_irq_window(cpu_exec_control);