Replace x86 memory fences in Xen drivers by their Xen equivalents, to reduce
MD dependency: x86_lfence() => xen_rmb() x86_sfence() => xen_wmb() x86_mfence() => xen_mb() Discussed in http://mail-index.netbsd.org/port-xen/2009/01/15/msg004655.html Ok by bouyer@.
This commit is contained in:
parent
c99586fc4a
commit
f0ba6e4c1b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xen.h,v 1.7 2008/04/21 15:15:34 cegger Exp $ */
|
||||
/* $NetBSD: xen.h,v 1.8 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, K A Fraser
|
||||
@ -43,6 +43,12 @@
|
||||
#error "Unsupported architecture"
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#define xen_mb() x86_mfence()
|
||||
#define xen_rmb() x86_lfence()
|
||||
#define xen_wmb() x86_sfence()
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XEN "SYSTEM CALLS" (a.k.a. HYPERCALLS).
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xen_intr.c,v 1.8 2008/07/01 18:44:50 bouyer Exp $ */
|
||||
/* $NetBSD: xen_intr.c,v 1.9 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.8 2008/07/01 18:44:50 bouyer Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.9 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
@ -107,7 +107,7 @@ x86_write_psl(u_long psl)
|
||||
struct cpu_info *ci = curcpu();
|
||||
|
||||
ci->ci_vcpu->evtchn_upcall_mask = psl;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
if (ci->ci_vcpu->evtchn_upcall_pending && psl == 0) {
|
||||
hypervisor_force_callback();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clock.c,v 1.48 2008/11/13 18:44:51 cegger Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.49 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
@ -34,7 +34,7 @@
|
||||
#include "opt_xen.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.48 2008/11/13 18:44:51 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.49 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -108,30 +108,30 @@ get_time_values_from_xen(void)
|
||||
|
||||
do {
|
||||
shadow_time_version = t->version;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
shadow_tsc_stamp = t->tsc_timestamp;
|
||||
shadow_system_time = t->system_time;
|
||||
shadow_freq_mul = t->tsc_to_system_mul;
|
||||
shadow_freq_shift = t->tsc_shift;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
} while ((t->version & 1) || (shadow_time_version != t->version));
|
||||
do {
|
||||
tversion = HYPERVISOR_shared_info->wc_version;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
shadow_ts.tv_sec = HYPERVISOR_shared_info->wc_sec;
|
||||
shadow_ts.tv_nsec = HYPERVISOR_shared_info->wc_nsec;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
} while ((HYPERVISOR_shared_info->wc_version & 1) ||
|
||||
(tversion != HYPERVISOR_shared_info->wc_version));
|
||||
#else /* XEN3 */
|
||||
do {
|
||||
shadow_time_version = HYPERVISOR_shared_info->time_version2;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
shadow_ts.tv_sec = HYPERVISOR_shared_info->wc_sec;
|
||||
shadow_ts.tv_nsec = HYPERVISOR_shared_info->wc_usec;
|
||||
shadow_tsc_stamp = HYPERVISOR_shared_info->tsc_timestamp;
|
||||
shadow_system_time = HYPERVISOR_shared_info->system_time;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
} while (shadow_time_version != HYPERVISOR_shared_info->time_version1);
|
||||
shadow_ts.tv_nsec *= 1000;
|
||||
#endif
|
||||
@ -145,13 +145,13 @@ time_values_up_to_date(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
#ifndef XEN3
|
||||
rv = shadow_time_version == HYPERVISOR_shared_info->time_version1;
|
||||
#else
|
||||
rv = shadow_time_version == curcpu()->ci_vcpu->time.version;
|
||||
#endif
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ctrl_if.c,v 1.20 2008/12/18 12:19:03 cegger Exp $ */
|
||||
/* $NetBSD: ctrl_if.c,v 1.21 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/******************************************************************************
|
||||
* ctrl_if.c
|
||||
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ctrl_if.c,v 1.20 2008/12/18 12:19:03 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ctrl_if.c,v 1.21 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -90,7 +90,7 @@ __ctrl_if_tx_tasklet(unsigned long data)
|
||||
CONTROL_RING_IDX rp;
|
||||
|
||||
rp = ctrl_if->tx_resp_prod;
|
||||
x86_lfence(); /* Ensure we see all requests up to 'rp'. */
|
||||
xen_rmb(); /* Ensure we see all requests up to 'rp'. */
|
||||
|
||||
while ( ctrl_if_tx_resp_cons != rp )
|
||||
{
|
||||
@ -135,7 +135,7 @@ __ctrl_if_rxmsg_deferred(void *unused)
|
||||
while (1) {
|
||||
s = splsoftnet();
|
||||
dp = ctrl_if_rxmsg_deferred_prod;
|
||||
x86_lfence(); /* Ensure we see all requests up to 'dp'. */
|
||||
xen_rmb(); /* Ensure we see all requests up to 'dp'. */
|
||||
if (ctrl_if_rxmsg_deferred_cons == dp) {
|
||||
tsleep(&ctrl_if_rxmsg_deferred_cons, PRIBIO,
|
||||
"rxdef", 0);
|
||||
@ -163,7 +163,7 @@ __ctrl_if_rx_tasklet(unsigned long data)
|
||||
|
||||
dp = ctrl_if_rxmsg_deferred_prod;
|
||||
rp = ctrl_if->rx_req_prod;
|
||||
x86_lfence(); /* Ensure we see all requests up to 'rp'. */
|
||||
xen_rmb(); /* Ensure we see all requests up to 'rp'. */
|
||||
|
||||
while ( ctrl_if_rx_req_cons != rp )
|
||||
{
|
||||
@ -192,7 +192,7 @@ __ctrl_if_rx_tasklet(unsigned long data)
|
||||
(*ctrl_if_rxmsg_handler[msg.type])(&msg, 0);
|
||||
/* update rp, in case the console polling code was used */
|
||||
rp = ctrl_if->rx_req_prod;
|
||||
x86_lfence(); /* Ensure we see all requests up to 'rp'. */
|
||||
xen_rmb(); /* Ensure we see all requests up to 'rp'. */
|
||||
}
|
||||
|
||||
if ( dp != ctrl_if_rxmsg_deferred_prod )
|
||||
@ -268,7 +268,7 @@ ctrl_if_send_message_noblock(
|
||||
|
||||
memcpy(&ctrl_if->tx_ring[MASK_CONTROL_IDX(ctrl_if->tx_req_prod)],
|
||||
msg, sizeof(*msg));
|
||||
x86_lfence(); /* Write the message before letting the controller peek at it. */
|
||||
xen_rmb(); /* Write the message before letting the controller peek at it. */
|
||||
ctrl_if->tx_req_prod++;
|
||||
|
||||
simple_unlock(&ctrl_if_lock);
|
||||
@ -315,7 +315,7 @@ static void __ctrl_if_get_response(ctrl_msg_t *msg, unsigned long id)
|
||||
struct rsp_wait *wait = (struct rsp_wait *)id;
|
||||
|
||||
memcpy(wait->msg, msg, sizeof(*msg));
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
wait->done = 1;
|
||||
|
||||
wakeup(wait);
|
||||
@ -366,7 +366,7 @@ ctrl_if_enqueue_space_callback(
|
||||
* the task is not executed despite the ring being non-full then we will
|
||||
* certainly return 'not full'.
|
||||
*/
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
return TX_FULL(ctrl_if);
|
||||
}
|
||||
#endif
|
||||
@ -394,7 +394,7 @@ ctrl_if_send_response(
|
||||
if ( dmsg != msg )
|
||||
memcpy(dmsg, msg, sizeof(*msg));
|
||||
|
||||
x86_lfence(); /* Write the message before letting the controller peek at it. */
|
||||
xen_rmb(); /* Write the message before letting the controller peek at it. */
|
||||
ctrl_if->rx_resp_prod++;
|
||||
|
||||
simple_unlock(&ctrl_if_lock);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_xennet.c,v 1.60 2008/10/27 10:58:22 cegger Exp $ */
|
||||
/* $NetBSD: if_xennet.c,v 1.61 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.60 2008/10/27 10:58:22 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.61 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_nfs_boot.h"
|
||||
@ -551,7 +551,7 @@ xennet_interface_status_change(netif_fe_interface_status_t *status)
|
||||
* we've probably just requeued some packets.
|
||||
*/
|
||||
sc->sc_backend_state = BEST_CONNECTED;
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
hypervisor_notify_via_evtchn(status->evtchn);
|
||||
network_tx_buf_gc(sc);
|
||||
|
||||
@ -702,7 +702,7 @@ xen_network_handler(void *arg)
|
||||
|
||||
again:
|
||||
resp_prod = sc->sc_rx->resp_prod;
|
||||
x86_lfence(); /* ensure we see all requests up to resp_prod */
|
||||
xen_rmb(); /* ensure we see all requests up to resp_prod */
|
||||
for (ringidx = sc->sc_rx_resp_cons;
|
||||
ringidx != resp_prod;
|
||||
ringidx++) {
|
||||
@ -826,7 +826,7 @@ xen_network_handler(void *arg)
|
||||
|
||||
sc->sc_rx_resp_cons = ringidx;
|
||||
sc->sc_rx->event = resp_prod + 1;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
/* ensure backend see the new sc_rx->event before we start again */
|
||||
|
||||
if (sc->sc_rx->resp_prod != resp_prod)
|
||||
@ -892,7 +892,7 @@ network_tx_buf_gc(struct xennet_softc *sc)
|
||||
*/
|
||||
sc->sc_tx->event = /* atomic */
|
||||
prod + (sc->sc_tx_entries >> 1) + 1;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
} while (prod != sc->sc_tx->resp_prod);
|
||||
|
||||
if (sc->sc_tx->resp_prod == sc->sc_tx->req_prod)
|
||||
@ -1143,12 +1143,12 @@ xennet_softstart(void *arg)
|
||||
txreq->addr = xpmap_ptom(pa);
|
||||
txreq->size = m->m_pkthdr.len;
|
||||
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
idx++;
|
||||
sc->sc_tx->req_prod = idx;
|
||||
|
||||
sc->sc_tx_entries++; /* XXX atomic */
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
|
||||
#ifdef XENNET_DEBUG
|
||||
DPRINTFN(XEDB_MEM, ("packet addr %p/%p, physical %p/%p, "
|
||||
@ -1168,7 +1168,7 @@ xennet_softstart(void *arg)
|
||||
#endif
|
||||
}
|
||||
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
if (sc->sc_tx->resp_prod != idx) {
|
||||
hypervisor_notify_via_evtchn(sc->sc_evtchn);
|
||||
ifp->if_timer = 5;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_xennet_xenbus.c,v 1.31 2009/01/15 14:51:30 jym Exp $ */
|
||||
/* $NetBSD: if_xennet_xenbus.c,v 1.32 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.31 2009/01/15 14:51:30 jym Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.32 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include "opt_xen.h"
|
||||
#include "opt_nfs_boot.h"
|
||||
@ -689,7 +689,7 @@ xennet_tx_complete(struct xennet_xenbus_softc *sc)
|
||||
|
||||
again:
|
||||
resp_prod = sc->sc_tx_ring.sring->rsp_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
for (i = sc->sc_tx_ring.rsp_cons; i != resp_prod; i++) {
|
||||
req = &sc->sc_txreqs[RING_GET_RESPONSE(&sc->sc_tx_ring, i)->id];
|
||||
KASSERT(req->txreq_id ==
|
||||
@ -715,7 +715,7 @@ again:
|
||||
sc->sc_tx_ring.sring->rsp_event =
|
||||
resp_prod + ((sc->sc_tx_ring.sring->req_prod - resp_prod) >> 1) + 1;
|
||||
ifp->if_timer = 0;
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
if (resp_prod != sc->sc_tx_ring.sring->rsp_prod)
|
||||
goto again;
|
||||
end:
|
||||
@ -750,7 +750,7 @@ again:
|
||||
sc->sc_rx_ring.sring->rsp_prod, sc->sc_rx_ring.rsp_cons));
|
||||
|
||||
resp_prod = sc->sc_rx_ring.sring->rsp_prod;
|
||||
x86_lfence(); /* ensure we see replies up to resp_prod */
|
||||
xen_rmb(); /* ensure we see replies up to resp_prod */
|
||||
for (i = sc->sc_rx_ring.rsp_cons; i != resp_prod; i++) {
|
||||
netif_rx_response_t *rx = RING_GET_RESPONSE(&sc->sc_rx_ring, i);
|
||||
req = &sc->sc_rxreqs[rx->id];
|
||||
@ -862,7 +862,7 @@ again:
|
||||
/* Pass the packet up. */
|
||||
(*ifp->if_input)(ifp, m);
|
||||
}
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
sc->sc_rx_ring.rsp_cons = i;
|
||||
RING_FINAL_CHECK_FOR_RESPONSES(&sc->sc_rx_ring, more_to_do);
|
||||
if (more_to_do)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xbd.c,v 1.50 2009/01/13 13:35:52 yamt Exp $ */
|
||||
/* $NetBSD: xbd.c,v 1.51 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.50 2009/01/13 13:35:52 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.51 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include "xbd_hypervisor.h"
|
||||
#include "rnd.h"
|
||||
@ -661,7 +661,7 @@ recover_interface(void)
|
||||
++req_prod;
|
||||
}
|
||||
recovery = 0;
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
signal_requests_to_xen();
|
||||
}
|
||||
|
||||
@ -1531,7 +1531,7 @@ xbd_response_handler(void *arg)
|
||||
}
|
||||
|
||||
rp = blk_ring->resp_prod;
|
||||
x86_lfence(); /* Ensure we see queued responses up to 'rp'. */
|
||||
xen_rmb(); /* Ensure we see queued responses up to 'rp'. */
|
||||
|
||||
for (i = resp_cons; i != rp; i++) {
|
||||
ring_resp = &blk_ring->ring[MASK_BLKIF_IDX(i)].resp;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xbd_xenbus.c,v 1.36 2009/01/13 13:35:52 yamt Exp $ */
|
||||
/* $NetBSD: xbd_xenbus.c,v 1.37 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.36 2009/01/13 13:35:52 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.37 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include "opt_xen.h"
|
||||
#include "rnd.h"
|
||||
@ -492,7 +492,7 @@ xbd_handler(void *arg)
|
||||
return 0;
|
||||
again:
|
||||
resp_prod = sc->sc_ring.sring->rsp_prod;
|
||||
x86_lfence(); /* ensure we see replies up to resp_prod */
|
||||
xen_rmb(); /* ensure we see replies up to resp_prod */
|
||||
for (i = sc->sc_ring.rsp_cons; i != resp_prod; i++) {
|
||||
blkif_response_t *rep = RING_GET_RESPONSE(&sc->sc_ring, i);
|
||||
struct xbd_req *xbdreq = &sc->sc_reqs[rep->id];
|
||||
@ -536,7 +536,7 @@ next:
|
||||
biodone(bp);
|
||||
SLIST_INSERT_HEAD(&sc->sc_xbdreq_head, xbdreq, req_next);
|
||||
}
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
sc->sc_ring.rsp_cons = i;
|
||||
RING_FINAL_CHECK_FOR_RESPONSES(&sc->sc_ring, more_to_do);
|
||||
if (more_to_do)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xbdback.c,v 1.36 2009/01/13 03:28:54 taca Exp $ */
|
||||
/* $NetBSD: xbdback.c,v 1.37 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Manuel Bouyer.
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xbdback.c,v 1.36 2009/01/13 03:28:54 taca Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xbdback.c,v 1.37 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -704,7 +704,7 @@ xbdback_co_main(struct xbdback_instance *xbdi, void *obj)
|
||||
{
|
||||
(void)obj;
|
||||
xbdi->req_prod = xbdi->blk_ring->req_prod;
|
||||
x86_lfence(); /* ensure we see all requests up to req_prod */
|
||||
xen_rmb(); /* ensure we see all requests up to req_prod */
|
||||
/*
|
||||
* note that we'll eventually get a full ring of request.
|
||||
* in this case, MASK_BLKIF_IDX(req_cons) == MASK_BLKIF_IDX(req_prod)
|
||||
@ -1251,7 +1251,7 @@ xbdback_send_reply(struct xbdback_instance *xbdi, int id, int op, int status)
|
||||
resp->operation = op;
|
||||
resp->status = status;
|
||||
xbdi->resp_prod++;
|
||||
x86_lfence(); /* ensure guest see all our replies */
|
||||
xen_rmb(); /* ensure guest see all our replies */
|
||||
xbdi->blk_ring->resp_prod = xbdi->resp_prod;
|
||||
hypervisor_notify_via_evtchn(xbdi->evtchn);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xbdback_xenbus.c,v 1.22 2009/01/12 08:55:48 cegger Exp $ */
|
||||
/* $NetBSD: xbdback_xenbus.c,v 1.23 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.22 2009/01/12 08:55:48 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.23 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -801,7 +801,7 @@ xbdback_co_main(struct xbdback_instance *xbdi, void *obj)
|
||||
{
|
||||
(void)obj;
|
||||
xbdi->xbdi_req_prod = xbdi->xbdi_ring.ring_n.sring->req_prod;
|
||||
x86_lfence(); /* ensure we see all requests up to req_prod */
|
||||
xen_rmb(); /* ensure we see all requests up to req_prod */
|
||||
/*
|
||||
* note that we'll eventually get a full ring of request.
|
||||
* in this case, MASK_BLKIF_IDX(req_cons) == MASK_BLKIF_IDX(req_prod)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xencons.c,v 1.30 2008/11/13 18:44:51 cegger Exp $ */
|
||||
/* $NetBSD: xencons.c,v 1.31 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
@ -63,7 +63,7 @@
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.30 2008/11/13 18:44:51 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.31 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include "opt_xen.h"
|
||||
|
||||
@ -386,7 +386,7 @@ xencons_start(struct tty *tp)
|
||||
#define XNC_OUT (xencons_interface->out)
|
||||
cons = xencons_interface->out_cons;
|
||||
prod = xencons_interface->out_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
while (prod != cons + sizeof(xencons_interface->out)) {
|
||||
if (MASK_XENCONS_IDX(prod, XNC_OUT) <
|
||||
MASK_XENCONS_IDX(cons, XNC_OUT)) {
|
||||
@ -402,9 +402,9 @@ xencons_start(struct tty *tp)
|
||||
break;
|
||||
prod = prod + len;
|
||||
}
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
xencons_interface->out_prod = prod;
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
hypervisor_notify_via_evtchn(xen_start_info.console.domU.evtchn);
|
||||
#undef XNC_OUT
|
||||
#else /* XEN3 */
|
||||
@ -459,7 +459,7 @@ xencons_handler(void *arg)
|
||||
|
||||
cons = xencons_interface->in_cons;
|
||||
prod = xencons_interface->in_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
while (cons != prod) {
|
||||
if (MASK_XENCONS_IDX(cons, XNC_IN) <
|
||||
MASK_XENCONS_IDX(prod, XNC_IN))
|
||||
@ -474,12 +474,12 @@ xencons_handler(void *arg)
|
||||
/* catch up with xenconscn_getc() */
|
||||
cons = xencons_interface->in_cons;
|
||||
prod = xencons_interface->in_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
} else {
|
||||
cons += len;
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
xencons_interface->in_cons = cons;
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
}
|
||||
}
|
||||
hypervisor_notify_via_evtchn(xen_start_info.console.domU.evtchn);
|
||||
@ -627,15 +627,15 @@ xenconscn_getc(dev_t dev)
|
||||
#ifdef XEN3
|
||||
cons = xencons_interface->in_cons;
|
||||
prod = xencons_interface->in_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
while (cons == prod) {
|
||||
HYPERVISOR_yield();
|
||||
prod = xencons_interface->in_prod;
|
||||
}
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
c = xencons_interface->in[MASK_XENCONS_IDX(xencons_interface->in_cons,
|
||||
xencons_interface->in)];
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
xencons_interface->in_cons = cons + 1;
|
||||
cn_check_magic(dev, c, xencons_cnm_state);
|
||||
splx(s);
|
||||
@ -675,17 +675,17 @@ xenconscn_putc(dev_t dev, int c)
|
||||
#ifdef XEN3
|
||||
cons = xencons_interface->out_cons;
|
||||
prod = xencons_interface->out_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
while (prod == cons + sizeof(xencons_interface->out)) {
|
||||
cons = xencons_interface->out_cons;
|
||||
prod = xencons_interface->out_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
}
|
||||
xencons_interface->out[MASK_XENCONS_IDX(xencons_interface->out_prod,
|
||||
xencons_interface->out)] = c;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
xencons_interface->out_prod++;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
hypervisor_notify_via_evtchn(xen_start_info.console.domU.evtchn);
|
||||
#else
|
||||
ctrl_msg_t msg;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xengnt.c,v 1.11 2008/11/13 18:44:51 cegger Exp $ */
|
||||
/* $NetBSD: xengnt.c,v 1.12 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.11 2008/11/13 18:44:51 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.12 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -234,7 +234,7 @@ xengnt_grant_access(domid_t dom, paddr_t ma, int ro, grant_ref_t *entryp)
|
||||
|
||||
grant_table[*entryp].frame = ma >> PAGE_SHIFT;
|
||||
grant_table[*entryp].domid = dom;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
grant_table[*entryp].flags =
|
||||
GTF_permit_access | (ro ? GTF_readonly : 0);
|
||||
return 0;
|
||||
@ -265,7 +265,7 @@ xengnt_grant_transfer(domid_t dom, grant_ref_t *entryp)
|
||||
|
||||
grant_table[*entryp].frame = 0;
|
||||
grant_table[*entryp].domid =dom;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
grant_table[*entryp].flags = GTF_accept_transfer;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xennetback.c,v 1.34 2008/10/21 15:46:32 cegger Exp $ */
|
||||
/* $NetBSD: xennetback.c,v 1.35 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Manuel Bouyer.
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xennetback.c,v 1.34 2008/10/21 15:46:32 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xennetback.c,v 1.35 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include "opt_xen.h"
|
||||
|
||||
@ -531,9 +531,9 @@ xennetback_tx_response(struct xnetback_instance *xneti, int id, int status)
|
||||
|
||||
txresp->id = id;
|
||||
txresp->status = status;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
xneti->xni_txring->resp_prod++;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
if (xneti->xni_txring->event == xneti->xni_txring->resp_prod) {
|
||||
XENPRINTF(("%s send event\n", xneti->xni_if.if_xname));
|
||||
hypervisor_notify_via_evtchn(xneti->xni_evtchn);
|
||||
@ -559,7 +559,7 @@ xennetback_evthandler(void *arg)
|
||||
XENPRINTF(("xennetback_evthandler "));
|
||||
again:
|
||||
req_prod = xneti->xni_txring->req_prod;
|
||||
x86_lfence(); /* ensure we see all requests up to req_prod */
|
||||
xen_rmb(); /* ensure we see all requests up to req_prod */
|
||||
req_cons = xneti->xni_txring->req_cons;
|
||||
XENPRINTF(("%s event req_prod %d resp_prod %d req_cons %d event %d\n",
|
||||
xneti->xni_if.if_xname,
|
||||
@ -750,7 +750,7 @@ again:
|
||||
* make sure the guest will see our replies before testing for more
|
||||
* work.
|
||||
*/
|
||||
x86_lfence(); /* ensure we see all requests up to req_prod */
|
||||
xen_rmb(); /* ensure we see all requests up to req_prod */
|
||||
if (i > 0)
|
||||
goto again; /* more work to do ? */
|
||||
|
||||
@ -779,10 +779,10 @@ xennetback_tx_free(struct mbuf *m, void *va, size_t size, void *arg)
|
||||
txresp = &xneti->xni_txring->ring[MASK_NETIF_TX_IDX(resp_prod)].resp;
|
||||
txresp->id = pkt->pkt_id;
|
||||
txresp->status = NETIF_RSP_OKAY;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
resp_prod++;
|
||||
xneti->xni_txring->resp_prod = resp_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
if (resp_prod == xneti->xni_txring->event) {
|
||||
XENPRINTF(("%s send event\n",
|
||||
xneti->xni_if.if_xname));
|
||||
@ -864,7 +864,7 @@ xennetback_ifsoftstart(void *arg)
|
||||
XENPRINTF(("pkt\n"));
|
||||
req_prod = xneti->xni_rxring->req_prod;
|
||||
resp_prod = xneti->xni_rxring->resp_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
|
||||
mmup = xstart_mmu;
|
||||
mclp = xstart_mcl;
|
||||
@ -975,10 +975,10 @@ xennetback_ifsoftstart(void *arg)
|
||||
printf("%s: xstart_mcl[%d] failed\n",
|
||||
ifp->if_xname, j);
|
||||
}
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
/* update pointer */
|
||||
xneti->xni_rxring->resp_prod += i;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
/* now we can free the mbufs */
|
||||
for (j = 0; j < i; j++) {
|
||||
m_freem(mbufs_sent[j]);
|
||||
@ -991,7 +991,7 @@ xennetback_ifsoftstart(void *arg)
|
||||
}
|
||||
/* send event */
|
||||
if (do_event) {
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
XENPRINTF(("%s receive event\n",
|
||||
xneti->xni_if.if_xname));
|
||||
hypervisor_notify_via_evtchn(xneti->xni_evtchn);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xennetback_xenbus.c,v 1.26 2009/01/06 00:57:47 jym Exp $ */
|
||||
/* $NetBSD: xennetback_xenbus.c,v 1.27 2009/01/16 20:16:47 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Manuel Bouyer.
|
||||
@ -490,10 +490,10 @@ xennetback_frontend_changed(void *arg, XenbusState new_state)
|
||||
goto err2;
|
||||
}
|
||||
xneti->xni_evtchn = evop.u.bind_interdomain.local_port;
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
xneti->xni_status = CONNECTED;
|
||||
xenbus_switch_state(xbusd, NULL, XenbusStateConnected);
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
event_set_handler(xneti->xni_evtchn, xennetback_evthandler,
|
||||
xneti, IPL_NET, xneti->xni_if.if_xname);
|
||||
xennetback_ifinit(&xneti->xni_if);
|
||||
@ -617,17 +617,17 @@ xennetback_evthandler(void *arg)
|
||||
|
||||
XENPRINTF(("xennetback_evthandler "));
|
||||
req_cons = xneti->xni_txring.req_cons;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
while (1) {
|
||||
x86_lfence(); /* be sure to read the request before updating */
|
||||
xen_rmb(); /* be sure to read the request before updating */
|
||||
xneti->xni_txring.req_cons = req_cons;
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
RING_FINAL_CHECK_FOR_REQUESTS(&xneti->xni_txring,
|
||||
receive_pending);
|
||||
if (receive_pending == 0)
|
||||
break;
|
||||
txreq = RING_GET_REQUEST(&xneti->xni_txring, req_cons);
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
XENPRINTF(("%s pkt size %d\n", xneti->xni_if.if_xname,
|
||||
txreq->size));
|
||||
req_cons++;
|
||||
@ -778,9 +778,9 @@ so always copy for now.
|
||||
#endif
|
||||
(*ifp->if_input)(ifp, m);
|
||||
}
|
||||
x86_lfence(); /* be sure to read the request before updating pointer */
|
||||
xen_rmb(); /* be sure to read the request before updating pointer */
|
||||
xneti->xni_txring.req_cons = req_cons;
|
||||
x86_sfence();
|
||||
xen_wmb();
|
||||
/* check to see if we can transmit more packets */
|
||||
softint_schedule(xneti->xni_softintr);
|
||||
|
||||
@ -866,7 +866,7 @@ xennetback_ifsoftstart(void *arg)
|
||||
XENPRINTF(("pkt\n"));
|
||||
req_prod = xneti->xni_rxring.sring->req_prod;
|
||||
resp_prod = xneti->xni_rxring.rsp_prod_pvt;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
|
||||
mmup = xstart_mmu;
|
||||
mclp = xstart_mcl;
|
||||
@ -928,7 +928,7 @@ xennetback_ifsoftstart(void *arg)
|
||||
xneti->xni_rxring.req_cons)->gref;
|
||||
id = RING_GET_REQUEST(&xneti->xni_rxring,
|
||||
xneti->xni_rxring.req_cons)->id;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
xneti->xni_rxring.req_cons++;
|
||||
rxresp = RING_GET_RESPONSE(&xneti->xni_rxring,
|
||||
resp_prod);
|
||||
@ -1055,7 +1055,7 @@ xennetback_ifsoftstart(void *arg)
|
||||
}
|
||||
/* send event */
|
||||
if (do_event) {
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
XENPRINTF(("%s receive event\n",
|
||||
xneti->xni_if.if_xname));
|
||||
hypervisor_notify_via_evtchn(xneti->xni_evtchn);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xenbus_comms.c,v 1.11 2008/12/18 12:19:03 cegger Exp $ */
|
||||
/* $NetBSD: xenbus_comms.c,v 1.12 2009/01/16 20:16:47 jym Exp $ */
|
||||
/******************************************************************************
|
||||
* xenbus_comms.c
|
||||
*
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenbus_comms.c,v 1.11 2008/12/18 12:19:03 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenbus_comms.c,v 1.12 2009/01/16 20:16:47 jym Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/null.h>
|
||||
@ -133,7 +133,7 @@ xb_write(const void *data, unsigned len)
|
||||
/* Read indexes, then verify. */
|
||||
cons = intf->req_cons;
|
||||
prod = intf->req_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
if (!check_indexes(cons, prod)) {
|
||||
splx(s);
|
||||
return EIO;
|
||||
@ -150,9 +150,9 @@ xb_write(const void *data, unsigned len)
|
||||
len -= avail;
|
||||
|
||||
/* Other side must not see new header until data is there. */
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
intf->req_prod += avail;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
|
||||
hypervisor_notify_via_evtchn(xen_start_info.store_evtchn);
|
||||
}
|
||||
@ -179,7 +179,7 @@ xb_read(void *data, unsigned len)
|
||||
/* Read indexes, then verify. */
|
||||
cons = intf->rsp_cons;
|
||||
prod = intf->rsp_prod;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
if (!check_indexes(cons, prod)) {
|
||||
XENPRINTF(("xb_read EIO\n"));
|
||||
splx(s);
|
||||
@ -193,16 +193,16 @@ xb_read(void *data, unsigned len)
|
||||
avail = len;
|
||||
|
||||
/* We must read header before we read data. */
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
|
||||
memcpy(data, src, avail);
|
||||
data = (char *)data + avail;
|
||||
len -= avail;
|
||||
|
||||
/* Other side must not see free space until we've copied out */
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
intf->rsp_cons += avail;
|
||||
x86_lfence();
|
||||
xen_rmb();
|
||||
|
||||
XENPRINTF(("Finished read of %i bytes (%i to go)\n",
|
||||
avail, len));
|
||||
|
Loading…
Reference in New Issue
Block a user