-/* $OpenBSD: xen.c,v 1.59 2016/08/03 14:55:57 mikeb Exp $ */
+/* $OpenBSD: xen.c,v 1.60 2016/08/03 17:14:41 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
SLIST_INSERT_HEAD(&sc->sc_intrs, xi, xi_entry);
/* Mask the event port */
- setbit((char *)&sc->sc_ipg->evtchn_mask[0], xi->xi_port);
+ atomic_setbit_ptr(&sc->sc_ipg->evtchn_mask[0], xi->xi_port);
#if defined(XEN_DEBUG) && disabled
memset(&es, 0, sizeof(es));
taskq_destroy(xi->xi_taskq);
- setbit((char *)&sc->sc_ipg->evtchn_mask[0], xi->xi_port);
- clrbit((char *)&sc->sc_ipg->evtchn_pending[0], xi->xi_port);
- virtio_membar_sync();
+ atomic_setbit_ptr(&sc->sc_ipg->evtchn_mask[0], xi->xi_port);
+ atomic_clearbit_ptr(&sc->sc_ipg->evtchn_pending[0], xi->xi_port);
if (!xi->xi_noclose) {
ec.port = xi->xi_port;
if ((xi = xen_lookup_intsrc(sc, port)) != NULL) {
xi->xi_masked = 1;
- setbit((char *)&sc->sc_ipg->evtchn_mask[0], xi->xi_port);
- virtio_membar_sync();
+ atomic_setbit_ptr(&sc->sc_ipg->evtchn_mask[0], xi->xi_port);
}
}
-/* $OpenBSD: xenvar.h,v 1.34 2016/08/03 14:55:58 mikeb Exp $ */
+/* $OpenBSD: xenvar.h,v 1.35 2016/08/03 17:14:41 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
struct xs_softc *xst_sc;
};
+static inline int
+atomic_setbit_ptr(volatile void *ptr, int bit)
+{
+ int obit;
+
+ __asm__ __volatile__ ("lock btsl %2,%1; sbbl %0,%0" :
+ "=r" (obit), "=m" (*(volatile long *)ptr) : "Ir" (bit) :
+ "memory");
+
+ return (obit);
+}
+
static inline int
atomic_clearbit_ptr(volatile void *ptr, int bit)
{