ia64/xen-unstable

changeset 17041:88818d55e95a

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>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Feb 12 11:37:45 2008 +0000 (2008-02-12)
parents bd09d9692bda
children a905c582a406
files tools/blktap/drivers/tapdisk.c tools/console/daemon/io.c tools/fs-back/fs-backend.c tools/ioemu/hw/xen_console.c tools/ioemu/hw/xenfb.c tools/ioemu/target-i386-dm/helper2.c tools/libxc/xenctrl.h tools/xenmon/xenbaked.c tools/xenstore/xenstored_domain.c tools/xentrace/xentrace.c xen/include/public/io/ring.h xen/include/public/xen-compat.h
line diff
     1.1 --- a/tools/blktap/drivers/tapdisk.c	Tue Feb 12 10:57:49 2008 +0000
     1.2 +++ b/tools/blktap/drivers/tapdisk.c	Tue Feb 12 11:37:45 2008 +0000
     1.3 @@ -641,7 +641,7 @@ static void get_io_request(struct td_sta
     1.4  	if (!run) return; /*We have received signal to close*/
     1.5  
     1.6  	rp = info->fe_ring.sring->req_prod; 
     1.7 -	rmb();
     1.8 +	xen_rmb();
     1.9  	for (j = info->fe_ring.req_cons; j != rp; j++)
    1.10  	{
    1.11  		int done = 0, start_seg = 0; 
     2.1 --- a/tools/console/daemon/io.c	Tue Feb 12 10:57:49 2008 +0000
     2.2 +++ b/tools/console/daemon/io.c	Tue Feb 12 11:37:45 2008 +0000
     2.3 @@ -153,7 +153,7 @@ static void buffer_append(struct domain 
     2.4  
     2.5  	cons = intf->out_cons;
     2.6  	prod = intf->out_prod;
     2.7 -	mb();
     2.8 +	xen_mb();
     2.9  
    2.10  	size = prod - cons;
    2.11  	if ((size == 0) || (size > sizeof(intf->out)))
    2.12 @@ -172,7 +172,7 @@ static void buffer_append(struct domain 
    2.13  		buffer->data[buffer->size++] = intf->out[
    2.14  			MASK_XENCONS_IDX(cons++, intf->out)];
    2.15  
    2.16 -	mb();
    2.17 +	xen_mb();
    2.18  	intf->out_cons = cons;
    2.19  	xc_evtchn_notify(dom->xce_handle, dom->local_port);
    2.20  
    2.21 @@ -750,7 +750,7 @@ static int ring_free_bytes(struct domain
    2.22  
    2.23  	cons = intf->in_cons;
    2.24  	prod = intf->in_prod;
    2.25 -	mb();
    2.26 +	xen_mb();
    2.27  
    2.28  	space = prod - cons;
    2.29  	if (space > sizeof(intf->in))
    2.30 @@ -797,7 +797,7 @@ static void handle_tty_read(struct domai
    2.31  			intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
    2.32  				msg[i];
    2.33  		}
    2.34 -		wmb();
    2.35 +		xen_wmb();
    2.36  		intf->in_prod = prod;
    2.37  		xc_evtchn_notify(dom->xce_handle, dom->local_port);
    2.38  	} else {
     3.1 --- a/tools/fs-back/fs-backend.c	Tue Feb 12 10:57:49 2008 +0000
     3.2 +++ b/tools/fs-back/fs-backend.c	Tue Feb 12 11:37:45 2008 +0000
     3.3 @@ -140,8 +140,8 @@ void* handle_mount(void *data)
     3.4          handle_aio_events(mount);
     3.5  moretodo:
     3.6          rp = mount->ring.sring->req_prod;
     3.7 -        rmb(); /* Ensure we see queued requests up to 'rp'. */
     3.8 -                
     3.9 +        xen_rmb(); /* Ensure we see queued requests up to 'rp'. */
    3.10 +
    3.11          while ((cons = mount->ring.req_cons) != rp)
    3.12          {
    3.13              int i;
     4.1 --- a/tools/ioemu/hw/xen_console.c	Tue Feb 12 10:57:49 2008 +0000
     4.2 +++ b/tools/ioemu/hw/xen_console.c	Tue Feb 12 11:37:45 2008 +0000
     4.3 @@ -75,7 +75,7 @@ static void buffer_append(struct domain 
     4.4  
     4.5  	cons = intf->out_cons;
     4.6  	prod = intf->out_prod;
     4.7 -	mb();
     4.8 +	xen_mb();
     4.9  
    4.10  	size = prod - cons;
    4.11  	if ((size == 0) || (size > sizeof(intf->out)))
    4.12 @@ -94,7 +94,7 @@ static void buffer_append(struct domain 
    4.13  		buffer->data[buffer->size++] = intf->out[
    4.14  			MASK_XENCONS_IDX(cons++, intf->out)];
    4.15  
    4.16 -	mb();
    4.17 +	xen_mb();
    4.18  	intf->out_cons = cons;
    4.19  	xc_evtchn_notify(dom->xce_handle, dom->local_port);
    4.20  
    4.21 @@ -289,7 +289,7 @@ static int ring_free_bytes(struct domain
    4.22  
    4.23  	cons = intf->in_cons;
    4.24  	prod = intf->in_prod;
    4.25 -	mb();
    4.26 +	xen_mb();
    4.27  
    4.28  	space = prod - cons;
    4.29  	if (space > sizeof(intf->in))
    4.30 @@ -322,7 +322,7 @@ static void xencons_receive(void *opaque
    4.31  		intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
    4.32  			buf[i];
    4.33  	}
    4.34 -	wmb();
    4.35 +	xen_wmb();
    4.36  	intf->in_prod = prod;
    4.37  	xc_evtchn_notify(dom->xce_handle, dom->local_port);
    4.38  }
     5.1 --- a/tools/ioemu/hw/xenfb.c	Tue Feb 12 10:57:49 2008 +0000
     5.2 +++ b/tools/ioemu/hw/xenfb.c	Tue Feb 12 11:37:45 2008 +0000
     5.3 @@ -485,7 +485,7 @@ static void xenfb_on_fb_event(struct xen
     5.4  	prod = page->out_prod;
     5.5  	if (prod == page->out_cons)
     5.6  		return;
     5.7 -	rmb();			/* ensure we see ring contents up to prod */
     5.8 +	xen_rmb();		/* ensure we see ring contents up to prod */
     5.9  	for (cons = page->out_cons; cons != prod; cons++) {
    5.10  		union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
    5.11  		int x, y, w, h;
    5.12 @@ -512,7 +512,7 @@ static void xenfb_on_fb_event(struct xen
    5.13  			break;
    5.14  		}
    5.15  	}
    5.16 -	mb();			/* ensure we're done with ring contents */
    5.17 +	xen_mb();		/* ensure we're done with ring contents */
    5.18  	page->out_cons = cons;
    5.19  	xc_evtchn_notify(xenfb->evt_xch, xenfb->fb.port);
    5.20  }
    5.21 @@ -571,9 +571,9 @@ static int xenfb_kbd_event(struct xenfb 
    5.22  		return -1;
    5.23  	}
    5.24  
    5.25 -	mb();			/* ensure ring space available */
    5.26 +	xen_mb();		/* ensure ring space available */
    5.27  	XENKBD_IN_RING_REF(page, prod) = *event;
    5.28 -	wmb();			/* ensure ring contents visible */
    5.29 +	xen_wmb();		/* ensure ring contents visible */
    5.30  	page->in_prod = prod + 1;
    5.31  	return xc_evtchn_notify(xenfb->evt_xch, xenfb->kbd.port);
    5.32  }
     6.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Tue Feb 12 10:57:49 2008 +0000
     6.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Tue Feb 12 11:37:45 2008 +0000
     6.3 @@ -218,7 +218,7 @@ static ioreq_t *__cpu_get_ioreq(int vcpu
     6.4          return NULL;
     6.5      }
     6.6  
     6.7 -    rmb(); /* see IOREQ_READY /then/ read contents of ioreq */
     6.8 +    xen_rmb(); /* see IOREQ_READY /then/ read contents of ioreq */
     6.9  
    6.10      req->state = STATE_IOREQ_INPROCESS;
    6.11      return req;
    6.12 @@ -568,7 +568,7 @@ void __handle_buffered_iopage(CPUState *
    6.13  
    6.14          __handle_ioreq(env, &req);
    6.15  
    6.16 -        mb();
    6.17 +        xen_mb();
    6.18          buffered_io_page->read_pointer += qw ? 2 : 1;
    6.19      }
    6.20  }
    6.21 @@ -603,7 +603,7 @@ void cpu_handle_ioreq(void *opaque)
    6.22              return;
    6.23          }
    6.24  
    6.25 -        wmb(); /* Update ioreq contents /then/ update state. */
    6.26 +        xen_wmb(); /* Update ioreq contents /then/ update state. */
    6.27  
    6.28  	/*
    6.29           * We do this before we send the response so that the tools
     7.1 --- a/tools/libxc/xenctrl.h	Tue Feb 12 10:57:49 2008 +0000
     7.2 +++ b/tools/libxc/xenctrl.h	Tue Feb 12 11:37:45 2008 +0000
     7.3 @@ -43,22 +43,21 @@
     7.4   */
     7.5  
     7.6  #if defined(__i386__)
     7.7 -#define mb()  __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
     7.8 -#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
     7.9 -#define wmb() __asm__ __volatile__ ( "" : : : "memory")
    7.10 +#define xen_mb()  asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
    7.11 +#define xen_rmb() asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
    7.12 +#define xen_wmb() asm volatile ( "" : : : "memory")
    7.13  #elif defined(__x86_64__)
    7.14 -#define mb()  __asm__ __volatile__ ( "mfence" : : : "memory")
    7.15 -#define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
    7.16 -#define wmb() __asm__ __volatile__ ( "" : : : "memory")
    7.17 +#define xen_mb()  asm volatile ( "mfence" : : : "memory")
    7.18 +#define xen_rmb() asm volatile ( "lfence" : : : "memory")
    7.19 +#define xen_wmb() asm volatile ( "" : : : "memory")
    7.20  #elif defined(__ia64__)
    7.21 -#define mb()   __asm__ __volatile__ ("mf" ::: "memory")
    7.22 -#define rmb()  __asm__ __volatile__ ("mf" ::: "memory")
    7.23 -#define wmb()  __asm__ __volatile__ ("mf" ::: "memory")
    7.24 +#define xen_mb()   asm volatile ("mf" ::: "memory")
    7.25 +#define xen_rmb()  asm volatile ("mf" ::: "memory")
    7.26 +#define xen_wmb()  asm volatile ("mf" ::: "memory")
    7.27  #elif defined(__powerpc__)
    7.28 -/* XXX loosen these up later */
    7.29 -#define mb()   __asm__ __volatile__ ("sync" : : : "memory")
    7.30 -#define rmb()  __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */
    7.31 -#define wmb()  __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */
    7.32 +#define xen_mb()   asm volatile ("sync" : : : "memory")
    7.33 +#define xen_rmb()  asm volatile ("sync" : : : "memory") /* lwsync? */
    7.34 +#define xen_wmb()  asm volatile ("sync" : : : "memory") /* eieio? */
    7.35  #else
    7.36  #error "Define barriers"
    7.37  #endif
     8.1 --- a/tools/xenmon/xenbaked.c	Tue Feb 12 10:57:49 2008 +0000
     8.2 +++ b/tools/xenmon/xenbaked.c	Tue Feb 12 11:37:45 2008 +0000
     8.3 @@ -511,10 +511,10 @@ int monitor_tbufs(void)
     8.4          {
     8.5              while ( meta[i]->cons != meta[i]->prod )
     8.6              {
     8.7 -                rmb(); /* read prod, then read item. */
     8.8 +                xen_rmb(); /* read prod, then read item. */
     8.9                  rec_size = process_record(
    8.10                      i, (struct t_rec *)(data[i] + meta[i]->cons % data_size));
    8.11 -                mb(); /* read item, then update cons. */
    8.12 +                xen_mb(); /* read item, then update cons. */
    8.13                  meta[i]->cons += rec_size;
    8.14              }
    8.15          }
     9.1 --- a/tools/xenstore/xenstored_domain.c	Tue Feb 12 10:57:49 2008 +0000
     9.2 +++ b/tools/xenstore/xenstored_domain.c	Tue Feb 12 11:37:45 2008 +0000
     9.3 @@ -112,7 +112,7 @@ static int writechn(struct connection *c
     9.4  	/* Must read indexes once, and before anything else, and verified. */
     9.5  	cons = intf->rsp_cons;
     9.6  	prod = intf->rsp_prod;
     9.7 -	mb();
     9.8 +	xen_mb();
     9.9  
    9.10  	if (!check_indexes(cons, prod)) {
    9.11  		errno = EIO;
    9.12 @@ -124,7 +124,7 @@ static int writechn(struct connection *c
    9.13  		len = avail;
    9.14  
    9.15  	memcpy(dest, data, len);
    9.16 -	mb();
    9.17 +	xen_mb();
    9.18  	intf->rsp_prod += len;
    9.19  
    9.20  	xc_evtchn_notify(xce_handle, conn->domain->port);
    9.21 @@ -142,7 +142,7 @@ static int readchn(struct connection *co
    9.22  	/* Must read indexes once, and before anything else, and verified. */
    9.23  	cons = intf->req_cons;
    9.24  	prod = intf->req_prod;
    9.25 -	mb();
    9.26 +	xen_mb();
    9.27  
    9.28  	if (!check_indexes(cons, prod)) {
    9.29  		errno = EIO;
    9.30 @@ -154,7 +154,7 @@ static int readchn(struct connection *co
    9.31  		len = avail;
    9.32  
    9.33  	memcpy(data, src, len);
    9.34 -	mb();
    9.35 +	xen_mb();
    9.36  	intf->req_cons += len;
    9.37  
    9.38  	xc_evtchn_notify(xce_handle, conn->domain->port);
    10.1 --- a/tools/xentrace/xentrace.c	Tue Feb 12 10:57:49 2008 +0000
    10.2 +++ b/tools/xentrace/xentrace.c	Tue Feb 12 11:37:45 2008 +0000
    10.3 @@ -384,8 +384,8 @@ int monitor_tbufs(int outfd)
    10.4              /* Read window information only once. */
    10.5              cons = meta[i]->cons;
    10.6              prod = meta[i]->prod;
    10.7 -            rmb(); /* read prod, then read item. */
    10.8 -            
    10.9 +            xen_rmb(); /* read prod, then read item. */
   10.10 +
   10.11              if ( cons == prod )
   10.12                  continue;
   10.13             
   10.14 @@ -428,7 +428,7 @@ int monitor_tbufs(int outfd)
   10.15                               outfd);
   10.16              }
   10.17  
   10.18 -            mb(); /* read buffer, then update cons. */
   10.19 +            xen_mb(); /* read buffer, then update cons. */
   10.20              meta[i]->cons = prod;
   10.21          }
   10.22  
    11.1 --- a/xen/include/public/io/ring.h	Tue Feb 12 10:57:49 2008 +0000
    11.2 +++ b/xen/include/public/io/ring.h	Tue Feb 12 11:37:45 2008 +0000
    11.3 @@ -27,6 +27,14 @@
    11.4  #ifndef __XEN_PUBLIC_IO_RING_H__
    11.5  #define __XEN_PUBLIC_IO_RING_H__
    11.6  
    11.7 +#include "../xen-compat.h"
    11.8 +
    11.9 +#if __XEN_INTERFACE_VERSION__ < 0x00030208
   11.10 +#define xen_mb()  mb()
   11.11 +#define xen_rmb() rmb()
   11.12 +#define xen_wmb() wmb()
   11.13 +#endif
   11.14 +
   11.15  typedef unsigned int RING_IDX;
   11.16  
   11.17  /* Round a 32-bit unsigned constant down to the nearest power of two. */
   11.18 @@ -211,12 +219,12 @@ typedef struct __name##_back_ring __name
   11.19      (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
   11.20  
   11.21  #define RING_PUSH_REQUESTS(_r) do {                                     \
   11.22 -    wmb(); /* back sees requests /before/ updated producer index */     \
   11.23 +    xen_wmb(); /* back sees requests /before/ updated producer index */ \
   11.24      (_r)->sring->req_prod = (_r)->req_prod_pvt;                         \
   11.25  } while (0)
   11.26  
   11.27  #define RING_PUSH_RESPONSES(_r) do {                                    \
   11.28 -    wmb(); /* front sees responses /before/ updated producer index */   \
   11.29 +    xen_wmb(); /* front sees resps /before/ updated producer index */   \
   11.30      (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt;                         \
   11.31  } while (0)
   11.32  
   11.33 @@ -253,9 +261,9 @@ typedef struct __name##_back_ring __name
   11.34  #define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do {           \
   11.35      RING_IDX __old = (_r)->sring->req_prod;                             \
   11.36      RING_IDX __new = (_r)->req_prod_pvt;                                \
   11.37 -    wmb(); /* back sees requests /before/ updated producer index */     \
   11.38 +    xen_wmb(); /* back sees requests /before/ updated producer index */ \
   11.39      (_r)->sring->req_prod = __new;                                      \
   11.40 -    mb(); /* back sees new requests /before/ we check req_event */      \
   11.41 +    xen_mb(); /* back sees new requests /before/ we check req_event */  \
   11.42      (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) <           \
   11.43                   (RING_IDX)(__new - __old));                            \
   11.44  } while (0)
   11.45 @@ -263,9 +271,9 @@ typedef struct __name##_back_ring __name
   11.46  #define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do {          \
   11.47      RING_IDX __old = (_r)->sring->rsp_prod;                             \
   11.48      RING_IDX __new = (_r)->rsp_prod_pvt;                                \
   11.49 -    wmb(); /* front sees responses /before/ updated producer index */   \
   11.50 +    xen_wmb(); /* front sees resps /before/ updated producer index */   \
   11.51      (_r)->sring->rsp_prod = __new;                                      \
   11.52 -    mb(); /* front sees new responses /before/ we check rsp_event */    \
   11.53 +    xen_mb(); /* front sees new resps /before/ we check rsp_event */    \
   11.54      (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) <           \
   11.55                   (RING_IDX)(__new - __old));                            \
   11.56  } while (0)
   11.57 @@ -274,7 +282,7 @@ typedef struct __name##_back_ring __name
   11.58      (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
   11.59      if (_work_to_do) break;                                             \
   11.60      (_r)->sring->req_event = (_r)->req_cons + 1;                        \
   11.61 -    mb();                                                               \
   11.62 +    xen_mb();                                                           \
   11.63      (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
   11.64  } while (0)
   11.65  
   11.66 @@ -282,7 +290,7 @@ typedef struct __name##_back_ring __name
   11.67      (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
   11.68      if (_work_to_do) break;                                             \
   11.69      (_r)->sring->rsp_event = (_r)->rsp_cons + 1;                        \
   11.70 -    mb();                                                               \
   11.71 +    xen_mb();                                                           \
   11.72      (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
   11.73  } while (0)
   11.74  
    12.1 --- a/xen/include/public/xen-compat.h	Tue Feb 12 10:57:49 2008 +0000
    12.2 +++ b/xen/include/public/xen-compat.h	Tue Feb 12 11:37:45 2008 +0000
    12.3 @@ -27,7 +27,7 @@
    12.4  #ifndef __XEN_PUBLIC_XEN_COMPAT_H__
    12.5  #define __XEN_PUBLIC_XEN_COMPAT_H__
    12.6  
    12.7 -#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030207
    12.8 +#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030208
    12.9  
   12.10  #if defined(__XEN__) || defined(__XEN_TOOLS__)
   12.11  /* Xen is built with matching headers and implements the latest interface. */