]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user: Always exit from exclusive state in fork_end()
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 14 Feb 2023 14:08:26 +0000 (15:08 +0100)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 21 Feb 2023 18:44:13 +0000 (08:44 -1000)
fork()ed processes currently start with
current_cpu->in_exclusive_context set, which is, strictly speaking, not
correct, but does not cause problems (even assertion failures).

With one of the next patches, the code begins to rely on this value, so
fix it by always calling end_exclusive() in fork_end().

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20230214140829.45392-2-iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
linux-user/main.c
linux-user/syscall.c

index 4290651c3cf713653c3c81e300eb58e82e965971..4ff30ff98066502dd0af7acceacc16a3b8027809 100644 (file)
@@ -161,13 +161,15 @@ void fork_end(int child)
         }
         qemu_init_cpu_list();
         gdbserver_fork(thread_cpu);
-        /* qemu_init_cpu_list() takes care of reinitializing the
-         * exclusive state, so we don't need to end_exclusive() here.
-         */
     } else {
         cpu_list_unlock();
-        end_exclusive();
     }
+    /*
+     * qemu_init_cpu_list() reinitialized the child exclusive state, but we
+     * also need to keep current_cpu consistent, so call end_exclusive() for
+     * both child and parent.
+     */
+    end_exclusive();
 }
 
 __thread CPUState *thread_cpu;
index 1e868e9b0e279be7c827d04762bb16fc6ee5b4c1..a6c426d73cfe933c82b7f03b0d759d0134539361 100644 (file)
@@ -6752,6 +6752,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
             cpu_clone_regs_parent(env, flags);
             fork_end(0);
         }
+        g_assert(!cpu_in_exclusive_context(cpu));
     }
     return ret;
 }