Received: from eggs.gnu.org ([2001:4830:134:3::10]:53061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYDb5-00015l-2k for qemu-devel@nongnu.org; Wed, 18 Mar 2015 09:01:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYDav-0003Uz-Nx for qemu-devel@nongnu.org; Wed, 18 Mar 2015 09:01:19 -0400 Received: from mail-bn1on0075.outbound.protection.outlook.com ([157.56.110.75]:47840 helo=na01-bn1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYDav-0003Un-JY for qemu-devel@nongnu.org; Wed, 18 Mar 2015 09:01:09 -0400 From: Peter Crosthwaite Date: Wed, 18 Mar 2015 05:53:52 -0700 Message-ID: <1426683232-8847-1-git-send-email-peter.crosthwaite@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [RFC PATCH] cpus: Don't kick un-inited cpus. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, Peter Crosthwaite , alistair.francis@xilinx.com following a464982499b2f637f6699e3d03e0a9d2e0b5288b, it's now possible for there to be attempts to take the BQL before CPUs have been realized in cases where a machine model inits peripherals before the first CPU. BQL lock aquisition kicks the first_cpu, leading to a segfault if this happens pre-realize. Guard the CPU kick routine to perform no action for a CPU that doesn't exist or doesn't have a thread yet. Signed-off-by: Peter Crosthwaite --- cpus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpus.c b/cpus.c index 1ce90a1..c90dfa8 100644 --- a/cpus.c +++ b/cpus.c @@ -1046,6 +1046,10 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) static void qemu_cpu_kick_thread(CPUState *cpu) { + if (!cpu || !cpu->thread) { + return; + } + #ifndef _WIN32 int err; -- 2.3.1.2.g90df61e.dirty