Received: from eggs.gnu.org ([2001:4830:134:3::10]:51911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmgPi-0002lN-2s for qemu-devel@nongnu.org; Wed, 21 Sep 2016 08:14:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmgPe-00052R-Ot for qemu-devel@nongnu.org; Wed, 21 Sep 2016 08:14:09 -0400 Date: Wed, 21 Sep 2016 09:14:02 -0300 From: Eduardo Habkost Message-ID: <20160921121402.GI3233@thinpad.lan.raisama.net> References: <1474435766-9727-1-git-send-email-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1474435766-9727-1-git-send-email-david@gibson.dropbear.id.au> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] monitor: fix crash for platforms without a CPU 0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-trivial@nongnu.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, lcapitulino@redhat.com, armbru@redhat.com, imammedo@redhat.com, =?iso-8859-1?Q?C=E9dric?= Le Goater On Wed, Sep 21, 2016 at 03:29:26PM +1000, David Gibson wrote: > Now that we allow CPU hot unplug on a few platforms, we can end up in a > situation where we don't have a CPU with index 0. Or at least we could= , > if we didn't have code to explicitly prohibit unplug of CPU 0. >=20 > Longer term we want to allow CPU 0 unplug, this patch is an early step = in > allowing this, by removing an assumption in the monitor code that CPU 0 > always exists. >=20 > Signed-off-by: C=E9dric Le Goater > [dwg: Rewrote commit message to better explain background] > Signed-off-by: David Gibson > --- > monitor.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > Anyone want to volunteer to take this through their tree? If not, I > can take it through my ppc tree. >=20 > diff --git a/monitor.c b/monitor.c > index 8bb8bbf..83c4edf 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -1025,7 +1025,7 @@ int monitor_set_cpu(int cpu_index) > CPUState *mon_get_cpu(void) > { > if (!cur_mon->mon_cpu) { > - monitor_set_cpu(0); > + monitor_set_cpu(first_cpu->cpu_index); So, we are replacing the "CPU 0 always exists" assumption with a "first_cpu is always non-NULL" assumption. But considering that the first_cpu assumption already exists elsewhere and those cases can be found easily using grep, I think this is OK. So: Reviewed-by: Eduardo Habkost BTW, it is also possible to crash QEMU by unplugging the current monitor CPU; (qemu) device_add qemu64-x86_64-cpu,socket-id=3D2,core-id=3D0,thread-id= =3D0,id=3Dmycpu (qemu) cpu 2 (qemu) device_del mycpu (qemu) info registers qemu:qemu_cpu_kick_thread: No such process $=20 --=20 Eduardo