2 * Process-global memory barriers
4 * Copyright (c) 2018 Red Hat, Inc.
6 * Author: Paolo Bonzini <pbonzini@redhat.com>
9 #include "qemu/osdep.h"
10 #include "qemu/sys_membarrier.h"
11 #include "qemu/error-report.h"
14 #include <linux/membarrier.h>
15 #include <sys/syscall.h>
18 membarrier(int cmd
, int flags
)
20 return syscall(__NR_membarrier
, cmd
, flags
);
24 void smp_mb_global(void)
26 #if defined CONFIG_WIN32
27 FlushProcessWriteBuffers();
28 #elif defined CONFIG_LINUX
29 membarrier(MEMBARRIER_CMD_SHARED
, 0);
31 #error --enable-membarrier is not supported on this operating system.
35 void smp_mb_global_init(void)
38 int ret
= membarrier(MEMBARRIER_CMD_QUERY
, 0);
40 error_report("This QEMU binary requires the membarrier system call.");
41 error_report("Please upgrade your system to a newer version of Linux");
44 if (!(ret
& MEMBARRIER_CMD_SHARED
)) {
45 error_report("This QEMU binary requires MEMBARRIER_CMD_SHARED support.");
46 error_report("Please upgrade your system to a newer version of Linux");