File 19595-hvm-set-callback-irq-level.patch of Package xen

# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1241779812 -3600
# Node ID 2656ab6fa8286832ca7de3082d72e2406097f3ff
# Parent  bf946cc3008bcb927bf28de87160cc4ec2b180c0
x86 hvm: hvm_set_callback_irq_level() must not be called in IRQ
context or with IRQs disabled. Ensure this by deferring to tasklet
(softirq) context if required.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>

--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -685,6 +685,10 @@ int hvm_vcpu_initialise(struct vcpu *v)
     if ( rc != 0 )
         goto fail3;
 
+    tasklet_init(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet,
+                 (void(*)(unsigned long))hvm_assert_evtchn_irq,
+                 (unsigned long)v);
+
     v->arch.guest_context.user_regs.eflags = 2;
 
     if ( v->vcpu_id == 0 )
@@ -714,6 +718,7 @@ int hvm_vcpu_initialise(struct vcpu *v)
 
 void hvm_vcpu_destroy(struct vcpu *v)
 {
+    tasklet_kill(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
     hvm_vcpu_cacheattr_destroy(v);
     vlapic_destroy(v);
     hvm_funcs.vcpu_destroy(v);
--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -185,8 +185,16 @@ void hvm_maybe_deassert_evtchn_irq(void)
 
 void hvm_assert_evtchn_irq(struct vcpu *v)
 {
-    if ( v->vcpu_id == 0 )
-        hvm_set_callback_irq_level(v);
+    if ( v->vcpu_id != 0 )
+        return;
+
+    if ( unlikely(in_irq() || !local_irq_is_enabled()) )
+    {
+        tasklet_schedule(&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet);
+        return;
+    }
+
+    hvm_set_callback_irq_level(v);
 }
 
 void hvm_set_pci_link_route(struct domain *d, u8 link, u8 isa_irq)
--- a/xen/include/asm-x86/hvm/vcpu.h
+++ b/xen/include/asm-x86/hvm/vcpu.h
@@ -65,6 +65,8 @@ struct hvm_vcpu {
         struct arch_svm_struct svm;
     } u;
 
+    struct tasklet      assert_evtchn_irq_tasklet;
+
     struct mtrr_state   mtrr;
     u64                 pat_cr;
 
openSUSE Build Service is sponsored by