From patchwork Thu Nov 15 09:41:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40BC7109C for ; Thu, 15 Nov 2018 09:44:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E6AD286F8 for ; Thu, 15 Nov 2018 09:44:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 228292C098; Thu, 15 Nov 2018 09:44:26 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 EB6C5286F8 for ; Thu, 15 Nov 2018 09:44:24 +0000 (UTC) Received: from localhost ([::1]:37663 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNECF-0000DL-EV for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:44:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAi-0007JB-M2 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAc-0004cm-4x for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:45 -0500 Received: from greensocs.com ([193.104.36.180]:41855) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAH-0004Lm-0q; Thu, 15 Nov 2018 04:42:21 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 1AB9C6FD8D; Thu, 15 Nov 2018 10:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274934; bh=tkFfkyXsfXUrbWBdmWA6tql8O+uSKaP2Zc61/2iL4AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pAbLDraioJ5rhlQy0Mg1c+0or6HMNHHAodhfj8QwsHZp06R/xRk4RqwhACtJXK3pl KfB/CBz1rdakFd3IiMifcz9RODGOqitw1Om0ReexqTP8DAsVhHiKtZ7JNd/MpXncj6 RSMpLfMnCgv9mx92iIbbq/oKwLmCXIuz731yddN4= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=mYD9Zjny; dkim=pass (1024-bit key) header.d=greensocs.com header.b=mYD9Zjny Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eYhW1oBDq3sg; Thu, 15 Nov 2018 10:42:12 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 933415BD180; Thu, 15 Nov 2018 10:42:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274932; bh=tkFfkyXsfXUrbWBdmWA6tql8O+uSKaP2Zc61/2iL4AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mYD9ZjnysHWZn838BvBDRau6gRSIRsixwl3UaEvgSdZh8jQEuDoTAHfSctjUh2CUp mA57anHUgMTO4pBgyQmTzE6qyFK4oHh/qzwI1AFG8ORAhYEP04YDEodw/KpLgy2kvB BJZQr0xNAGN57XHRTQo+Q4kE3eJteroNptj5Yoww= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 32E795BD196; Thu, 15 Nov 2018 10:42:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274932; bh=tkFfkyXsfXUrbWBdmWA6tql8O+uSKaP2Zc61/2iL4AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mYD9ZjnysHWZn838BvBDRau6gRSIRsixwl3UaEvgSdZh8jQEuDoTAHfSctjUh2CUp mA57anHUgMTO4pBgyQmTzE6qyFK4oHh/qzwI1AFG8ORAhYEP04YDEodw/KpLgy2kvB BJZQr0xNAGN57XHRTQo+Q4kE3eJteroNptj5Yoww= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:41:52 +0100 Message-Id: <20181115094207.22846-2-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 01/16] hw/cpu: introduce CPU clusters 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This commit adds the cpu-cluster type. It aims at gathering CPUs from the same cluster in a machine. For now it only has a `cluster-id` property. Signed-off-by: Luc Michel Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias --- include/hw/cpu/cluster.h | 38 ++++++++++++++++++++++++++ hw/cpu/cluster.c | 59 ++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 ++ hw/cpu/Makefile.objs | 2 +- 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 include/hw/cpu/cluster.h create mode 100644 hw/cpu/cluster.c diff --git a/include/hw/cpu/cluster.h b/include/hw/cpu/cluster.h new file mode 100644 index 0000000000..11f50d5f6b --- /dev/null +++ b/include/hw/cpu/cluster.h @@ -0,0 +1,38 @@ +/* + * QEMU CPU cluster + * + * Copyright (c) 2018 GreenSocs SAS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see + * + */ +#ifndef HW_CPU_CLUSTER_H +#define HW_CPU_CLUSTER_H + +#include "qemu/osdep.h" +#include "hw/qdev.h" + +#define TYPE_CPU_CLUSTER "cpu-cluster" +#define CPU_CLUSTER(obj) \ + OBJECT_CHECK(CPUClusterState, (obj), TYPE_CPU_CLUSTER) + +typedef struct CPUClusterState { + /*< private >*/ + DeviceState parent_obj; + + /*< public >*/ + uint32_t cluster_id; +} CPUClusterState; + +#endif diff --git a/hw/cpu/cluster.c b/hw/cpu/cluster.c new file mode 100644 index 0000000000..e0ffd76152 --- /dev/null +++ b/hw/cpu/cluster.c @@ -0,0 +1,59 @@ +/* + * QEMU CPU cluster + * + * Copyright (c) 2018 GreenSocs SAS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see + * + */ + +#include "qemu/osdep.h" +#include "hw/cpu/cluster.h" +#include "qapi/error.h" +#include "qemu/module.h" + +static void cpu_cluster_init(Object *obj) +{ + static uint32_t cluster_id_auto_increment; + CPUClusterState *cluster = CPU_CLUSTER(obj); + + cluster->cluster_id = cluster_id_auto_increment++; +} + +static Property cpu_cluster_properties[] = { + DEFINE_PROP_UINT32("cluster-id", CPUClusterState, cluster_id, 0), + DEFINE_PROP_END_OF_LIST() +}; + +static void cpu_cluster_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->props = cpu_cluster_properties; +} + +static const TypeInfo cpu_cluster_type_info = { + .name = TYPE_CPU_CLUSTER, + .parent = TYPE_DEVICE, + .instance_size = sizeof(CPUClusterState), + .instance_init = cpu_cluster_init, + .class_init = cpu_cluster_class_init, +}; + +static void cpu_cluster_register_types(void) +{ + type_register_static(&cpu_cluster_type_info); +} + +type_init(cpu_cluster_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 4b8db618f5..3e7a0b09c0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1029,11 +1029,13 @@ Machine core M: Eduardo Habkost M: Marcel Apfelbaum S: Supported F: hw/core/machine.c F: hw/core/null-machine.c +F: hw/cpu/cluster.c F: include/hw/boards.h +F: include/hw/cpu/cluster.h T: git https://github.com/ehabkost/qemu.git machine-next Xtensa Machines --------------- sim diff --git a/hw/cpu/Makefile.objs b/hw/cpu/Makefile.objs index cd52d20b65..8db9e8a7b3 100644 --- a/hw/cpu/Makefile.objs +++ b/hw/cpu/Makefile.objs @@ -1,5 +1,5 @@ obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o obj-$(CONFIG_REALVIEW) += realview_mpcore.o obj-$(CONFIG_A9MPCORE) += a9mpcore.o obj-$(CONFIG_A15MPCORE) += a15mpcore.o -common-obj-y += core.o +common-obj-y += core.o cluster.o From patchwork Thu Nov 15 09:41:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D6E114BA for ; Thu, 15 Nov 2018 09:44:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B258286F8 for ; Thu, 15 Nov 2018 09:44:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EDC52C098; Thu, 15 Nov 2018 09:44:29 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 B5411286F8 for ; Thu, 15 Nov 2018 09:44:28 +0000 (UTC) Received: from localhost ([::1]:37664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNECJ-0000HD-Te for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:44:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAi-0007Ic-5T for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAb-0004cQ-Qc for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:44 -0500 Received: from greensocs.com ([193.104.36.180]:41851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAH-0004Ll-0r; Thu, 15 Nov 2018 04:42:21 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 224EC6FD95; Thu, 15 Nov 2018 10:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274934; bh=M0CprRAj6jUlUEKlFc5dMkzT5RJPghUHMDARv5+btVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bPsZgDPZTaUYedt8DGxPk402AAkWZ7XpuOtItj06mnAFdMJbGF7lkFMpX5mVOAYQw 4aNmV+/gH9dh9sIvrsSerSnLzC/nnk/fEx03NUMwuRFy/bETjws4sgKzjAB1xEa6Ad jb54mBXywDNJCu35QRVVMZS84o9SsqhVrvsiUTHQ= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=QsHJtxD2; dkim=pass (1024-bit key) header.d=greensocs.com header.b=FF9wnlnR Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dqEXn_JyLHXi; Thu, 15 Nov 2018 10:42:13 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 032835BD196; Thu, 15 Nov 2018 10:42:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274933; bh=M0CprRAj6jUlUEKlFc5dMkzT5RJPghUHMDARv5+btVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QsHJtxD2R0n2JQMjdwqj0tp2VVZvkFOidwGjpIkMKtyg2eUq4rLhdDRDyKDOc3rxn aES49itKYdTznfJWAyJTDaOqJm/7Y6pyoT+FkOcKw6qikS6GP8f/8TGdvml7Botuq8 1O8JyqQLcloKT7T/EgREF04knSG+vPsUYCBmN2N4= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 933595BD1AF; Thu, 15 Nov 2018 10:42:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274932; bh=M0CprRAj6jUlUEKlFc5dMkzT5RJPghUHMDARv5+btVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FF9wnlnRjRDBLEMp+CuytThIPzgsg4a8eF8ENXT3G4Q+Fq9rTMy/HiLffJHPW/5xZ oW03cYgg3+ZGl2VyQeqCrNAwKt5P5fva3YI537mnxomr678i3H3H34zqeULmlO8xgm k09Wbt/HBrRUVsLKX/jQPYmAf/0a7ZI5E7wDenhU= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:41:53 +0100 Message-Id: <20181115094207.22846-3-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 02/16] gdbstub: introduce GDB processes 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a structure GDBProcess that represent processes from the GDB semantic point of view. CPUs can be split into different processes, by grouping them under different cpu-cluster objects. Each occurrence of a cpu-cluster object implies the existence of the corresponding process in the GDB stub. The GDB process ID is derived from the corresponding cluster ID as follows: GDB PID = cluster ID + 1 This is because PIDs -1 and 0 are reserved in GDB and cannot be used by processes. When no such container are found, all the CPUs are put in a unique GDB process (create_unique_process()). This is also the case when compiled in user mode, where multi-processes do not make much sense for now. Signed-off-by: Luc Michel Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index c4e4f9f082..26f5a7449a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -27,10 +27,11 @@ #include "monitor/monitor.h" #include "chardev/char.h" #include "chardev/char-fe.h" #include "sysemu/sysemu.h" #include "exec/gdbstub.h" +#include "hw/cpu/cluster.h" #endif #define MAX_PACKET_LENGTH 4096 #include "qemu/sockets.h" @@ -294,10 +295,15 @@ typedef struct GDBRegisterState { gdb_reg_cb set_reg; const char *xml; struct GDBRegisterState *next; } GDBRegisterState; +typedef struct GDBProcess { + uint32_t pid; + bool attached; +} GDBProcess; + enum RSState { RS_INACTIVE, RS_IDLE, RS_GETLINE, RS_GETLINE_ESC, @@ -322,10 +328,13 @@ typedef struct GDBState { int running_state; #else CharBackend chr; Chardev *mon_chr; #endif + bool multiprocess; + GDBProcess *processes; + int process_num; char syscall_buf[256]; gdb_syscall_complete_cb current_syscall_cb; } GDBState; /* By default use no IRQs and no timers while single stepping so as to @@ -1749,10 +1758,24 @@ void gdb_exit(CPUArchState *env, int code) #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&s->chr, true); #endif } +/* + * Create a unique process containing all the CPUs. + */ +static void create_unique_process(GDBState *s) +{ + GDBProcess *process; + + s->processes = g_malloc0(sizeof(GDBProcess)); + s->process_num = 1; + process = &s->processes[0]; + + process->pid = 1; +} + #ifdef CONFIG_USER_ONLY int gdb_handlesig(CPUState *cpu, int sig) { GDBState *s; @@ -1846,10 +1869,11 @@ static bool gdb_accept(void) } s = g_malloc0(sizeof(GDBState)); s->c_cpu = first_cpu; s->g_cpu = first_cpu; + create_unique_process(s); s->fd = fd; gdb_has_xml = false; gdbserver_state = s; return true; @@ -2002,10 +2026,69 @@ static const TypeInfo char_gdb_type_info = { .name = TYPE_CHARDEV_GDB, .parent = TYPE_CHARDEV, .class_init = char_gdb_class_init, }; +static int find_cpu_clusters(Object *child, void *opaque) +{ + if (object_dynamic_cast(child, TYPE_CPU_CLUSTER)) { + GDBState *s = (GDBState *) opaque; + CPUClusterState *cluster = CPU_CLUSTER(child); + GDBProcess *process; + + s->processes = g_renew(GDBProcess, s->processes, ++s->process_num); + + process = &s->processes[s->process_num - 1]; + + /* + * GDB process IDs -1 and 0 are reserved. To avoid subtle errors at + * runtime, we enforce here that the machine does not use a cluster ID + * that would lead to PID 0. */ + assert(process->pid != UINT32_MAX); + process->pid = cluster->cluster_id + 1; + process->attached = false; + + return 0; + } + + return object_child_foreach(child, find_cpu_clusters, opaque); +} + +static int pid_order(const void *a, const void *b) +{ + GDBProcess *pa = (GDBProcess *) a; + GDBProcess *pb = (GDBProcess *) b; + + if (pa->pid < pb->pid) { + return -1; + } else if (pa->pid > pb->pid) { + return 1; + } else { + return 0; + } +} + +static void create_processes(GDBState *s) +{ + object_child_foreach(object_get_root(), find_cpu_clusters, s); + + if (!s->processes) { + /* No CPU cluster specified by the machine */ + create_unique_process(s); + } else { + /* Sort by PID */ + qsort(s->processes, s->process_num, sizeof(s->processes[0]), pid_order); + } +} + +static void cleanup_processes(GDBState *s) +{ + g_free(s->processes); + s->process_num = 0; + s->processes = NULL; +} + int gdbserver_start(const char *device) { trace_gdbstub_op_start(device); GDBState *s; @@ -2058,15 +2141,19 @@ int gdbserver_start(const char *device) NULL, &error_abort); monitor_init(mon_chr, 0); } else { qemu_chr_fe_deinit(&s->chr, true); mon_chr = s->mon_chr; + cleanup_processes(s); memset(s, 0, sizeof(GDBState)); s->mon_chr = mon_chr; } s->c_cpu = first_cpu; s->g_cpu = first_cpu; + + create_processes(s); + if (chr) { qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_receive, gdb_chr_event, NULL, NULL, NULL, true); } From patchwork Thu Nov 15 09:41:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D330F17EE for ; Thu, 15 Nov 2018 09:48:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA8882C0AD for ; Thu, 15 Nov 2018 09:48:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A956C2C098; Thu, 15 Nov 2018 09:48:05 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 26FEB2C098 for ; Thu, 15 Nov 2018 09:48:05 +0000 (UTC) Received: from localhost ([::1]:37686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEFo-0003JV-8r for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:48:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAi-0007JA-M0 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAb-0004cR-Qc for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:45 -0500 Received: from greensocs.com ([193.104.36.180]:41854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAH-0004Lk-4S; Thu, 15 Nov 2018 04:42:21 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id E81BB5BD180; Thu, 15 Nov 2018 10:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274934; bh=KrQImGji4CDiFKtwmdt0cnVuILaxfZ+qg7f4LV2oAA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tp5ya3EFc5nH6hNLGpTjbDW5ruKZOffFulDbBj+aFB3cuGavercUwZQ6tn+0ot9ET DZDxy8Amm+mVKWOAz3kRVcYP0TSfgv5lH2FmEOjkpCUfhDPqLd9oUjZGKRmldhhNut r2XDG0kYoe6yZ7C0CF2jfYCfMjTP8nBpEHrjtHFc= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=voys2wYt; dkim=pass (1024-bit key) header.d=greensocs.com header.b=voys2wYt Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cPtZvQ1ChHQb; Thu, 15 Nov 2018 10:42:14 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 9E0376FD8A; Thu, 15 Nov 2018 10:42:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274933; bh=KrQImGji4CDiFKtwmdt0cnVuILaxfZ+qg7f4LV2oAA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=voys2wYtw4qMjMoFP/9xknylAHdcPhTu/VmygEh+tmdpQOGPtXw8Mn84mcU1eB3Az +vzv5J2bGHQQSjyDw+PBEodWOSf96GGJbTwLuab+uuOI7OlxDjWW72xR2iKXihdAxv jyRPfYBvPopP9cRZpU5Q0FaSRvzQYmfbYhF6SonU= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 084CB5BD1AF; Thu, 15 Nov 2018 10:42:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274933; bh=KrQImGji4CDiFKtwmdt0cnVuILaxfZ+qg7f4LV2oAA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=voys2wYtw4qMjMoFP/9xknylAHdcPhTu/VmygEh+tmdpQOGPtXw8Mn84mcU1eB3Az +vzv5J2bGHQQSjyDw+PBEodWOSf96GGJbTwLuab+uuOI7OlxDjWW72xR2iKXihdAxv jyRPfYBvPopP9cRZpU5Q0FaSRvzQYmfbYhF6SonU= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:41:54 +0100 Message-Id: <20181115094207.22846-4-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 03/16] gdbstub: add multiprocess support to '?' packets 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The gdb_get_cpu_pid() function does the PID lookup for the given CPU. It checks if the CPU is a direct child of a CPU cluster. If it is, the returned PID is the cluster ID plus one (cluster IDs start at 0, GDB PIDs at 1). When the CPU is not a child of such a container, the PID of the first process is returned. The gdb_fmt_thread_id() function generates the string to be used to identify a given thread, in a response packet for the peer. This function supports generating thread IDs when multiprocess mode is enabled (in the form `p.'). Use them in the reply to a '?' request. Signed-off-by: Luc Michel Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 26f5a7449a..4fbc05dfe3 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -638,10 +638,52 @@ static int memtox(char *buf, const char *mem, int len) } } return p - buf; } +static uint32_t gdb_get_cpu_pid(const GDBState *s, CPUState *cpu) +{ +#ifndef CONFIG_USER_ONLY + gchar *path, *name; + Object *obj; + CPUClusterState *cluster; + uint32_t ret; + + path = object_get_canonical_path(OBJECT(cpu)); + name = object_get_canonical_path_component(OBJECT(cpu)); + + if (path == NULL) { + ret = s->processes[0].pid; + goto out; + } + + /* + * Retrieve the CPU parent path by removing the last '/' and the CPU name + * from the CPU canonical path. */ + path[strlen(path) - strlen(name) - 1] = '\0'; + + obj = object_resolve_path_type(path, TYPE_CPU_CLUSTER, NULL); + + if (obj == NULL) { + ret = s->processes[0].pid; + goto out; + } + + cluster = CPU_CLUSTER(obj); + ret = cluster->cluster_id + 1; + +out: + g_free(name); + g_free(path); + + return ret; + +#else + return s->processes[0].pid; +#endif +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -907,10 +949,23 @@ static CPUState *find_cpu(uint32_t thread_id) } return NULL; } +static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, + char *buf, size_t buf_size) +{ + if (s->multiprocess) { + snprintf(buf, buf_size, "p%02x.%02x", + gdb_get_cpu_pid(s, cpu), cpu_gdb_index(cpu)); + } else { + snprintf(buf, buf_size, "%02x", cpu_gdb_index(cpu)); + } + + return buf; +} + static int is_query_packet(const char *p, const char *query, char separator) { unsigned int query_len = strlen(query); return strncmp(p, query, query_len) == 0 && @@ -1018,22 +1073,23 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) const char *p; uint32_t thread; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; + char thread_id[16]; uint8_t *registers; target_ulong addr, len; trace_gdbstub_io_command(line_buf); p = line_buf; ch = *p++; switch(ch) { case '?': /* TODO: Make this return the correct value for user-mode. */ - snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP, - cpu_gdb_index(s->c_cpu)); + snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, + gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); /* Remove all the breakpoints when this query is issued, * because gdb is doing and initial connect and the state * should be cleaned up. */ From patchwork Thu Nov 15 09:41:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6045C17EE for ; Thu, 15 Nov 2018 09:47:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE08286F8 for ; Thu, 15 Nov 2018 09:47:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 428AB2C098; Thu, 15 Nov 2018 09:47:39 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A7A9C286F8 for ; Thu, 15 Nov 2018 09:47:38 +0000 (UTC) Received: from localhost ([::1]:37684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEFN-0002bR-Tf for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:47:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAi-0007J8-M4 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAc-0004cc-4X for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:45 -0500 Received: from greensocs.com ([193.104.36.180]:41852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAH-0004Li-0n; Thu, 15 Nov 2018 04:42:21 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 107185BD196; Thu, 15 Nov 2018 10:42:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274935; bh=woUz5gMr1yRY+/kHBr+hdGYA01XkDhQ/ai5lFu+hIhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Wle3qshWqZdbHhvI7pq6YFmq8Yef/nOwfbQgubsq1i+daadJmkg1b9+tm3MRhlQDL lerwrtud1JYwKP+6hZiVqOImf6MnKgMD18BIXlEbWhUpwRERpKx1dHk0kAX9u8Ki2I JlMiXkfAC1jKlwaKZVEGtjmZuEk2HcviPL0qAKHo= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=fOvA3+EL; dkim=pass (1024-bit key) header.d=greensocs.com header.b=nNZINng3 Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UAuRcvF8-ecm; Thu, 15 Nov 2018 10:42:14 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 059555BD1AF; Thu, 15 Nov 2018 10:42:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274934; bh=woUz5gMr1yRY+/kHBr+hdGYA01XkDhQ/ai5lFu+hIhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fOvA3+ELec/3T0FOgdxNmCKhB6cLI1GcoutUa2ty7wJ4ZKhMY1etk3ys4ShxT1Tud 8C70oB1QNF7OiWW1+QqBdWJS9z1u0wwrbcTbfmAXshvlJ5s2EqxsdIBiQWaG6rmp5G aF6uBc1d8/6dTXPl6drzF8jUjCM6GdgYa/7M3OuU= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 92F325BD1BB; Thu, 15 Nov 2018 10:42:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274933; bh=woUz5gMr1yRY+/kHBr+hdGYA01XkDhQ/ai5lFu+hIhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nNZINng3jq1X0C5i3T1fGo0fi3o8LLfuMbpj3jDw3XtQ+EEXai+asIReVUsYLVIJe zI5Ar7u7BpO58K1bECNdmTHBbBy/vtWO65d9epcwOyemRTP1YtcUcLau67aBchrtr/ V7uQ+9XL4Hw+26MIYUfxrppNd9msrqAyPfgyp9d8= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:41:55 +0100 Message-Id: <20181115094207.22846-5-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 04/16] gdbstub: add multiprocess support to 'H' and 'T' packets 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a couple of helper functions to cope with GDB threads and processes. The gdb_get_process() function looks for a process given a pid. The gdb_get_cpu() function returns the CPU corresponding to the (pid, tid) pair given as parameters. The read_thread_id() function parses the thread-id sent by the peer. This function supports the multiprocess extension thread-id syntax. The return value specifies if the parsing failed, or if a special case was encountered (all processes or all threads). Use them in 'H' and 'T' packets handling to support the multiprocess extension. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 134 insertions(+), 18 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 4fbc05dfe3..fa2b7077b2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -680,10 +680,73 @@ out: #else return s->processes[0].pid; #endif } +static GDBProcess *gdb_get_process(const GDBState *s, uint32_t pid) +{ + int i; + + if (!pid) { + /* 0 means any process, we take the first one */ + return &s->processes[0]; + } + + for (i = 0; i < s->process_num; i++) { + if (s->processes[i].pid == pid) { + return &s->processes[i]; + } + } + + return NULL; +} + +static GDBProcess *gdb_get_cpu_process(const GDBState *s, CPUState *cpu) +{ + return gdb_get_process(s, gdb_get_cpu_pid(s, cpu)); +} + +static CPUState *find_cpu(uint32_t thread_id) +{ + CPUState *cpu; + + CPU_FOREACH(cpu) { + if (cpu_gdb_index(cpu) == thread_id) { + return cpu; + } + } + + return NULL; +} + +static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) +{ + GDBProcess *process; + CPUState *cpu = find_cpu(tid); + + if (!tid) { + /* 0 means any thread, we take the first one */ + tid = 1; + } + + if (cpu == NULL) { + return NULL; + } + + process = gdb_get_cpu_process(s, cpu); + + if (process->pid != pid) { + return NULL; + } + + if (!process->attached) { + return NULL; + } + + return cpu; +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -936,23 +999,10 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) cpu_synchronize_state(cpu); cpu_set_pc(cpu, pc); } -static CPUState *find_cpu(uint32_t thread_id) -{ - CPUState *cpu; - - CPU_FOREACH(cpu) { - if (cpu_gdb_index(cpu) == thread_id) { - return cpu; - } - } - - return NULL; -} - static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, char *buf, size_t buf_size) { if (s->multiprocess) { snprintf(buf, buf_size, "p%02x.%02x", @@ -962,10 +1012,64 @@ static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, } return buf; } +typedef enum GDBThreadIdKind { + GDB_ONE_THREAD = 0, + GDB_ALL_THREADS, /* One process, all threads */ + GDB_ALL_PROCESSES, + GDB_READ_THREAD_ERR +} GDBThreadIdKind; + +static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, + uint32_t *pid, uint32_t *tid) +{ + unsigned long p, t; + int ret; + + if (*buf == 'p') { + buf++; + ret = qemu_strtoul(buf, &buf, 16, &p); + + if (ret) { + return GDB_READ_THREAD_ERR; + } + + /* Skip '.' */ + buf++; + } else { + p = 1; + } + + ret = qemu_strtoul(buf, &buf, 16, &t); + + if (ret) { + return GDB_READ_THREAD_ERR; + } + + *end_buf = buf; + + if (p == -1) { + return GDB_ALL_PROCESSES; + } + + if (pid) { + *pid = p; + } + + if (t == -1) { + return GDB_ALL_THREADS; + } + + if (tid) { + *tid = t; + } + + return GDB_ONE_THREAD; +} + static int is_query_packet(const char *p, const char *query, char separator) { unsigned int query_len = strlen(query); return strncmp(p, query, query_len) == 0 && @@ -1070,16 +1174,18 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; CPUClass *cc; const char *p; uint32_t thread; + uint32_t pid, tid; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; uint8_t *registers; target_ulong addr, len; + GDBThreadIdKind thread_kind; trace_gdbstub_io_command(line_buf); p = line_buf; ch = *p++; @@ -1283,16 +1389,22 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) else put_packet(s, "E22"); break; case 'H': type = *p++; - thread = strtoull(p, (char **)&p, 16); - if (thread == -1 || thread == 0) { + + thread_kind = read_thread_id(p, &p, &pid, &tid); + if (thread_kind == GDB_READ_THREAD_ERR) { + put_packet(s, "E22"); + break; + } + + if (thread_kind != GDB_ONE_THREAD) { put_packet(s, "OK"); break; } - cpu = find_cpu(thread); + cpu = gdb_get_cpu(s, pid, tid); if (cpu == NULL) { put_packet(s, "E22"); break; } switch (type) { @@ -1308,12 +1420,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "E22"); break; } break; case 'T': - thread = strtoull(p, (char **)&p, 16); - cpu = find_cpu(thread); + thread_kind = read_thread_id(p, &p, &pid, &tid); + if (thread_kind == GDB_READ_THREAD_ERR) { + put_packet(s, "E22"); + break; + } + cpu = gdb_get_cpu(s, pid, tid); if (cpu != NULL) { put_packet(s, "OK"); } else { put_packet(s, "E22"); From patchwork Thu Nov 15 09:41:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46972109C for ; Thu, 15 Nov 2018 09:49:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35F7B2C188 for ; Thu, 15 Nov 2018 09:49:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27ACE2C18C; Thu, 15 Nov 2018 09:49:12 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 952EC2C188 for ; Thu, 15 Nov 2018 09:49:11 +0000 (UTC) Received: from localhost ([::1]:37689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEGs-00041U-Rt for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:49:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAo-0007RO-8z for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAn-0004ny-8F for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:54 -0500 Received: from greensocs.com ([193.104.36.180]:41898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAj-0004NH-UE; Thu, 15 Nov 2018 04:42:50 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id CE89D6FD97; Thu, 15 Nov 2018 10:42:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274935; bh=lhK9y98YA4eU8ZDbe/2ENqqup6ImV4sjl9SKjjGnFEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NVJqJQuR4Wh9M4i/F1zA/g7HzUPGuD6U8VONTwEmJRWo+CmtMzqq4PWqeYXctsczX BdIXMg0k4Crsy8Q3A3ahO5uSDAKOYq/ii6vYZ1y0azRamR1jh4RylWncpS+0KDmAxm jGuZRqm39XcUzhKnQhtwnfJipbGOYrUhBb5Ororg= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=NJ0IYALn; dkim=pass (1024-bit key) header.d=greensocs.com header.b=NJ0IYALn Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0A-s-cWES6Nm; Thu, 15 Nov 2018 10:42:15 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 8F7935BD1B8; Thu, 15 Nov 2018 10:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274934; bh=lhK9y98YA4eU8ZDbe/2ENqqup6ImV4sjl9SKjjGnFEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NJ0IYALn/R0g/1odJGN2UTr44KKgskUKQpbBNVuqZzDPreyGlviVRV5QKIeR8VBGV PnunjB3A5rL0CJr7y1544MPYV06vCW1FyxucyPH4vnp02btoorrLSVo+gSHZz/MUgZ xDNYS3YYzW7sExYALSnp5Lrfogx7RfKHZWw+jnsU= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 0C9B95BD1BB; Thu, 15 Nov 2018 10:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274934; bh=lhK9y98YA4eU8ZDbe/2ENqqup6ImV4sjl9SKjjGnFEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NJ0IYALn/R0g/1odJGN2UTr44KKgskUKQpbBNVuqZzDPreyGlviVRV5QKIeR8VBGV PnunjB3A5rL0CJr7y1544MPYV06vCW1FyxucyPH4vnp02btoorrLSVo+gSHZz/MUgZ xDNYS3YYzW7sExYALSnp5Lrfogx7RfKHZWw+jnsU= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:41:56 +0100 Message-Id: <20181115094207.22846-6-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 05/16] gdbstub: add multiprocess support to vCont packets 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add the gdb_first_cpu() and gdb_next_cpu() to iterate over all the CPUs in currently attached processes. Add the gdb_first_cpu_in_process() and gdb_next_cpu_in_process() to iterate over CPUs of a given process. Use them to add multiprocess extension support to vCont packets. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 15 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index fa2b7077b2..f1ec3481cb 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -716,10 +716,40 @@ static CPUState *find_cpu(uint32_t thread_id) } return NULL; } +static CPUState *get_first_cpu_in_process(const GDBState *s, + GDBProcess *process) +{ + CPUState *cpu; + + CPU_FOREACH(cpu) { + if (gdb_get_cpu_pid(s, cpu) == process->pid) { + return cpu; + } + } + + return NULL; +} + +static CPUState *gdb_next_cpu_in_process(const GDBState *s, CPUState *cpu) +{ + uint32_t pid = gdb_get_cpu_pid(s, cpu); + cpu = CPU_NEXT(cpu); + + while (cpu) { + if (gdb_get_cpu_pid(s, cpu) == pid) { + break; + } + + cpu = CPU_NEXT(cpu); + } + + return cpu; +} + static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) { GDBProcess *process; CPUState *cpu = find_cpu(tid); @@ -743,10 +773,41 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) } return cpu; } +/* Return the cpu following @cpu, while ignoring + * unattached processes. + */ +static CPUState *gdb_next_cpu(const GDBState *s, CPUState *cpu) +{ + cpu = CPU_NEXT(cpu); + + while (cpu) { + if (gdb_get_cpu_process(s, cpu)->attached) { + break; + } + + cpu = CPU_NEXT(cpu); + } + + return cpu; +} + +/* Return the first attached cpu */ +static CPUState *gdb_first_cpu(const GDBState *s) +{ + CPUState *cpu = first_cpu; + GDBProcess *process = gdb_get_cpu_process(s, cpu); + + if (!process->attached) { + return gdb_next_cpu(s, cpu); + } + + return cpu; +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -1081,14 +1142,16 @@ static int is_query_packet(const char *p, const char *query, char separator) * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if there is * a format error, 0 on success. */ static int gdb_handle_vcont(GDBState *s, const char *p) { - int res, idx, signal = 0; + int res, signal = 0; char cur_action; char *newstates; unsigned long tmp; + uint32_t pid, tid; + GDBProcess *process; CPUState *cpu; #ifdef CONFIG_USER_ONLY int max_cpus = 1; /* global variable max_cpus exists only in system mode */ CPU_FOREACH(cpu) { @@ -1127,29 +1190,52 @@ static int gdb_handle_vcont(GDBState *s, const char *p) } else if (cur_action != 'c' && cur_action != 's') { /* unknown/invalid/unsupported command */ res = -ENOTSUP; goto out; } - /* thread specification. special values: (none), -1 = all; 0 = any */ - if ((p[0] == ':' && p[1] == '-' && p[2] == '1') || (p[0] != ':')) { - if (*p == ':') { - p += 3; - } - for (idx = 0; idx < max_cpus; idx++) { - if (newstates[idx] == 1) { - newstates[idx] = cur_action; + + if (*p++ != ':') { + res = -ENOTSUP; + goto out; + } + + switch (read_thread_id(p, &p, &pid, &tid)) { + case GDB_READ_THREAD_ERR: + res = -EINVAL; + goto out; + + case GDB_ALL_PROCESSES: + cpu = gdb_first_cpu(s); + while (cpu) { + if (newstates[cpu->cpu_index] == 1) { + newstates[cpu->cpu_index] = cur_action; } + + cpu = gdb_next_cpu(s, cpu); } - } else if (*p == ':') { - p++; - res = qemu_strtoul(p, &p, 16, &tmp); - if (res) { + break; + + case GDB_ALL_THREADS: + process = gdb_get_process(s, pid); + + if (!process->attached) { + res = -EINVAL; goto out; } - /* 0 means any thread, so we pick the first valid CPU */ - cpu = tmp ? find_cpu(tmp) : first_cpu; + cpu = get_first_cpu_in_process(s, process); + while (cpu) { + if (newstates[cpu->cpu_index] == 1) { + newstates[cpu->cpu_index] = cur_action; + } + + cpu = gdb_next_cpu_in_process(s, cpu); + } + break; + + case GDB_ONE_THREAD: + cpu = gdb_get_cpu(s, pid, tid); /* invalid CPU/thread specified */ if (!cpu) { res = -EINVAL; goto out; @@ -1157,10 +1243,11 @@ static int gdb_handle_vcont(GDBState *s, const char *p) /* only use if no previous match occourred */ if (newstates[cpu->cpu_index] == 1) { newstates[cpu->cpu_index] = cur_action; } + break; } } s->signal = signal; gdb_continue_partial(s, newstates); From patchwork Thu Nov 15 09:41:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9766817EE for ; Thu, 15 Nov 2018 09:57:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 851BD28E87 for ; Thu, 15 Nov 2018 09:57:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7907829154; Thu, 15 Nov 2018 09:57:47 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 137E128E87 for ; Thu, 15 Nov 2018 09:57:47 +0000 (UTC) Received: from localhost ([::1]:37740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEPC-0002fK-BH for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:57:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAo-0007RT-BO for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAn-0004oC-Ip for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:54 -0500 Received: from greensocs.com ([193.104.36.180]:41900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAk-0004NE-17; Thu, 15 Nov 2018 04:42:50 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 17B005BD1AF; Thu, 15 Nov 2018 10:42:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274936; bh=neHuSOMMGcXioIua1s7ErMLwy+7SfUXeWQVN/U4r6gA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TvBd5XuAH5d7LgAeSQ7lLgPqQr8D7yeW9cPLqbENBCGOigBs8jdE2Bgw3VZ5jqXTU P9JeTEjgtGp/pD6yIDBBOtXLuTwhyZb/bsR4RZkSQnbCOjtpYNgp0tFnSuM3Ofb1qM NVEMdtyOt9Exuo7tLSn4A9xS/WPHH011SAmEnk6g= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=fyie5kPM; dkim=pass (1024-bit key) header.d=greensocs.com header.b=fyie5kPM Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cqJTXebKgSDh; Thu, 15 Nov 2018 10:42:15 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id E6F605BD1BB; Thu, 15 Nov 2018 10:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274934; bh=neHuSOMMGcXioIua1s7ErMLwy+7SfUXeWQVN/U4r6gA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fyie5kPMrHnc7Vx6sKKtat4BaBMMoLzCbGCsXF79EV13sohp519X1fYoje3N76JIf F5p7DsvTyGntHa7ZBf+ODBjrbWO0TSUzy7CKPGchEdDwzVsivWTGcjXTvtXRKwzs1N /Ef4ldV27Y2tDmpxLerPNKaeSGweik71dP95oyVU= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 881905BD180; Thu, 15 Nov 2018 10:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274934; bh=neHuSOMMGcXioIua1s7ErMLwy+7SfUXeWQVN/U4r6gA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fyie5kPMrHnc7Vx6sKKtat4BaBMMoLzCbGCsXF79EV13sohp519X1fYoje3N76JIf F5p7DsvTyGntHa7ZBf+ODBjrbWO0TSUzy7CKPGchEdDwzVsivWTGcjXTvtXRKwzs1N /Ef4ldV27Y2tDmpxLerPNKaeSGweik71dP95oyVU= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:41:57 +0100 Message-Id: <20181115094207.22846-7-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 06/16] gdbstub: add multiprocess support to 'sC' packets 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the sC packet handling to support the multiprocess extension. Instead of returning the first thread, we return the first thread of the current process. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index f1ec3481cb..d19b0137e8 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1546,13 +1546,18 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) type = strtoul(p, (char **)&p, 16); sstep_flags = type; put_packet(s, "OK"); break; } else if (strcmp(p,"C") == 0) { - /* "Current thread" remains vague in the spec, so always return - * the first CPU (gdb returns the first thread). */ - put_packet(s, "QC1"); + /* "Current thread" remains vague in the spec, so always return the + * first thread of the current process (gdb returns the first + * thread). + */ + cpu = get_first_cpu_in_process(s, gdb_get_cpu_process(s, s->g_cpu)); + snprintf(buf, sizeof(buf), "QC%s", + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); + put_packet(s, buf); break; } else if (strcmp(p,"fThreadInfo") == 0) { s->query_cpu = first_cpu; goto report_cpuinfo; } else if (strcmp(p,"sThreadInfo") == 0) { From patchwork Thu Nov 15 09:41:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6879317EE for ; Thu, 15 Nov 2018 09:53:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 566DC2C229 for ; Thu, 15 Nov 2018 09:53:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AC872C244; Thu, 15 Nov 2018 09:53:13 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A63FD2C229 for ; Thu, 15 Nov 2018 09:53:12 +0000 (UTC) Received: from localhost ([::1]:37711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEKl-000743-P9 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:53:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEBG-0007r7-J9 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:43:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEBE-00053Q-8i for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:43:22 -0500 Received: from greensocs.com ([193.104.36.180]:41899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEB3-0004NF-TM; Thu, 15 Nov 2018 04:43:11 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id AA21E6FD9D; Thu, 15 Nov 2018 10:42:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274936; bh=Vz03jEkEoeWXKtww+utaeJgxU7B2mcpLpZOzsXl5hzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d6QPbcz7le5zdoEhmifFn5ON0sm1N8p/QDjy2OhCzjmc2s06H1PiyJ/5GaXuW1ZjH gkle4CIc9WvWeImYl/WoNhcMBNwdJ19f2bbc3UfteaKJLoEPBapr+BCCDxB6MJPggY IVvtpN6TPb7fGJpfQvHNHpDCcG7W5bbRLHyNopEg= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=sRqDACG8; dkim=pass (1024-bit key) header.d=greensocs.com header.b=sRqDACG8 Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WOJHX7Kbahed; Thu, 15 Nov 2018 10:42:16 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 78BE56FD8A; Thu, 15 Nov 2018 10:42:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274935; bh=Vz03jEkEoeWXKtww+utaeJgxU7B2mcpLpZOzsXl5hzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sRqDACG8Kiim6s18FoKa9q28+vxBat5VPUw6vWOteOobE6viUYW3OeRrZRymQKPm7 STJVqSR0ekKlyqPO6FhGpHiymaahjJRXGFD+SsW1vQZ2YFTwk+0UdNWXFeCY74eIzH eCM/Y9BOJew6gFHVL9CSbHnzB8HI0TS965pMR7Is= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id E98666FD97; Thu, 15 Nov 2018 10:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274935; bh=Vz03jEkEoeWXKtww+utaeJgxU7B2mcpLpZOzsXl5hzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sRqDACG8Kiim6s18FoKa9q28+vxBat5VPUw6vWOteOobE6viUYW3OeRrZRymQKPm7 STJVqSR0ekKlyqPO6FhGpHiymaahjJRXGFD+SsW1vQZ2YFTwk+0UdNWXFeCY74eIzH eCM/Y9BOJew6gFHVL9CSbHnzB8HI0TS965pMR7Is= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:41:58 +0100 Message-Id: <20181115094207.22846-8-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 07/16] gdbstub: add multiprocess support to (f|s)ThreadInfo and ThreadExtraInfo 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the thread info related packets handling to support multiprocess extension. Add the CPUs class name in the extra info to help differentiate them in multiprocess mode. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index d19b0137e8..292dee8914 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1260,11 +1260,10 @@ out: static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; CPUClass *cc; const char *p; - uint32_t thread; uint32_t pid, tid; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; @@ -1556,30 +1555,46 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) snprintf(buf, sizeof(buf), "QC%s", gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); break; } else if (strcmp(p,"fThreadInfo") == 0) { - s->query_cpu = first_cpu; + s->query_cpu = gdb_first_cpu(s); goto report_cpuinfo; } else if (strcmp(p,"sThreadInfo") == 0) { report_cpuinfo: if (s->query_cpu) { - snprintf(buf, sizeof(buf), "m%x", cpu_gdb_index(s->query_cpu)); + snprintf(buf, sizeof(buf), "m%s", + gdb_fmt_thread_id(s, s->query_cpu, + thread_id, sizeof(thread_id))); put_packet(s, buf); - s->query_cpu = CPU_NEXT(s->query_cpu); + s->query_cpu = gdb_next_cpu(s, s->query_cpu); } else put_packet(s, "l"); break; } else if (strncmp(p,"ThreadExtraInfo,", 16) == 0) { - thread = strtoull(p+16, (char **)&p, 16); - cpu = find_cpu(thread); + if (read_thread_id(p + 16, &p, &pid, &tid) == GDB_READ_THREAD_ERR) { + put_packet(s, "E22"); + break; + } + cpu = gdb_get_cpu(s, pid, tid); if (cpu != NULL) { cpu_synchronize_state(cpu); - /* memtohex() doubles the required space */ - len = snprintf((char *)mem_buf, sizeof(buf) / 2, - "CPU#%d [%s]", cpu->cpu_index, - cpu->halted ? "halted " : "running"); + + if (s->multiprocess && (s->process_num > 1)) { + /* Print the CPU model in multiprocess mode */ + ObjectClass *oc = object_get_class(OBJECT(cpu)); + const char *cpu_model = object_class_get_name(oc); + len = snprintf((char *)mem_buf, sizeof(buf) / 2, + "CPU#%d %s [%s]", cpu->cpu_index, + cpu_model, + cpu->halted ? "halted " : "running"); + } else { + /* memtohex() doubles the required space */ + len = snprintf((char *)mem_buf, sizeof(buf) / 2, + "CPU#%d [%s]", cpu->cpu_index, + cpu->halted ? "halted " : "running"); + } trace_gdbstub_op_extra_info((char *)mem_buf); memtohex(buf, mem_buf, len); put_packet(s, buf); } break; From patchwork Thu Nov 15 09:41:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F28017EE for ; Thu, 15 Nov 2018 09:58:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49DE82BC45 for ; Thu, 15 Nov 2018 09:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BFC02BC83; Thu, 15 Nov 2018 09:58:37 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A68812BC45 for ; Thu, 15 Nov 2018 09:58:36 +0000 (UTC) Received: from localhost ([::1]:37737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEPz-00026K-Rd for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:58:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAo-0007RK-63 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAn-0004ns-3l for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:54 -0500 Received: from greensocs.com ([193.104.36.180]:41897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAe-0004ND-HW; Thu, 15 Nov 2018 04:42:46 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 110C55BD1B8; Thu, 15 Nov 2018 10:42:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274937; bh=WNqtR7Yf1+DcI0hNNh1yydIGO5CsVKnhZZDe/hRGBTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wHMSPPkr6VCUpuixT5vLfZHNHLN4CL1QFpuursB9rq0BQ4aqKDKOgBuiBLLy4AyN3 jGAQ75fDOZdvZl61B0ivELpRNfINLch5ISWNZnjJka9CELiuif6eVHw0Al3zui4E1N gozvv3s6F51qeOwn1L7qU67T6y1Vr0SiR6T1yNqA= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=GehBHCuy; dkim=pass (1024-bit key) header.d=greensocs.com header.b=GehBHCuy Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ruOzKgoi-1oD; Thu, 15 Nov 2018 10:42:16 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id DAAF5400FE4; Thu, 15 Nov 2018 10:42:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274935; bh=WNqtR7Yf1+DcI0hNNh1yydIGO5CsVKnhZZDe/hRGBTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GehBHCuyoqyS5IGNCE7lsh6B3Fs/R7A84V4s596tL8lbbMB4iSq1gIWdEFVcWzj/p VotGKowFR9YA36kWkRtWoOHy0bpsqupz8ftr6WHrRB0tASHBn0itrs2OqvS9T4DC2X B2k8yHov+CsrIes2GOqZRg1FskSnrxHx5xyI3SrA= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 711975BD1AF; Thu, 15 Nov 2018 10:42:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274935; bh=WNqtR7Yf1+DcI0hNNh1yydIGO5CsVKnhZZDe/hRGBTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GehBHCuyoqyS5IGNCE7lsh6B3Fs/R7A84V4s596tL8lbbMB4iSq1gIWdEFVcWzj/p VotGKowFR9YA36kWkRtWoOHy0bpsqupz8ftr6WHrRB0tASHBn0itrs2OqvS9T4DC2X B2k8yHov+CsrIes2GOqZRg1FskSnrxHx5xyI3SrA= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:41:59 +0100 Message-Id: <20181115094207.22846-9-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 08/16] gdbstub: add multiprocess support to Xfer:features:read: 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the Xfer:features:read: packet handling to support the multiprocess extension. This packet is used to request the XML description of the CPU. In multiprocess mode, different descriptions can be sent for different processes. This function now takes the process to send the description for as a parameter, and use a buffer in the process structure to store the generated description. It takes the first CPU of the process to generate the description. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Reviewed-by: Alistair Francis --- gdbstub.c | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 292dee8914..4cbc81ae5b 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -298,10 +298,12 @@ typedef struct GDBRegisterState { } GDBRegisterState; typedef struct GDBProcess { uint32_t pid; bool attached; + + char target_xml[1024]; } GDBProcess; enum RSState { RS_INACTIVE, RS_IDLE, @@ -804,55 +806,57 @@ static CPUState *gdb_first_cpu(const GDBState *s) } return cpu; } -static const char *get_feature_xml(const char *p, const char **newp, - CPUClass *cc) +static const char *get_feature_xml(const GDBState *s, const char *p, + const char **newp, GDBProcess *process) { size_t len; int i; const char *name; - static char target_xml[1024]; + CPUState *cpu = get_first_cpu_in_process(s, process); + CPUClass *cc = CPU_GET_CLASS(cpu); len = 0; while (p[len] && p[len] != ':') len++; *newp = p + len; name = NULL; if (strncmp(p, "target.xml", len) == 0) { + char *buf = process->target_xml; + const size_t buf_sz = sizeof(process->target_xml); + /* Generate the XML description for this CPU. */ - if (!target_xml[0]) { + if (!buf[0]) { GDBRegisterState *r; - CPUState *cpu = first_cpu; - pstrcat(target_xml, sizeof(target_xml), + pstrcat(buf, buf_sz, "" "" ""); if (cc->gdb_arch_name) { gchar *arch = cc->gdb_arch_name(cpu); - pstrcat(target_xml, sizeof(target_xml), ""); - pstrcat(target_xml, sizeof(target_xml), arch); - pstrcat(target_xml, sizeof(target_xml), ""); + pstrcat(buf, buf_sz, ""); + pstrcat(buf, buf_sz, arch); + pstrcat(buf, buf_sz, ""); g_free(arch); } - pstrcat(target_xml, sizeof(target_xml), "gdb_core_xml_file); - pstrcat(target_xml, sizeof(target_xml), "\"/>"); + pstrcat(buf, buf_sz, "gdb_core_xml_file); + pstrcat(buf, buf_sz, "\"/>"); for (r = cpu->gdb_regs; r; r = r->next) { - pstrcat(target_xml, sizeof(target_xml), "xml); - pstrcat(target_xml, sizeof(target_xml), "\"/>"); + pstrcat(buf, buf_sz, "xml); + pstrcat(buf, buf_sz, "\"/>"); } - pstrcat(target_xml, sizeof(target_xml), ""); + pstrcat(buf, buf_sz, ""); } - return target_xml; + return buf; } if (cc->gdb_get_dynamic_xml) { - CPUState *cpu = first_cpu; char *xmlname = g_strndup(p, len); const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname); g_free(xmlname); if (xml) { @@ -1258,10 +1262,11 @@ out: } static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; + GDBProcess *process; CPUClass *cc; const char *p; uint32_t pid, tid; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; @@ -1639,18 +1644,19 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } if (strncmp(p, "Xfer:features:read:", 19) == 0) { const char *xml; target_ulong total_len; - cc = CPU_GET_CLASS(first_cpu); + process = gdb_get_cpu_process(s, s->g_cpu); + cc = CPU_GET_CLASS(s->g_cpu); if (cc->gdb_core_xml_file == NULL) { goto unknown_command; } gdb_has_xml = true; p += 19; - xml = get_feature_xml(p, &p, cc); + xml = get_feature_xml(s, p, &p, process); if (!xml) { snprintf(buf, sizeof(buf), "E00"); put_packet(s, buf); break; } @@ -2323,10 +2329,11 @@ static int find_cpu_clusters(Object *child, void *opaque) * runtime, we enforce here that the machine does not use a cluster ID * that would lead to PID 0. */ assert(process->pid != UINT32_MAX); process->pid = cluster->cluster_id + 1; process->attached = false; + process->target_xml[0] = '\0'; return 0; } return object_child_foreach(child, find_cpu_clusters, opaque); From patchwork Thu Nov 15 09:42:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42ED417EE for ; Thu, 15 Nov 2018 09:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 315DE2C199 for ; Thu, 15 Nov 2018 09:51:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22B952C1E4; Thu, 15 Nov 2018 09:51:44 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 B6D5A2C199 for ; Thu, 15 Nov 2018 09:51:43 +0000 (UTC) Received: from localhost ([::1]:37707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEJI-0005gz-Hv for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:51:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAn-0007Qy-S3 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAm-0004nm-W3 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:53 -0500 Received: from greensocs.com ([193.104.36.180]:41901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAj-0004NM-Rc; Thu, 15 Nov 2018 04:42:50 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 9FFA26FD98; Thu, 15 Nov 2018 10:42:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274937; bh=UDBAOEVSGWfQh0O7xzhIy8vCKBw2kBRw29FVMs7Wq7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FUXvT8egb6bjx0mzb0X8q+ZRByIk4H2qg+e1c9/P7+hFDeLgTYOS0hpLTWhvLtev6 jxOdEl1/yKP183YU1itVsB/lASwaBg+SyLvWVvBsI7mtzJ5PGZ8fYbOxhZvbETAjCa eBHGE04CidYkIbkBa588tH+2D6IyuxjQMYbsAWA4= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=U7YjMWJ/; dkim=pass (1024-bit key) header.d=greensocs.com header.b=U7YjMWJ/ Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4YlkwEJKfnbJ; Thu, 15 Nov 2018 10:42:16 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 5955F5BD1BB; Thu, 15 Nov 2018 10:42:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274936; bh=UDBAOEVSGWfQh0O7xzhIy8vCKBw2kBRw29FVMs7Wq7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=U7YjMWJ/fzB1iqX+waDw6daR7Kuku/eTvWSie2RYSx8DZ97nDu7iWH8a/4ZNILvAt LXkMBULJcCIArz3bgxD/Jsa6vdE+Mmz+TfTs6uvUIUKTyz1UMSo4TZpVXN0+sBsSkd OfWYgU2W0RddEIWoAiSqfdt4hpFoJHl8N+qjhOM0= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id DA5E76FD9D; Thu, 15 Nov 2018 10:42:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274936; bh=UDBAOEVSGWfQh0O7xzhIy8vCKBw2kBRw29FVMs7Wq7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=U7YjMWJ/fzB1iqX+waDw6daR7Kuku/eTvWSie2RYSx8DZ97nDu7iWH8a/4ZNILvAt LXkMBULJcCIArz3bgxD/Jsa6vdE+Mmz+TfTs6uvUIUKTyz1UMSo4TZpVXN0+sBsSkd OfWYgU2W0RddEIWoAiSqfdt4hpFoJHl8N+qjhOM0= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:42:00 +0100 Message-Id: <20181115094207.22846-10-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 09/16] gdbstub: add multiprocess support to gdb_vm_state_change() 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for multiprocess extension in gdb_vm_state_change() function. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 4cbc81ae5b..5df9929f92 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1713,10 +1713,11 @@ void gdb_set_stop_cpu(CPUState *cpu) static void gdb_vm_state_change(void *opaque, int running, RunState state) { GDBState *s = gdbserver_state; CPUState *cpu = s->c_cpu; char buf[256]; + char thread_id[16]; const char *type; int ret; if (running || s->state == RS_INACTIVE) { return; @@ -1724,10 +1725,18 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) /* Is there a GDB syscall waiting to be sent? */ if (s->current_syscall_cb) { put_packet(s, s->syscall_buf); return; } + + if (cpu == NULL) { + /* No process attached */ + return; + } + + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id)); + switch (state) { case RUN_STATE_DEBUG: if (cpu->watchpoint_hit) { switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) { case BP_MEM_READ: @@ -1741,12 +1750,12 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) break; } trace_gdbstub_hit_watchpoint(type, cpu_gdb_index(cpu), (target_ulong)cpu->watchpoint_hit->vaddr); snprintf(buf, sizeof(buf), - "T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";", - GDB_SIGNAL_TRAP, cpu_gdb_index(cpu), type, + "T%02xthread:%s;%swatch:" TARGET_FMT_lx ";", + GDB_SIGNAL_TRAP, thread_id, type, (target_ulong)cpu->watchpoint_hit->vaddr); cpu->watchpoint_hit = NULL; goto send_packet; } else { trace_gdbstub_hit_break(); @@ -1784,11 +1793,11 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) trace_gdbstub_hit_unknown(state); ret = GDB_SIGNAL_UNKNOWN; break; } gdb_set_stop_cpu(cpu); - snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_gdb_index(cpu)); + snprintf(buf, sizeof(buf), "T%02xthread:%s;", ret, thread_id); send_packet: put_packet(s, buf); /* disable single step if it was enabled */ From patchwork Thu Nov 15 09:42:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80225109C for ; Thu, 15 Nov 2018 09:52:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D2CF2C1DF for ; Thu, 15 Nov 2018 09:52:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60C272C222; Thu, 15 Nov 2018 09:52:46 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 030952C1DF for ; Thu, 15 Nov 2018 09:52:46 +0000 (UTC) Received: from localhost ([::1]:37710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEKL-0006Ys-97 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:52:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAn-0007Qm-QA for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAm-0004nc-RZ for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:53 -0500 Received: from greensocs.com ([193.104.36.180]:41903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAj-0004NI-QQ; Thu, 15 Nov 2018 04:42:50 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id F25C36FD8A; Thu, 15 Nov 2018 10:42:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274938; bh=FMStnxZ0F50sIEZeH3i6wcynmSEJaimYI3uhMKzTQ5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gFIWKxx4IDij/WZUkQGC1RVB1p1y+Anj+KOt6RGVIfAPUaateys0zNfot/YE7VmkM gRPRdcp+cMyPfmNmUsttgmA4iTztEvLV5gc9iUFOJED8VKHM4qjmSvDjueCzSD5w4r tvD5oVM82JB4zirqB0hn1G3JHGpZHrsYxIES8mqs= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=4wSVQ0nT; dkim=pass (1024-bit key) header.d=greensocs.com header.b=4wSVQ0nT Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gcyN7FIn4iYl; Thu, 15 Nov 2018 10:42:17 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id BC3BD441B57; Thu, 15 Nov 2018 10:42:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274936; bh=FMStnxZ0F50sIEZeH3i6wcynmSEJaimYI3uhMKzTQ5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=4wSVQ0nT+KvyUjwW5SwW+qcSnGBjwlAMQTmASeHZvJX5q+E77f2FEVlVxRzrlPVb2 iIqg5xeazABdXBBXqT11CZRoJkEZs+LCwzHDJ9wleKbFkhZgwrxJ5WfvZKNmh3xdC7 l0k1gBdGyiq7AgT39A0gD9Oql6ftS9qyCgPqUdHU= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 5CCEA6FD98; Thu, 15 Nov 2018 10:42:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274936; bh=FMStnxZ0F50sIEZeH3i6wcynmSEJaimYI3uhMKzTQ5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=4wSVQ0nT+KvyUjwW5SwW+qcSnGBjwlAMQTmASeHZvJX5q+E77f2FEVlVxRzrlPVb2 iIqg5xeazABdXBBXqT11CZRoJkEZs+LCwzHDJ9wleKbFkhZgwrxJ5WfvZKNmh3xdC7 l0k1gBdGyiq7AgT39A0gD9Oql6ftS9qyCgPqUdHU= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:42:01 +0100 Message-Id: <20181115094207.22846-11-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 10/16] gdbstub: add multiprocess support to 'D' packets 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 'D' packets are used by GDB to detach from a process. In multiprocess mode, the PID to detach from is sent in the request. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 5df9929f92..eec1cf0d09 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1039,24 +1039,39 @@ static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type) default: return -ENOSYS; } } +static inline void gdb_cpu_breakpoint_remove_all(CPUState *cpu) +{ + cpu_breakpoint_remove_all(cpu, BP_GDB); +#ifndef CONFIG_USER_ONLY + cpu_watchpoint_remove_all(cpu, BP_GDB); +#endif +} + +static void gdb_process_breakpoint_remove_all(const GDBState *s, GDBProcess *p) +{ + CPUState *cpu = get_first_cpu_in_process(s, p); + + while (cpu) { + gdb_cpu_breakpoint_remove_all(cpu); + cpu = gdb_next_cpu_in_process(s, cpu); + } +} + static void gdb_breakpoint_remove_all(void) { CPUState *cpu; if (kvm_enabled()) { kvm_remove_all_breakpoints(gdbserver_state->c_cpu); return; } CPU_FOREACH(cpu) { - cpu_breakpoint_remove_all(cpu, BP_GDB); -#ifndef CONFIG_USER_ONLY - cpu_watchpoint_remove_all(cpu, BP_GDB); -#endif + gdb_cpu_breakpoint_remove_all(cpu); } } static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) { @@ -1331,13 +1346,44 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); exit(0); case 'D': /* Detach packet */ - gdb_breakpoint_remove_all(); - gdb_syscall_mode = GDB_SYS_DISABLED; - gdb_continue(s); + pid = 1; + + if (s->multiprocess) { + unsigned long lpid; + if (*p != ';') { + put_packet(s, "E22"); + break; + } + + if (qemu_strtoul(p + 1, &p, 16, &lpid)) { + put_packet(s, "E22"); + break; + } + + pid = lpid; + } + + process = gdb_get_process(s, pid); + gdb_process_breakpoint_remove_all(s, process); + process->attached = false; + + if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { + s->c_cpu = gdb_first_cpu(s); + } + + if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { + s->g_cpu = gdb_first_cpu(s); + } + + if (s->c_cpu == NULL) { + /* No more process attached */ + gdb_syscall_mode = GDB_SYS_DISABLED; + gdb_continue(s); + } put_packet(s, "OK"); break; case 's': if (*p != '\0') { addr = strtoull(p, (char **)&p, 16); From patchwork Thu Nov 15 09:42:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E78EF14BA for ; Thu, 15 Nov 2018 10:01:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D52582928B for ; Thu, 15 Nov 2018 10:01:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C94262C405; Thu, 15 Nov 2018 10:01:16 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 AF96E2928B for ; Thu, 15 Nov 2018 10:01:15 +0000 (UTC) Received: from localhost ([::1]:37768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNESY-0005uw-Fh for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 05:01:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEBG-0007r5-If for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:43:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEBE-00053L-3z for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:43:22 -0500 Received: from greensocs.com ([193.104.36.180]:41902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEB4-0004NO-0P; Thu, 15 Nov 2018 04:43:11 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 947F95BD1BB; Thu, 15 Nov 2018 10:42:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274938; bh=+CaC0VEimyO/GjsARvQENMrckw79wtWNMlRkaKEVcsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iZaSiUWD5UrFtZXas7jE4qD51PlcQFvbGmloNCfGdt6eTz+73nQluUt8pszDtdpUY fvDDlPQUfpbAJ29r3MW6Yx2HAoWAWzTKmRsemDviddIT52+L1pi9EUwgZ/NEu/tEGO n/aAuW8vuwRetvT1jfMWkuTqi0FK/lnAqveO3Mmk= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=zsrHab4p; dkim=pass (1024-bit key) header.d=greensocs.com header.b=zsrHab4p Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gtfGjt8aP9Y1; Thu, 15 Nov 2018 10:42:17 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 3E1EF400FE4; Thu, 15 Nov 2018 10:42:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274937; bh=+CaC0VEimyO/GjsARvQENMrckw79wtWNMlRkaKEVcsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zsrHab4p7DuItY5hu1ayplQ4WW5Q8ZjR7mocxnKJUl8l5UsMYIqJa+MPAFDflVJXw be4PAu6KQB5uEbfc7TXk0Z4jieB1FHtkMUPytP0tA7v3vM/BJ3EydpOwFJPlJ6D6lC 5N/RXqUPvo17+y0jI4OIttX7R/ACqQjg+77R3w48= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id C07B86FD98; Thu, 15 Nov 2018 10:42:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274937; bh=+CaC0VEimyO/GjsARvQENMrckw79wtWNMlRkaKEVcsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zsrHab4p7DuItY5hu1ayplQ4WW5Q8ZjR7mocxnKJUl8l5UsMYIqJa+MPAFDflVJXw be4PAu6KQB5uEbfc7TXk0Z4jieB1FHtkMUPytP0tA7v3vM/BJ3EydpOwFJPlJ6D6lC 5N/RXqUPvo17+y0jI4OIttX7R/ACqQjg+77R3w48= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:42:02 +0100 Message-Id: <20181115094207.22846-12-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 11/16] gdbstub: add support for extended mode packet 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for the '!' extended mode packet. This is required for the multiprocess extension. Signed-off-by: Luc Michel Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index eec1cf0d09..ada53ac559 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1294,10 +1294,13 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) trace_gdbstub_io_command(line_buf); p = line_buf; ch = *p++; switch(ch) { + case '!': + put_packet(s, "OK"); + break; case '?': /* TODO: Make this return the correct value for user-mode. */ snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); From patchwork Thu Nov 15 09:42:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C033D17EE for ; Thu, 15 Nov 2018 09:51:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABD412C199 for ; Thu, 15 Nov 2018 09:51:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96FAA2C1E4; Thu, 15 Nov 2018 09:51:46 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 4C2782C199 for ; Thu, 15 Nov 2018 09:51:46 +0000 (UTC) Received: from localhost ([::1]:37709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEJN-0005jH-En for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:51:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAl-0007Nu-Ih for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAh-0004fz-Iv for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:51 -0500 Received: from greensocs.com ([193.104.36.180]:41904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAU-0004NP-RJ; Thu, 15 Nov 2018 04:42:36 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id E4B27400FE4; Thu, 15 Nov 2018 10:42:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274938; bh=9Lroo8lp/NrsN5CPeEin+WNWgbyuC7KOEH8dyRxdbv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aoa52CNhhi5eV5iI+pBG38VFZM//Mm4GVbxZpXPq1kK4EWbwcuPOoQX4Qwf3xmCJi 51Ey0too37A6H21z0/ptCo73OFcLiIxRycI2/78mlVYYAvEQnti4BxEnGl7zfAsNeI MkZJvx/kX6DW9Cg2gxQ3dp/0Vhr/sgY458I6CecA= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=aoa52CNh; dkim=pass (1024-bit key) header.d=greensocs.com header.b=pDd0cKIw Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YIPpuE792Sck; Thu, 15 Nov 2018 10:42:18 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 08A6144325D; Thu, 15 Nov 2018 10:42:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274938; bh=9Lroo8lp/NrsN5CPeEin+WNWgbyuC7KOEH8dyRxdbv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aoa52CNhhi5eV5iI+pBG38VFZM//Mm4GVbxZpXPq1kK4EWbwcuPOoQX4Qwf3xmCJi 51Ey0too37A6H21z0/ptCo73OFcLiIxRycI2/78mlVYYAvEQnti4BxEnGl7zfAsNeI MkZJvx/kX6DW9Cg2gxQ3dp/0Vhr/sgY458I6CecA= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 343CB441B67; Thu, 15 Nov 2018 10:42:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274937; bh=9Lroo8lp/NrsN5CPeEin+WNWgbyuC7KOEH8dyRxdbv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pDd0cKIwnSxhkx+rhz4E9vc5vzZdwb6VHlt4kCi6UYCf9z3s53XkQ3EcDmu5uN+f/ 90kbqU+85K2EhnALZc6YeaQpvvXBKENFd1X0d9wUBPNIKLQJxSHGhAJIr+Ax6P7uwV /nLe7jRlnaVSMYv8+ql65gIkg35gIuP64T3oMsH8= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:42:03 +0100 Message-Id: <20181115094207.22846-13-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 12/16] gdbstub: add support for vAttach packets 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for the vAttach packets. In multiprocess mode, GDB sends them to attach to additional processes. Signed-off-by: Luc Michel Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index ada53ac559..0427d1c4f0 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1340,10 +1340,45 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) break; } goto unknown_command; } break; + } else if (strncmp(p, "Attach;", 7) == 0) { + unsigned long pid; + + p += 7; + + if (qemu_strtoul(p, &p, 16, &pid)) { + put_packet(s, "E22"); + break; + } + + process = gdb_get_process(s, pid); + + if (process == NULL) { + put_packet(s, "E22"); + break; + } + + cpu = get_first_cpu_in_process(s, process); + + if (cpu == NULL) { + /* Refuse to attach an empty process */ + put_packet(s, "E22"); + break; + } + + process->attached = true; + + s->g_cpu = cpu; + s->c_cpu = cpu; + + snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); + + put_packet(s, buf); + break; } else { goto unknown_command; } case 'k': /* Kill the target */ From patchwork Thu Nov 15 09:42:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0903B17EE for ; Thu, 15 Nov 2018 09:49:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC1422C188 for ; Thu, 15 Nov 2018 09:49:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEA652C18F; Thu, 15 Nov 2018 09:49:55 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 5B0262C188 for ; Thu, 15 Nov 2018 09:49:55 +0000 (UTC) Received: from localhost ([::1]:37693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEHa-0004TP-3j for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:49:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEBG-0007r6-JB for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:43:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEBE-00053G-3i for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:43:22 -0500 Received: from greensocs.com ([193.104.36.180]:41906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEB3-0004NU-Sf; Thu, 15 Nov 2018 04:43:11 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 6892C44325E; Thu, 15 Nov 2018 10:42:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274939; bh=EIdLDC5u0xmtQYqBAdduMjysY1VZBCN7v1PRkawPBBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CPAZhkg4Oo0nIJt0iuyllTkm77cpAeRotRtxmdzfBW7tx6yUV0SuYn21vC4VZkB7O YhknryzOs5ajsDpmDyc60cnNlFLIp0/1vYMxE5VEXwRmo9M2D+nggZjF1POXRLiavU X0ipuqkDGY5xuDOGg4JbI224x9ySEwC3GOvwrNDQ= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=b4c72gY1; dkim=pass (1024-bit key) header.d=greensocs.com header.b=b4c72gY1 Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 35_EZBPGN4FF; Thu, 15 Nov 2018 10:42:18 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 6F3CC441B67; Thu, 15 Nov 2018 10:42:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274938; bh=EIdLDC5u0xmtQYqBAdduMjysY1VZBCN7v1PRkawPBBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b4c72gY1ICbj9h0o0ETZSfn4mdQWZxp4Txna0G6q4vRjjSah5K1pCr4SMAO74GZ84 uwuvc56c24YDLqn3u+5YRTyBc6Ei4EgLm/b8ZHPHZjozO0dI4WYCcAme8am0sCVKfn +mrdIgOo7vQqGekScB/RCfJQc3ZXH6osaGH6Ued0= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id DBE905BD1BB; Thu, 15 Nov 2018 10:42:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274938; bh=EIdLDC5u0xmtQYqBAdduMjysY1VZBCN7v1PRkawPBBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b4c72gY1ICbj9h0o0ETZSfn4mdQWZxp4Txna0G6q4vRjjSah5K1pCr4SMAO74GZ84 uwuvc56c24YDLqn3u+5YRTyBc6Ei4EgLm/b8ZHPHZjozO0dI4WYCcAme8am0sCVKfn +mrdIgOo7vQqGekScB/RCfJQc3ZXH6osaGH6Ued0= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:42:04 +0100 Message-Id: <20181115094207.22846-14-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 13/16] gdbstub: processes initialization on new peer connection 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When a new connection is established, we set the first process to be attached, and the others detached. The first CPU of the first process is selected as the current CPU. Signed-off-by: Luc Michel Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 0427d1c4f0..59eed3b878 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2245,13 +2245,14 @@ static bool gdb_accept(void) close(fd); return false; } s = g_malloc0(sizeof(GDBState)); - s->c_cpu = first_cpu; - s->g_cpu = first_cpu; create_unique_process(s); + s->processes[0].attached = true; + s->c_cpu = gdb_first_cpu(s); + s->g_cpu = s->c_cpu; s->fd = fd; gdb_has_xml = false; gdbserver_state = s; return true; @@ -2333,12 +2334,23 @@ static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) } } static void gdb_chr_event(void *opaque, int event) { + int i; + GDBState *s = (GDBState *) opaque; + switch (event) { case CHR_EVENT_OPENED: + /* Start with first process attached, others detached */ + for (i = 0; i < s->process_num; i++) { + s->processes[i].attached = !i; + } + + s->c_cpu = gdb_first_cpu(s); + s->g_cpu = s->c_cpu; + vm_stop(RUN_STATE_PAUSED); gdb_has_xml = false; break; default: break; @@ -2524,19 +2536,17 @@ int gdbserver_start(const char *device) mon_chr = s->mon_chr; cleanup_processes(s); memset(s, 0, sizeof(GDBState)); s->mon_chr = mon_chr; } - s->c_cpu = first_cpu; - s->g_cpu = first_cpu; create_processes(s); if (chr) { qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_receive, - gdb_chr_event, NULL, NULL, NULL, true); + gdb_chr_event, NULL, s, NULL, true); } s->state = chr ? RS_IDLE : RS_INACTIVE; s->mon_chr = mon_chr; s->current_syscall_cb = NULL; From patchwork Thu Nov 15 09:42:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6A8317EE for ; Thu, 15 Nov 2018 09:55:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 927D829154 for ; Thu, 15 Nov 2018 09:55:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DAC52950F; Thu, 15 Nov 2018 09:55:44 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 BFF822C516 for ; Thu, 15 Nov 2018 09:55:43 +0000 (UTC) Received: from localhost ([::1]:37731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNENC-0000uM-9I for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:55:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAo-0007Re-GD for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAn-0004oT-NF for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:54 -0500 Received: from greensocs.com ([193.104.36.180]:41905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAk-0004NT-0v; Thu, 15 Nov 2018 04:42:50 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id B2C07441B67; Thu, 15 Nov 2018 10:42:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274939; bh=5y0tKMHMdk7YdAq4Id1MBSsyrMbMoeOzN/P9UoGb6YU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2b+o51QYRoStLw7FwLpKZ6bFw6mD/aGe3LYGffCPOE3uevzHEwn4vgwS7Qq/HG59d pGgNNB9a8O3HHZG4nAa14fesd6clJsBXQH2TZj5+GkL3GpQxamYuQAdG8yuEy0nkCn dgnNvMcxgmpnlfHrkwNVEmnOHV1++IA4C36z7StQ= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=2b+o51QY; dkim=pass (1024-bit key) header.d=greensocs.com header.b=C5VGWyWN Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kYHPFGZEkf8b; Thu, 15 Nov 2018 10:42:19 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 01935446865; Thu, 15 Nov 2018 10:42:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274939; bh=5y0tKMHMdk7YdAq4Id1MBSsyrMbMoeOzN/P9UoGb6YU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2b+o51QYRoStLw7FwLpKZ6bFw6mD/aGe3LYGffCPOE3uevzHEwn4vgwS7Qq/HG59d pGgNNB9a8O3HHZG4nAa14fesd6clJsBXQH2TZj5+GkL3GpQxamYuQAdG8yuEy0nkCn dgnNvMcxgmpnlfHrkwNVEmnOHV1++IA4C36z7StQ= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 649A4441B57; Thu, 15 Nov 2018 10:42:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274938; bh=5y0tKMHMdk7YdAq4Id1MBSsyrMbMoeOzN/P9UoGb6YU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=C5VGWyWNyIMRs0MRiVZ5LRC9hcK3i7OwsytPU+Ht/zglKDs7OzEHDv/sl7j0fGvgZ nVEWj5gEgatipdfAoBd0YPTwE4b+v5QTx+S+9E7VSAp753LCRIc7hjRjynKdweF31n aq3k6+2dx3QolguN+LwUoQl+oSR9Mwx6iEJcfwM0= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:42:05 +0100 Message-Id: <20181115094207.22846-15-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 14/16] gdbstub: gdb_set_stop_cpu: ignore request when process is not attached 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When gdb_set_stop_cpu() is called with a CPU associated to a process currently not attached by the GDB client, return without modifying the stop CPU. Otherwise, GDB gets confused if it receives packets with a thread-id it does not know about. Signed-off-by: Luc Michel Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 59eed3b878..89819a6a72 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1787,10 +1787,19 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) return RS_IDLE; } void gdb_set_stop_cpu(CPUState *cpu) { + GDBProcess *p = gdb_get_cpu_process(gdbserver_state, cpu); + + if (!p->attached) { + /* Having a stop CPU corresponding to a process that is not attached + * confuses GDB. So we ignore the request. + */ + return; + } + gdbserver_state->c_cpu = cpu; gdbserver_state->g_cpu = cpu; } #ifndef CONFIG_USER_ONLY From patchwork Thu Nov 15 09:42:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DACC7109C for ; Thu, 15 Nov 2018 09:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB62E2C043 for ; Thu, 15 Nov 2018 09:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD89B2C0AD; Thu, 15 Nov 2018 09:46:00 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 9CDDF2C043 for ; Thu, 15 Nov 2018 09:45:59 +0000 (UTC) Received: from localhost ([::1]:37675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEDm-0001Vb-SK for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:45:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAo-0007Rc-Fk for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAn-0004oO-Ly for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:54 -0500 Received: from greensocs.com ([193.104.36.180]:41929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAk-0004bT-2v; Thu, 15 Nov 2018 04:42:50 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 36CD2441B57; Thu, 15 Nov 2018 10:42:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274940; bh=eTAQ3gyUIFB+pZwXAVSZtIdNbFbdyQOd/43CxMn9TWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=n1DtfkK3QIznDJ0azW0j04kyyXhvpJ6RqT3Kbla4INX8Ug+YmoDk2uWN4oduhPvsQ xGDGJaeOSfRltVEpwBYJbXY/Ty7YrNUtbZ4eHqWjPaNdOmnt7b/z/Sb3ZRaPBYgxta nUIbBz6V9P52zldTamS3jnyKBROelIS8UloPF0Wk= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=OkXHKONa; dkim=pass (1024-bit key) header.d=greensocs.com header.b=OkXHKONa Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EyvazNl1m3le; Thu, 15 Nov 2018 10:42:19 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 6573D44325D; Thu, 15 Nov 2018 10:42:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274939; bh=eTAQ3gyUIFB+pZwXAVSZtIdNbFbdyQOd/43CxMn9TWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OkXHKONa42m+5+VrFoAVETRMV4C8TsIOYjIZi7uz7dPKsuULccU1g5R7yNr63C4ps mDy1obj47vqIJ2m33TctwaViRyTLPpPD28nDs9Yundyu+qb2RUUkmYkPkklEWfEWOc zrJamrxQUvmtFB/hoShf9CctAMFis1NFTMNajv0s= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id E651144325E; Thu, 15 Nov 2018 10:42:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274939; bh=eTAQ3gyUIFB+pZwXAVSZtIdNbFbdyQOd/43CxMn9TWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OkXHKONa42m+5+VrFoAVETRMV4C8TsIOYjIZi7uz7dPKsuULccU1g5R7yNr63C4ps mDy1obj47vqIJ2m33TctwaViRyTLPpPD28nDs9Yundyu+qb2RUUkmYkPkklEWfEWOc zrJamrxQUvmtFB/hoShf9CctAMFis1NFTMNajv0s= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:42:06 +0100 Message-Id: <20181115094207.22846-16-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 15/16] gdbstub: add multiprocess extension support 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add multiprocess extension support by enabling multiprocess mode when the peer requests it, and by replying that we actually support it in the qSupported reply packet. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 89819a6a72..e0b844c040 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1721,10 +1721,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH); cc = CPU_GET_CLASS(first_cpu); if (cc->gdb_core_xml_file != NULL) { pstrcat(buf, sizeof(buf), ";qXfer:features:read+"); } + + if (strstr(p, "multiprocess+")) { + s->multiprocess = true; + } + pstrcat(buf, sizeof(buf), ";multiprocess+"); + put_packet(s, buf); break; } if (strncmp(p, "Xfer:features:read:", 19) == 0) { const char *xml; From patchwork Thu Nov 15 09:42:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10684063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9F9B17EE for ; Thu, 15 Nov 2018 09:54:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94556287FE for ; Thu, 15 Nov 2018 09:54:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 819AD28535; Thu, 15 Nov 2018 09:54:52 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 217AF29425 for ; Thu, 15 Nov 2018 09:54:47 +0000 (UTC) Received: from localhost ([::1]:37724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEMI-00008a-AY for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 04:54:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAo-0007Rw-SG for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNEAn-0004oj-Vi for qemu-devel@nongnu.org; Thu, 15 Nov 2018 04:42:54 -0500 Received: from greensocs.com ([193.104.36.180]:41904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNEAk-0004NP-49; Thu, 15 Nov 2018 04:42:50 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id BA45C44325B; Thu, 15 Nov 2018 10:42:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274940; bh=Dkji4JTfOdePjfk92E+wL5e2vsn+se5ApMpIQQk9dpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fhqipl6MXaULk1MfmS37Pg5sVXuKicOLiowChTpqKyJQAYxLAHagKCpQlKA8by76A 30IGygdw4P0Oq+Q5u5pwEffZcVRRG9xfv4N79rnh58uAZpfqG8KS1PoF3I0XB1puP8 WWMNIp3oA9BhOG4xfsUXx3bDdvMzBICRhlWQnaMQ= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=rgBeLN2t; dkim=pass (1024-bit key) header.d=greensocs.com header.b=rgBeLN2t Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VpKE5Dt3e3f5; Thu, 15 Nov 2018 10:42:19 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id CF83F446876; Thu, 15 Nov 2018 10:42:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274939; bh=Dkji4JTfOdePjfk92E+wL5e2vsn+se5ApMpIQQk9dpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rgBeLN2tgEAcQ3JvVwPIf59Y9zYwGJDNCRichPiNH1vYH+ZEAGd5LZQCJTHy4IWeK j4yJK6ivKRY7OheLD1o6qL+4Eyb2/NCk0pzPZ0NafKeN9BQnzjYuWNFs0Q4CGL/HGk CTLgRCj4fqno0BOKT1DZZv7A4Dhr6nbtgjlfDMYU= Received: from michell-laptop.hive.antfield.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 5C2BC441B57; Thu, 15 Nov 2018 10:42:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1542274939; bh=Dkji4JTfOdePjfk92E+wL5e2vsn+se5ApMpIQQk9dpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rgBeLN2tgEAcQ3JvVwPIf59Y9zYwGJDNCRichPiNH1vYH+ZEAGd5LZQCJTHy4IWeK j4yJK6ivKRY7OheLD1o6qL+4Eyb2/NCk0pzPZ0NafKeN9BQnzjYuWNFs0Q4CGL/HGk CTLgRCj4fqno0BOKT1DZZv7A4Dhr6nbtgjlfDMYU= From: Luc Michel To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 10:42:07 +0100 Message-Id: <20181115094207.22846-17-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115094207.22846-1-luc.michel@greensocs.com> References: <20181115094207.22846-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v6 16/16] arm/xlnx-zynqmp: put APUs and RPUs in separate CPU clusters 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: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Create two separate CPU clusters for APUs and RPUs. Signed-off-by: Luc Michel Reviewed-by: Edgar E. Iglesias --- include/hw/arm/xlnx-zynqmp.h | 3 +++ hw/arm/xlnx-zynqmp.c | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h index 98f925ab84..591515c760 100644 --- a/include/hw/arm/xlnx-zynqmp.h +++ b/include/hw/arm/xlnx-zynqmp.h @@ -29,10 +29,11 @@ #include "hw/dma/xlnx_dpdma.h" #include "hw/dma/xlnx-zdma.h" #include "hw/display/xlnx_dp.h" #include "hw/intc/xlnx-zynqmp-ipi.h" #include "hw/timer/xlnx-zynqmp-rtc.h" +#include "hw/cpu/cluster.h" #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp" #define XLNX_ZYNQMP(obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \ TYPE_XLNX_ZYNQMP) @@ -75,10 +76,12 @@ typedef struct XlnxZynqMPState { /*< private >*/ DeviceState parent_obj; /*< public >*/ + CPUClusterState apu_cluster; + CPUClusterState rpu_cluster; ARMCPU apu_cpu[XLNX_ZYNQMP_NUM_APU_CPUS]; ARMCPU rpu_cpu[XLNX_ZYNQMP_NUM_RPU_CPUS]; GICState gic; MemoryRegion gic_mr[XLNX_ZYNQMP_GIC_REGIONS][XLNX_ZYNQMP_GIC_ALIASES]; diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index c195040350..42a138074c 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -176,16 +176,22 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, { Error *err = NULL; int i; int num_rpus = MIN(smp_cpus - XLNX_ZYNQMP_NUM_APU_CPUS, XLNX_ZYNQMP_NUM_RPU_CPUS); + object_initialize_child(OBJECT(s), "rpu-cluster", &s->rpu_cluster, + sizeof(s->rpu_cluster), TYPE_CPU_CLUSTER, + &error_abort, NULL); + + qdev_init_nofail(DEVICE(&s->rpu_cluster)); + for (i = 0; i < num_rpus; i++) { char *name; object_initialize(&s->rpu_cpu[i], sizeof(s->rpu_cpu[i]), "cortex-r5f-" TYPE_ARM_CPU); - object_property_add_child(OBJECT(s), "rpu-cpu[*]", + object_property_add_child(OBJECT(&s->rpu_cluster), "rpu-cpu[*]", OBJECT(&s->rpu_cpu[i]), &error_abort); name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i])); if (strcmp(name, boot_cpu)) { /* Secondary CPUs start in PSCI powered-down state */ @@ -211,14 +217,19 @@ static void xlnx_zynqmp_init(Object *obj) { XlnxZynqMPState *s = XLNX_ZYNQMP(obj); int i; int num_apus = MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS); + object_initialize_child(obj, "apu-cluster", &s->apu_cluster, + sizeof(s->apu_cluster), TYPE_CPU_CLUSTER, + &error_abort, NULL); + for (i = 0; i < num_apus; i++) { - object_initialize_child(obj, "apu-cpu[*]", &s->apu_cpu[i], - sizeof(s->apu_cpu[i]), - "cortex-a53-" TYPE_ARM_CPU, &error_abort, NULL); + object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]", + &s->apu_cpu[i], sizeof(s->apu_cpu[i]), + "cortex-a53-" TYPE_ARM_CPU, &error_abort, + NULL); } sysbus_init_child_obj(obj, "gic", &s->gic, sizeof(s->gic), gic_class_name()); @@ -331,10 +342,12 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", num_apus); qdev_prop_set_bit(DEVICE(&s->gic), "has-security-extensions", s->secure); qdev_prop_set_bit(DEVICE(&s->gic), "has-virtualization-extensions", s->virt); + qdev_init_nofail(DEVICE(&s->apu_cluster)); + /* Realize APUs before realizing the GIC. KVM requires this. */ for (i = 0; i < num_apus; i++) { char *name; object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,