From f7d376afdbf27a679ddeb78fd89a8c6cf653fb5d Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <roger.pau@citrix.com>
Date: Thu, 19 Jun 2014 13:06:04 +0200
Subject: [PATCH v5 02/29] xen: mask all event channels on init

Mask all event channels, this is done so that we don't receive
spurious interrupts while dinamically registering new event channels,
because there's a small window during registration where an event
channel can fire before we have attached a handler to it.

Approved by: xxx
Sponsored by: Citrix Systems R&D

x86/xen/xen_intr.c:
 - Mask all event channels on init.
---
 sys/x86/xen/xen_intr.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c
index bf94168..d148798 100644
--- a/sys/x86/xen/xen_intr.c
+++ b/sys/x86/xen/xen_intr.c
@@ -584,6 +584,7 @@ xen_intr_handle_upcall(struct trapframe *trap_frame)
 static int
 xen_intr_init(void *dummy __unused)
 {
+	shared_info_t *s = HYPERVISOR_shared_info;
 	struct xen_intr_pcpu_data *pcpu;
 	struct physdev_pirq_eoi_gmfn eoi_gmfn;
 	int i, rc;
@@ -607,6 +608,9 @@ xen_intr_init(void *dummy __unused)
 		xen_intr_intrcnt_add(i);
 	}
 
+	for (i = 0; i < nitems(s->evtchn_mask); i++)
+		atomic_store_rel_long(&s->evtchn_mask[i], ~0);
+
 	/* Try to register PIRQ EOI map */
 	xen_intr_pirq_eoi_map = malloc(PAGE_SIZE, M_XENINTR, M_WAITOK | M_ZERO);
 	eoi_gmfn.gmfn = atop(vtophys(xen_intr_pirq_eoi_map));
-- 
1.7.7.5 (Apple Git-26)

