From patchwork Fri Sep 23 07:15:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 9347657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B851A607F2 for ; Fri, 23 Sep 2016 08:02:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA5592A259 for ; Fri, 23 Sep 2016 08:02:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F2582A2B0; Fri, 23 Sep 2016 08:02:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 462E12A259 for ; Fri, 23 Sep 2016 08:02:55 +0000 (UTC) Received: from localhost ([::1]:41856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnLRe-0000uK-NE for patchwork-qemu-devel@patchwork.kernel.org; Fri, 23 Sep 2016 04:02:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnKir-0005s4-R8 for qemu-devel@nongnu.org; Fri, 23 Sep 2016 03:16:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnKil-00089e-S6 for qemu-devel@nongnu.org; Fri, 23 Sep 2016 03:16:37 -0400 Received: from ozlabs.org ([103.22.144.67]:53611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnKil-000879-Dc; Fri, 23 Sep 2016 03:16:31 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3sgPlX1VGbz9vFB; Fri, 23 Sep 2016 17:15:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1474614936; bh=in28MW8P8IwlECu5Lmgkusaru80OalYaO4D7jpWqO4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9kkCJzKLf1/lCnzKuaR7VFuQan7n8zvYQjehqD0d4psqQQ2yIlsKBTmipHH5Q+rT jrFhLQHfQdDzEwul7XSR0RRFdck7DYHmKJIHhr80yxHyOIjWNAnHp2gG97t602tItP EqfmUgEsJsPTeib+l8yPTkLtVbzImY0bHICLI6QY= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 23 Sep 2016 17:15:20 +1000 Message-Id: <1474614921-2221-45-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474614921-2221-1-git-send-email-david@gibson.dropbear.id.au> References: <1474614921-2221-1-git-send-email-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 44/45] monitor: fix crash for platforms without a CPU 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , qemu-ppc@nongnu.org, agraf@suse.de, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. 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. Signed-off-by: Cédric Le Goater [dwg: Rewrote commit message to better explain background] Reviewed-by: Igor Mammedov Reviewed-by: Eduardo Habkost Reviewed-by: Luiz Capitulino Signed-off-by: David Gibson --- monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } cpu_synchronize_state(cur_mon->mon_cpu); return cur_mon->mon_cpu;