]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user/syscall: extend lock around cpu-list
authorAlex Bennée <alex.bennee@linaro.org>
Fri, 30 Sep 2016 21:31:01 +0000 (22:31 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 4 Oct 2016 08:00:26 +0000 (10:00 +0200)
There is a potential race if several threads exit at once. To serialise
the exits extend the lock above the initial checking of the CPU list.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20160930213106.20186-11-alex.bennee@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
linux-user/syscall.c

index 0815f3096549e81cfc3b67b2de61d9cfe58db00e..fa559be47f3ae79438e6dbf6302f6d0d94807532 100644 (file)
@@ -7476,13 +7476,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             break;
         }
 
+        cpu_list_lock();
+
         if (CPU_NEXT(first_cpu)) {
             TaskState *ts;
 
-            cpu_list_lock();
             /* Remove the CPU from the list.  */
             QTAILQ_REMOVE(&cpus, cpu, node);
+
             cpu_list_unlock();
+
             ts = cpu->opaque;
             if (ts->child_tidptr) {
                 put_user_u32(0, ts->child_tidptr);
@@ -7495,6 +7498,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             rcu_unregister_thread();
             pthread_exit(NULL);
         }
+
+        cpu_list_unlock();
 #ifdef TARGET_GPROF
         _mcleanup();
 #endif