aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-02-12 11:37:45 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-02-12 11:37:45 +0000
commit67bfbd67d1311a1a590b47e568a07622d4492873 (patch)
tree17fb757a0b4179d91042dcb8bf3fdb3859925fba
parentb3a389fdfc3a1fe19fd7094b0180e97d49c186dd (diff)
downloadxen-67bfbd67d1311a1a590b47e568a07622d4492873.tar.gz
xen-67bfbd67d1311a1a590b47e568a07622d4492873.tar.bz2
xen-67bfbd67d1311a1a590b47e568a07622d4492873.zip
libxenctrl headers should not pollute macro namespace with
mb/rmb/wmb. Instead add a xen_ prefix. Modify Xen's public headers to expect the prefixed names instead of bare mb/rmb/wmb, but gate this expectation on a bump of __XEN_INTERFACE_VERSION__. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
-rw-r--r--tools/blktap/drivers/tapdisk.c2
-rw-r--r--tools/console/daemon/io.c8
-rw-r--r--tools/fs-back/fs-backend.c4
-rw-r--r--tools/ioemu/hw/xen_console.c8
-rw-r--r--tools/ioemu/hw/xenfb.c8
-rw-r--r--tools/ioemu/target-i386-dm/helper2.c6
-rw-r--r--tools/libxc/xenctrl.h25
-rw-r--r--tools/xenmon/xenbaked.c4
-rw-r--r--tools/xenstore/xenstored_domain.c8
-rw-r--r--tools/xentrace/xentrace.c6
-rw-r--r--xen/include/public/io/ring.h24
-rw-r--r--xen/include/public/xen-compat.h2
12 files changed, 56 insertions, 49 deletions
diff --git a/tools/blktap/drivers/tapdisk.c b/tools/blktap/drivers/tapdisk.c
index 993e09b155..75f06c701c 100644
--- a/tools/blktap/drivers/tapdisk.c
+++ b/tools/blktap/drivers/tapdisk.c
@@ -641,7 +641,7 @@ static void get_io_request(struct td_state *s)
if (!run) return; /*We have received signal to close*/
rp = info->fe_ring.sring->req_prod;
- rmb();
+ xen_rmb();
for (j = info->fe_ring.req_cons; j != rp; j++)
{
int done = 0, start_seg = 0;
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 52df19ed34..9573333c08 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -153,7 +153,7 @@ static void buffer_append(struct domain *dom)
cons = intf->out_cons;
prod = intf->out_prod;
- mb();
+ xen_mb();
size = prod - cons;
if ((size == 0) || (size > sizeof(intf->out)))
@@ -172,7 +172,7 @@ static void buffer_append(struct domain *dom)
buffer->data[buffer->size++] = intf->out[
MASK_XENCONS_IDX(cons++, intf->out)];
- mb();
+ xen_mb();
intf->out_cons = cons;
xc_evtchn_notify(dom->xce_handle, dom->local_port);
@@ -750,7 +750,7 @@ static int ring_free_bytes(struct domain *dom)
cons = intf->in_cons;
prod = intf->in_prod;
- mb();
+ xen_mb();
space = prod - cons;
if (space > sizeof(intf->in))
@@ -797,7 +797,7 @@ static void handle_tty_read(struct domain *dom)
intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
msg[i];
}
- wmb();
+ xen_wmb();
intf->in_prod = prod;
xc_evtchn_notify(dom->xce_handle, dom->local_port);
} else {
diff --git a/tools/fs-back/fs-backend.c b/tools/fs-back/fs-backend.c
index 634d5fa31e..fd5ba2b46b 100644
--- a/tools/fs-back/fs-backend.c
+++ b/tools/fs-back/fs-backend.c
@@ -140,8 +140,8 @@ void* handle_mount(void *data)
handle_aio_events(mount);
moretodo:
rp = mount->ring.sring->req_prod;
- rmb(); /* Ensure we see queued requests up to 'rp'. */
-
+ xen_rmb(); /* Ensure we see queued requests up to 'rp'. */
+
while ((cons = mount->ring.req_cons) != rp)
{
int i;
diff --git a/tools/ioemu/hw/xen_console.c b/tools/ioemu/hw/xen_console.c
index 76aca8f3ee..44f8bcca48 100644
--- a/tools/ioemu/hw/xen_console.c
+++ b/tools/ioemu/hw/xen_console.c
@@ -75,7 +75,7 @@ static void buffer_append(struct domain *dom)
cons = intf->out_cons;
prod = intf->out_prod;
- mb();
+ xen_mb();
size = prod - cons;
if ((size == 0) || (size > sizeof(intf->out)))
@@ -94,7 +94,7 @@ static void buffer_append(struct domain *dom)
buffer->data[buffer->size++] = intf->out[
MASK_XENCONS_IDX(cons++, intf->out)];
- mb();
+ xen_mb();
intf->out_cons = cons;
xc_evtchn_notify(dom->xce_handle, dom->local_port);
@@ -289,7 +289,7 @@ static int ring_free_bytes(struct domain *dom)
cons = intf->in_cons;
prod = intf->in_prod;
- mb();
+ xen_mb();
space = prod - cons;
if (space > sizeof(intf->in))
@@ -322,7 +322,7 @@ static void xencons_receive(void *opaque, const uint8_t *buf, int len)
intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
buf[i];
}
- wmb();
+ xen_wmb();
intf->in_prod = prod;
xc_evtchn_notify(dom->xce_handle, dom->local_port);
}
diff --git a/tools/ioemu/hw/xenfb.c b/tools/ioemu/hw/xenfb.c
index f0d7f7936e..5418986178 100644
--- a/tools/ioemu/hw/xenfb.c
+++ b/tools/ioemu/hw/xenfb.c
@@ -485,7 +485,7 @@ static void xenfb_on_fb_event(struct xenfb *xenfb)
prod = page->out_prod;
if (prod == page->out_cons)
return;
- rmb(); /* ensure we see ring contents up to prod */
+ xen_rmb(); /* ensure we see ring contents up to prod */
for (cons = page->out_cons; cons != prod; cons++) {
union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
int x, y, w, h;
@@ -512,7 +512,7 @@ static void xenfb_on_fb_event(struct xenfb *xenfb)
break;
}
}
- mb(); /* ensure we're done with ring contents */
+ xen_mb(); /* ensure we're done with ring contents */
page->out_cons = cons;
xc_evtchn_notify(xenfb->evt_xch, xenfb->fb.port);
}
@@ -571,9 +571,9 @@ static int xenfb_kbd_event(struct xenfb *xenfb,
return -1;
}
- mb(); /* ensure ring space available */
+ xen_mb(); /* ensure ring space available */
XENKBD_IN_RING_REF(page, prod) = *event;
- wmb(); /* ensure ring contents visible */
+ xen_wmb(); /* ensure ring contents visible */
page->in_prod = prod + 1;
return xc_evtchn_notify(xenfb->evt_xch, xenfb->kbd.port);
}
diff --git a/tools/ioemu/target-i386-dm/helper2.c b/tools/ioemu/target-i386-dm/helper2.c
index d45ac7a999..4896b11ab8 100644
--- a/tools/ioemu/target-i386-dm/helper2.c
+++ b/tools/ioemu/target-i386-dm/helper2.c
@@ -218,7 +218,7 @@ static ioreq_t *__cpu_get_ioreq(int vcpu)
return NULL;
}
- rmb(); /* see IOREQ_READY /then/ read contents of ioreq */
+ xen_rmb(); /* see IOREQ_READY /then/ read contents of ioreq */
req->state = STATE_IOREQ_INPROCESS;
return req;
@@ -568,7 +568,7 @@ void __handle_buffered_iopage(CPUState *env)
__handle_ioreq(env, &req);
- mb();
+ xen_mb();
buffered_io_page->read_pointer += qw ? 2 : 1;
}
}
@@ -603,7 +603,7 @@ void cpu_handle_ioreq(void *opaque)
return;
}
- wmb(); /* Update ioreq contents /then/ update state. */
+ xen_wmb(); /* Update ioreq contents /then/ update state. */
/*
* We do this before we send the response so that the tools
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index b9e9abd249..afc80a36df 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -43,22 +43,21 @@
*/
#if defined(__i386__)
-#define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
+#define xen_mb() asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
+#define xen_rmb() asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
+#define xen_wmb() asm volatile ( "" : : : "memory")
#elif defined(__x86_64__)
-#define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
-#define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
+#define xen_mb() asm volatile ( "mfence" : : : "memory")
+#define xen_rmb() asm volatile ( "lfence" : : : "memory")
+#define xen_wmb() asm volatile ( "" : : : "memory")
#elif defined(__ia64__)
-#define mb() __asm__ __volatile__ ("mf" ::: "memory")
-#define rmb() __asm__ __volatile__ ("mf" ::: "memory")
-#define wmb() __asm__ __volatile__ ("mf" ::: "memory")
+#define xen_mb() asm volatile ("mf" ::: "memory")
+#define xen_rmb() asm volatile ("mf" ::: "memory")
+#define xen_wmb() asm volatile ("mf" ::: "memory")
#elif defined(__powerpc__)
-/* XXX loosen these up later */
-#define mb() __asm__ __volatile__ ("sync" : : : "memory")
-#define rmb() __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */
-#define wmb() __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */
+#define xen_mb() asm volatile ("sync" : : : "memory")
+#define xen_rmb() asm volatile ("sync" : : : "memory") /* lwsync? */
+#define xen_wmb() asm volatile ("sync" : : : "memory") /* eieio? */
#else
#error "Define barriers"
#endif
diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
index 728f14b753..32ca9f36c3 100644
--- a/tools/xenmon/xenbaked.c
+++ b/tools/xenmon/xenbaked.c
@@ -511,10 +511,10 @@ int monitor_tbufs(void)
{
while ( meta[i]->cons != meta[i]->prod )
{
- rmb(); /* read prod, then read item. */
+ xen_rmb(); /* read prod, then read item. */
rec_size = process_record(
i, (struct t_rec *)(data[i] + meta[i]->cons % data_size));
- mb(); /* read item, then update cons. */
+ xen_mb(); /* read item, then update cons. */
meta[i]->cons += rec_size;
}
}
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index 2cc9881eb4..d1d59f9f6f 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -112,7 +112,7 @@ static int writechn(struct connection *conn,
/* Must read indexes once, and before anything else, and verified. */
cons = intf->rsp_cons;
prod = intf->rsp_prod;
- mb();
+ xen_mb();
if (!check_indexes(cons, prod)) {
errno = EIO;
@@ -124,7 +124,7 @@ static int writechn(struct connection *conn,
len = avail;
memcpy(dest, data, len);
- mb();
+ xen_mb();
intf->rsp_prod += len;
xc_evtchn_notify(xce_handle, conn->domain->port);
@@ -142,7 +142,7 @@ static int readchn(struct connection *conn, void *data, unsigned int len)
/* Must read indexes once, and before anything else, and verified. */
cons = intf->req_cons;
prod = intf->req_prod;
- mb();
+ xen_mb();
if (!check_indexes(cons, prod)) {
errno = EIO;
@@ -154,7 +154,7 @@ static int readchn(struct connection *conn, void *data, unsigned int len)
len = avail;
memcpy(data, src, len);
- mb();
+ xen_mb();
intf->req_cons += len;
xc_evtchn_notify(xce_handle, conn->domain->port);
diff --git a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c
index 0879576645..7f394d2af0 100644
--- a/tools/xentrace/xentrace.c
+++ b/tools/xentrace/xentrace.c
@@ -384,8 +384,8 @@ int monitor_tbufs(int outfd)
/* Read window information only once. */
cons = meta[i]->cons;
prod = meta[i]->prod;
- rmb(); /* read prod, then read item. */
-
+ xen_rmb(); /* read prod, then read item. */
+
if ( cons == prod )
continue;
@@ -428,7 +428,7 @@ int monitor_tbufs(int outfd)
outfd);
}
- mb(); /* read buffer, then update cons. */
+ xen_mb(); /* read buffer, then update cons. */
meta[i]->cons = prod;
}
diff --git a/xen/include/public/io/ring.h b/xen/include/public/io/ring.h
index 355eba5545..6ce1d0d485 100644
--- a/xen/include/public/io/ring.h
+++ b/xen/include/public/io/ring.h
@@ -27,6 +27,14 @@
#ifndef __XEN_PUBLIC_IO_RING_H__
#define __XEN_PUBLIC_IO_RING_H__
+#include "../xen-compat.h"
+
+#if __XEN_INTERFACE_VERSION__ < 0x00030208
+#define xen_mb() mb()
+#define xen_rmb() rmb()
+#define xen_wmb() wmb()
+#endif
+
typedef unsigned int RING_IDX;
/* Round a 32-bit unsigned constant down to the nearest power of two. */
@@ -211,12 +219,12 @@ typedef struct __name##_back_ring __name##_back_ring_t
(((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
#define RING_PUSH_REQUESTS(_r) do { \
- wmb(); /* back sees requests /before/ updated producer index */ \
+ xen_wmb(); /* back sees requests /before/ updated producer index */ \
(_r)->sring->req_prod = (_r)->req_prod_pvt; \
} while (0)
#define RING_PUSH_RESPONSES(_r) do { \
- wmb(); /* front sees responses /before/ updated producer index */ \
+ xen_wmb(); /* front sees resps /before/ updated producer index */ \
(_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \
} while (0)
@@ -253,9 +261,9 @@ typedef struct __name##_back_ring __name##_back_ring_t
#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do { \
RING_IDX __old = (_r)->sring->req_prod; \
RING_IDX __new = (_r)->req_prod_pvt; \
- wmb(); /* back sees requests /before/ updated producer index */ \
+ xen_wmb(); /* back sees requests /before/ updated producer index */ \
(_r)->sring->req_prod = __new; \
- mb(); /* back sees new requests /before/ we check req_event */ \
+ xen_mb(); /* back sees new requests /before/ we check req_event */ \
(_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < \
(RING_IDX)(__new - __old)); \
} while (0)
@@ -263,9 +271,9 @@ typedef struct __name##_back_ring __name##_back_ring_t
#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do { \
RING_IDX __old = (_r)->sring->rsp_prod; \
RING_IDX __new = (_r)->rsp_prod_pvt; \
- wmb(); /* front sees responses /before/ updated producer index */ \
+ xen_wmb(); /* front sees resps /before/ updated producer index */ \
(_r)->sring->rsp_prod = __new; \
- mb(); /* front sees new responses /before/ we check rsp_event */ \
+ xen_mb(); /* front sees new resps /before/ we check rsp_event */ \
(_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \
(RING_IDX)(__new - __old)); \
} while (0)
@@ -274,7 +282,7 @@ typedef struct __name##_back_ring __name##_back_ring_t
(_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \
if (_work_to_do) break; \
(_r)->sring->req_event = (_r)->req_cons + 1; \
- mb(); \
+ xen_mb(); \
(_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \
} while (0)
@@ -282,7 +290,7 @@ typedef struct __name##_back_ring __name##_back_ring_t
(_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \
if (_work_to_do) break; \
(_r)->sring->rsp_event = (_r)->rsp_cons + 1; \
- mb(); \
+ xen_mb(); \
(_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \
} while (0)
diff --git a/xen/include/public/xen-compat.h b/xen/include/public/xen-compat.h
index c9f369f0e9..c2894990cd 100644
--- a/xen/include/public/xen-compat.h
+++ b/xen/include/public/xen-compat.h
@@ -27,7 +27,7 @@
#ifndef __XEN_PUBLIC_XEN_COMPAT_H__
#define __XEN_PUBLIC_XEN_COMPAT_H__
-#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030207
+#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030208
#if defined(__XEN__) || defined(__XEN_TOOLS__)
/* Xen is built with matching headers and implements the latest interface. */