Module Name:    src
Committed By:   cherry
Date:           Sat Feb  2 14:50:15 UTC 2019

Modified Files:
        src/sys/arch/xen/include: hypervisor.h xenring.h

Log Message:
Remove mb(), rmb() and wmb() from the kernel namespace.

These are introduced by external/bsd/common/include/asm/barrier.h

The purpose of barrier.h is to bridge the use of linux API calls
within code which uses them, such as drm code. The XEN api implicitly
uses these calls which are linuxisms within io/ring.h

This diff undos the damage.

The correct fix is to modify io/ring.h to not assume that all OSs that
XEN runs on has these functions, and to appropriately conditionally via
#ifdef __NetBSD__/#endif use the appropriate NetBSD functions. These
changes then need to be pushed upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/xen/include/xenring.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/include/hypervisor.h
diff -u src/sys/arch/xen/include/hypervisor.h:1.47 src/sys/arch/xen/include/hypervisor.h:1.48
--- src/sys/arch/xen/include/hypervisor.h:1.47	Sat Feb  2 12:32:55 2019
+++ src/sys/arch/xen/include/hypervisor.h	Sat Feb  2 14:50:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor.h,v 1.47 2019/02/02 12:32:55 cherry Exp $	*/
+/*	$NetBSD: hypervisor.h,v 1.48 2019/02/02 14:50:15 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -80,7 +80,7 @@ struct xen_npx_attach_args {
 #define	s32 int32_t
 #define	s64 int64_t
 
-#include <external/bsd/common/include/asm/barrier.h> /* Linux mb() and friends */
+#include <sys/atomic.h>
 
 #include <xen/include/public/xen.h>
 #include <xen/include/public/sched.h>
@@ -94,6 +94,18 @@ struct xen_npx_attach_args {
 #include <xen/include/public/io/netif.h>
 #include <xen/include/public/io/blkif.h>
 
+/* Undo namespace damage from xen/include/public/io/ring.h
+ * The proper fix is to get upstream to stop assuming that all OSs use
+ * mb(), rmb(), wmb().
+ */
+#undef xen_mb
+#undef xen_rmb
+#undef xen_wmb
+
+#define xen_mb()  membar_sync()
+#define xen_rmb() membar_producer()
+#define xen_wmb() membar_consumer()
+
 #include <machine/hypercalls.h>
 
 #undef u8

Index: src/sys/arch/xen/include/xenring.h
diff -u src/sys/arch/xen/include/xenring.h:1.1 src/sys/arch/xen/include/xenring.h:1.2
--- src/sys/arch/xen/include/xenring.h:1.1	Sat Feb  2 12:32:55 2019
+++ src/sys/arch/xen/include/xenring.h	Sat Feb  2 14:50:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: xenring.h,v 1.1 2019/02/02 12:32:55 cherry Exp $ */
+/* $NetBSD: xenring.h,v 1.2 2019/02/02 14:50:15 cherry Exp $ */
 
 /*
  * Glue goop for xbd ring request/response protocol structures.
@@ -10,10 +10,28 @@
 #ifndef _XEN_RING_H
 #define _XEN_RING_H
 
-#if __XEN_INTERFACE_VERSION__ >= 0x00030201
+#if (__XEN_INTERFACE_VERSION__ >= 0x00030201) &&
+	(__XEN_INTERFACE_VERSION < 0x00030208)
 
 #include <xen/include/public/io/ring.h>
 
+/*
+ * Undo namespace damage from xen/include/public/io/ring.h
+ * The proper fix is to get upstream to stop assuming that all OSs use
+ * mb(), rmb(), wmb().
+ */
+#undef xen_mb
+#undef xen_rmb
+#undef xen_wmb
+
+#define xen_mb()  membar_sync()
+#define xen_rmb() membar_producer()
+#define xen_wmb() membar_consumer()
+
+/*
+ * Define ring types. These were previously part of the public API.
+ * Not anymore.
+ */
 DEFINE_RING_TYPES(blkif_x86_32, struct blkif_request, struct blkif_response);
 DEFINE_RING_TYPES(blkif_x86_64, struct blkif_request, struct blkif_response);
 
@@ -30,5 +48,6 @@ union blkif_back_ring_proto {
 };
 typedef union blkif_back_ring_proto blkif_back_ring_proto_t;
 
-#endif /* __XEN_INTERFACE_VERSION__ >= 0x00030201 */
+#endif /* __XEN_INTERFACE_VERSION__ */
+
 #endif /* _XEN_RING_H_ */

Reply via email to