From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya191-0005Wu-53 for qemu-devel@nongnu.org; Mon, 23 Mar 2015 08:07:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ya18x-0001kT-Oe for qemu-devel@nongnu.org; Mon, 23 Mar 2015 08:07:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya18x-0001kO-GH for qemu-devel@nongnu.org; Mon, 23 Mar 2015 08:07:43 -0400 Message-ID: <5510020A.4030605@redhat.com> Date: Mon, 23 Mar 2015 13:07:38 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1427107689-6946-1-git-send-email-peter.crosthwaite@xilinx.com> In-Reply-To: <1427107689-6946-1-git-send-email-peter.crosthwaite@xilinx.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.3 v2] cpus: Don't kick un-realized cpus. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite , qemu-devel@nongnu.org On 23/03/2015 11:48, Peter Crosthwaite wrote: > 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. > > There was a fix to this with commit > 6b49809c597331803ea941eadda813e5bb4e8fe2, but the check there misses > the case where the CPU has been inited and not realized. Strengthen the > check to make sure that the first_cpu has a thread (i.e. it is > realized) before allowing the kick. > > Signed-off-by: Peter Crosthwaite > --- > Fixed since V1: > Change implementation to match 6b49809c597331803ea941eadda813e5bb4e8fe2 > --- > cpus.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/cpus.c b/cpus.c > index 314df16..e6dcae3 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -1119,7 +1119,7 @@ bool qemu_in_vcpu_thread(void) > void qemu_mutex_lock_iothread(void) > { > atomic_inc(&iothread_requesting_mutex); > - if (!tcg_enabled() || !first_cpu) { > + if (!tcg_enabled() || !first_cpu || !first_cpu->thread) { > qemu_mutex_lock(&qemu_global_mutex); > atomic_dec(&iothread_requesting_mutex); > } else { > Thanks, applied. Paolo