for_each_online_cpu(i) {
                struct vcpu_info *v = per_cpu(xen_vcpu, i);
                printk("%d: masked=%d pending=%d event_sel %08lx\n  ", i,
-                       (get_irq_regs() && i == cpu) ? !(get_irq_regs()->flags & X86_EFLAGS_IF) : v->evtchn_upcall_mask,
+                       (get_irq_regs() && i == cpu) ? xen_irqs_disabled(get_irq_regs()) : v->evtchn_upcall_mask,
                        v->evtchn_upcall_pending,
                        v->evtchn_pending_sel);
        }
                if (__get_cpu_var(nesting_count)++)
                        goto out;
 
-               /* NB. No need for a barrier here -- XCHG is a barrier on x86. */
+#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */
+               /* Clear master flag /before/ clearing selector flag. */
+               rmb();
+#endif
                pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0);
                while (pending_words != 0) {
                        unsigned long pending_bits;
                                int port = (word_idx * BITS_PER_LONG) + bit_idx;
                                int irq = evtchn_to_irq[port];
 
-                               if (irq != -1) {
-                                       regs->orig_ax = ~irq;
-                                       do_IRQ(regs);
-                               }
+                               if (irq != -1)
+                                       xen_do_IRQ(irq, regs);
                        }
                }
 
 
--- /dev/null
+#ifndef __XEN_EVENTS_H
+#define __XEN_EVENTS_H
+
+enum ipi_vector {
+       XEN_RESCHEDULE_VECTOR,
+       XEN_CALL_FUNCTION_VECTOR,
+
+       XEN_NR_IPIS,
+};
+
+static inline int xen_irqs_disabled(struct pt_regs *regs)
+{
+       return raw_irqs_disabled_flags(regs->flags);
+}
+
+static inline void xen_do_IRQ(int irq, struct pt_regs *regs)
+{
+       regs->orig_ax = ~irq;
+       do_IRQ(regs);
+}
+
+#endif /* __XEN_EVENTS_H */
 
 
 #include <xen/interface/event_channel.h>
 #include <asm/xen/hypercall.h>
-
-enum ipi_vector {
-       XEN_RESCHEDULE_VECTOR,
-       XEN_CALL_FUNCTION_VECTOR,
-
-       XEN_NR_IPIS,
-};
+#include <asm/xen/events.h>
 
 int bind_evtchn_to_irq(unsigned int evtchn);
 int bind_evtchn_to_irqhandler(unsigned int evtchn,