* [PATCH 1/3] tools/virtio: include asm/bug.h
2020-12-09 8:42 [PATCH 0/3] tools/virtio: support aarch64 cross compiling Peng Fan (OSS)
@ 2020-12-09 8:42 ` Peng Fan (OSS)
2020-12-09 8:42 ` [PATCH 2/3] tools/virtio: add krealloc_array Peng Fan (OSS)
2020-12-09 8:42 ` [PATCH 3/3] tools/virtio: add barrier for aarch64 Peng Fan (OSS)
2 siblings, 0 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2020-12-09 8:42 UTC (permalink / raw)
To: mst, jasowang, virtualization, catalin.marinas, will, maz
Cc: linux-kernel, linux-imx, van.freenix, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
WARN_ON is used in drivers/vhost/vringh.c, to avoid build failure,
need include asm/bug.h
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
tools/virtio/linux/bug.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/virtio/linux/bug.h b/tools/virtio/linux/bug.h
index b14c2c3b6b85..813baf13f62a 100644
--- a/tools/virtio/linux/bug.h
+++ b/tools/virtio/linux/bug.h
@@ -2,6 +2,8 @@
#ifndef BUG_H
#define BUG_H
+#include <asm/bug.h>
+
#define BUG_ON(__BUG_ON_cond) assert(!(__BUG_ON_cond))
#define BUILD_BUG_ON(x)
--
2.28.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] tools/virtio: add krealloc_array
2020-12-09 8:42 [PATCH 0/3] tools/virtio: support aarch64 cross compiling Peng Fan (OSS)
2020-12-09 8:42 ` [PATCH 1/3] tools/virtio: include asm/bug.h Peng Fan (OSS)
@ 2020-12-09 8:42 ` Peng Fan (OSS)
2020-12-09 8:42 ` [PATCH 3/3] tools/virtio: add barrier for aarch64 Peng Fan (OSS)
2 siblings, 0 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2020-12-09 8:42 UTC (permalink / raw)
To: mst, jasowang, virtualization, catalin.marinas, will, maz
Cc: linux-kernel, linux-imx, van.freenix, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
krealloc_array is used in drivers/vhost/vringh.c, add it to avoid build
failure.
Drop WARN_ON_ONCE, because duplicated with the one in bug.h
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
tools/virtio/linux/kernel.h | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
index 315e85cabeda..0b493542e61a 100644
--- a/tools/virtio/linux/kernel.h
+++ b/tools/virtio/linux/kernel.h
@@ -11,6 +11,7 @@
#include <linux/compiler.h>
#include <linux/types.h>
+#include <linux/overflow.h>
#include <linux/list.h>
#include <linux/printk.h>
#include <linux/bug.h>
@@ -117,6 +118,16 @@ static inline void free_page(unsigned long addr)
# define unlikely(x) (__builtin_expect(!!(x), 0))
# endif
+static inline void *krealloc_array(void *p, size_t new_n, size_t new_size, gfp_t gfp)
+{
+ size_t bytes;
+
+ if (unlikely(check_mul_overflow(new_n, new_size, &bytes)))
+ return NULL;
+
+ return krealloc(p, bytes, gfp);
+}
+
#define pr_err(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
#ifdef DEBUG
#define pr_debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
@@ -126,8 +137,6 @@ static inline void free_page(unsigned long addr)
#define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
#define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
-#define WARN_ON_ONCE(cond) (unlikely(cond) ? fprintf (stderr, "WARNING\n") : 0)
-
#define min(x, y) ({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
--
2.28.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] tools/virtio: add barrier for aarch64
2020-12-09 8:42 [PATCH 0/3] tools/virtio: support aarch64 cross compiling Peng Fan (OSS)
2020-12-09 8:42 ` [PATCH 1/3] tools/virtio: include asm/bug.h Peng Fan (OSS)
2020-12-09 8:42 ` [PATCH 2/3] tools/virtio: add krealloc_array Peng Fan (OSS)
@ 2020-12-09 8:42 ` Peng Fan (OSS)
2 siblings, 0 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2020-12-09 8:42 UTC (permalink / raw)
To: mst, jasowang, virtualization, catalin.marinas, will, maz
Cc: linux-kernel, linux-imx, van.freenix, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Add barrier for aarch64 for cross compiling, and most are from Linux Kernel.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
tools/virtio/asm/barrier.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/virtio/asm/barrier.h b/tools/virtio/asm/barrier.h
index 04d563fc9b95..468435ed64e6 100644
--- a/tools/virtio/asm/barrier.h
+++ b/tools/virtio/asm/barrier.h
@@ -16,6 +16,16 @@
# define mb() abort()
# define dma_rmb() abort()
# define dma_wmb() abort()
+#elif defined(__aarch64__)
+#define dmb(opt) asm volatile("dmb " #opt : : : "memory")
+#define virt_mb() __sync_synchronize()
+#define virt_rmb() dmb(ishld)
+#define virt_wmb() dmb(ishst)
+#define virt_store_mb(var, value) do { WRITE_ONCE(var, value); dmb(ish); } while (0)
+/* Weak barriers should be used. If not - it's a bug */
+# define mb() abort()
+# define dma_rmb() abort()
+# define dma_wmb() abort()
#else
#error Please fill in barrier macros
#endif
--
2.28.0
^ permalink raw reply related [flat|nested] 4+ messages in thread