]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
tcg: Do not elide memory barriers for !CF_PARALLEL in system mode
authorRichard Henderson <richard.henderson@linaro.org>
Thu, 18 Feb 2021 16:47:35 +0000 (16:47 +0000)
committerRichard Henderson <richard.henderson@linaro.org>
Mon, 26 Jun 2023 15:33:00 +0000 (17:33 +0200)
The virtio devices require proper memory ordering between
the vcpus and the iothreads.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
tcg/tcg-op.c

index c07de5d9f8e32d7cfea9a649688bce1dd8d52f03..7aadb37756d3a28ae2a3ae4f653410951171e84f 100644 (file)
@@ -102,7 +102,19 @@ void tcg_gen_br(TCGLabel *l)
 
 void tcg_gen_mb(TCGBar mb_type)
 {
-    if (tcg_ctx->gen_tb->cflags & CF_PARALLEL) {
+#ifdef CONFIG_USER_ONLY
+    bool parallel = tcg_ctx->gen_tb->cflags & CF_PARALLEL;
+#else
+    /*
+     * It is tempting to elide the barrier in a uniprocessor context.
+     * However, even with a single cpu we have i/o threads running in
+     * parallel, and lack of memory order can result in e.g. virtio
+     * queue entries being read incorrectly.
+     */
+    bool parallel = true;
+#endif
+
+    if (parallel) {
         tcg_gen_op1(INDEX_op_mb, mb_type);
     }
 }