From patchwork Thu Jan 5 16:43:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 639286 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp325560pvb; Thu, 5 Jan 2023 08:57:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXuWbj9uwmLdJH9jrPOwY6+Njsdbbx5/JlHq6Qgo5yM6LyVnJZ8M97/8inl9yc/wt/jGGsUY X-Received: by 2002:a0c:e78e:0:b0:532:1123:4258 with SMTP id x14-20020a0ce78e000000b0053211234258mr4590464qvn.28.1672937839035; Thu, 05 Jan 2023 08:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672937839; cv=none; d=google.com; s=arc-20160816; b=oBU0JjVyJxse1DpA4v6c8n7lTPkynUTBb/3dQdIDZduEP+3Z+iSNdgxa/erlh5jn7N O6+jiIl6p4IxAKWz3sBVi6Derau/eJDx90aNGsDdLW3SvWGtPwI9BUtPcXMO0wHvR19C iSPfvAAfnivZXz10WowrSSc6Hlu2RDxdP2UbGkK8sJt94I8LLK2tQhYvdUZWrUZ+k5g5 cXrtdOVai+rFFVRrtrlJEybVzkjSqwCsD36NpgRHgcVHgYn0O3tXeRnHZSnySRfxg0Wl AnckJVZjthLapV/n9sraxhfO3JKc9QVBvQLYljEQG9bZiNPL00+tEaA1VSrd/fyhMGzN laaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KvmsaKxAU2/5pEbjF5nj04jG9W5Ow7s2kAzsiToIRsM=; b=NvcFlkIII3/+NtJPfoHHd3z2e2TkP9zSA3+w8DIbDT9GS47HplpjPI+gDF6yohRKqe gm04yUzHMG3Xswf0bhLink4ZeXYI7beaO7Vm4zjxKWcl+HEKkkeBPapATV6P7mrP9y+8 fZ7pP8msFPXdFqcEFAyw4lkk0YwbRd+8H7e+46sFAE73Eva3CDts7HyMwNPPcOXP5ohm NMKSwnvfVJiy51S8EK8IZwa2aJCkNleWF/6Qb5Z4g6gy4d/N97gaUwWjsSJJOMiCjpT/ GgwHYqAOafIGJo+f9LakHJVQJYAXh95bKiZUhYrbBGcTFOMWHaXD1bFz0ZQX5iAIhY0Y cFSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m0CniPaq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e2-20020a0562141d0200b004bb67048051si20319813qvd.128.2023.01.05.08.57.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2023 08:57:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m0CniPaq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDTTG-0006vB-Ql; Thu, 05 Jan 2023 11:52:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDTTF-0006uA-Ms for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:52:01 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDTTB-00016h-Dk for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:52:01 -0500 Received: by mail-wm1-x32c.google.com with SMTP id m3so19570135wmq.0 for ; Thu, 05 Jan 2023 08:51:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KvmsaKxAU2/5pEbjF5nj04jG9W5Ow7s2kAzsiToIRsM=; b=m0CniPaqVh4isHJr1TU084TGdYE6FN7Voa0sCesASAj6DSaYGfRQecELC0S1Krav2z 5s9ndZ7N8Tu5KVmd8WxOKKwFJ9NXI+c2Ib8+uP/97ZZkb331GOiy7wDEDg8FN11WcFVg bXzEzr9b12b8fOw7NZGGYfpyqIUpWSLtylyOy+aN1G4Z3/Va6NxdpagPWvZnfR7ihRRZ +V1VzOwXnOV2XyPL7Yxfcsqfnec9KN9dgpVMPY1kXiig797PSE1EIKsAhL+XJ/7IGpxP +aFZKCzzi86jGyOgCYApCiA2JaNINp4Zoi1LHLuqSc/uJUDub55Fh+TLxTzLWJzuqVTL 21HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KvmsaKxAU2/5pEbjF5nj04jG9W5Ow7s2kAzsiToIRsM=; b=m2Gw3Lye5b2urQTv5g6ARj/T0hG2mt7Hvr6ttSxubncQ8jcfEa37kzn9Kmn2KYwkrZ Wt9JrUknHa2oiIlCMQRr4eIBbGZthdeoxJcbAJpc8dP2/JIABnRqALl0DSjihUsKPljV KUlWEUYsO6KL5r7ke8oUBg4aBY8K0tR/FlDawdZAO+6VC6SctPThoPoIhdMCYl5izVIJ UUXNgFkM/xryfEnUt90YoIzFCY786JaW0bFNwxCenxhuP+o94Z2ccow2YIzQW2fFRrSf UQbhoBPj76GhxZiKTP9w+GgT60efmx34zUOf9o3Afyb90cWkSo+1hXQnhrku+QN16Z3y KOQA== X-Gm-Message-State: AFqh2kpPU5fel60pimZqQPsFob7oQbsVV7tVRLUJ9priwjIPGhBQJ6vt SVjsYmIg36dDogFhOcmEhksQHg== X-Received: by 2002:a1c:ed19:0:b0:3d3:52bb:3984 with SMTP id l25-20020a1ced19000000b003d352bb3984mr37898768wmh.17.1672937516079; Thu, 05 Jan 2023 08:51:56 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id az28-20020a05600c601c00b003cf57329221sm3052269wmb.14.2023.01.05.08.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 08:51:55 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5E0131FFC6; Thu, 5 Jan 2023 16:43:21 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org, alex.bennee@gmail.com Cc: David Hildenbrand , Sunil Muthuswamy , Aurelien Jarno , Michael Rolnik , Aleksandar Rikalo , Greg Kurz , Ilya Leoshkevich , Thomas Huth , qemu-ppc@nongnu.org, Laurent Vivier , Max Filippov , Yanan Wang , Marek Vasut , Stafford Horne , Peter Maydell , Daniel Henrique Barboza , Palmer Dabbelt , =?utf-8?q?Alex_Benn=C3=A9e?= , Taylor Simpson , Marcel Apfelbaum , Alexandre Iooss , Chris Wulff , Richard Henderson , Eduardo Habkost , Song Gao , Mark Cave-Ayland , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= , Artyom Tarasenko , Paolo Bonzini , qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Alistair Francis , "Edgar E. Iglesias" , Bastian Koppelmann , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Bin Meng , Mahmoud Mandour , David Gibson , Yoshinori Sato , Xiaojuan Yang , qemu-arm@nongnu.org Subject: [PATCH v2 15/21] gdbstub: introduce gdb_get_max_cpus Date: Thu, 5 Jan 2023 16:43:14 +0000 Message-Id: <20230105164320.2164095-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230105164320.2164095-1-alex.bennee@linaro.org> References: <20230105164320.2164095-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This is needed for handling vcont packets as the way of calculating max cpus vhanges between user and softmmu mode. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- gdbstub/internals.h | 1 + gdbstub/gdbstub.c | 11 +---------- gdbstub/softmmu.c | 9 +++++++++ gdbstub/user.c | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 55f3d820aa..a371373c1d 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -125,6 +125,7 @@ bool gdb_got_immediate_ack(void); CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); int gdb_get_cpu_index(CPUState *cpu); +unsigned int gdb_get_max_cpus(void); /* both */ void gdb_create_default_process(GDBState *s); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 91021859a1..f9950200b8 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -624,16 +624,7 @@ static int gdb_handle_vcont(const char *p) GDBProcess *process; CPUState *cpu; GDBThreadIdKind kind; -#ifdef CONFIG_USER_ONLY - int max_cpus = 1; /* global variable max_cpus exists only in system mode */ - - CPU_FOREACH(cpu) { - max_cpus = max_cpus <= cpu->cpu_index ? cpu->cpu_index + 1 : max_cpus; - } -#else - MachineState *ms = MACHINE(qdev_get_machine()); - unsigned int max_cpus = ms->smp.max_cpus; -#endif + unsigned int max_cpus = gdb_get_max_cpus(); /* uninitialised CPUs stay 0 */ newstates = g_new0(char, max_cpus); diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index c42230acca..015848358a 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -436,6 +436,15 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } +/* + * cpu helpers + */ + +unsigned int gdb_get_max_cpus(void) +{ + MachineState *ms = MACHINE(qdev_get_machine()); + return ms->smp.max_cpus; +} /* * Softmmu specific command helpers diff --git a/gdbstub/user.c b/gdbstub/user.c index 74f541223c..9556a272d7 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -391,6 +391,23 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } +/* + * cpu helpers + */ + +unsigned int gdb_get_max_cpus(void) +{ + CPUState *cpu; + unsigned int max_cpus = 1; /* global variable max_cpus exists only in system mode */ + + CPU_FOREACH(cpu) { + max_cpus = max_cpus <= cpu->cpu_index ? cpu->cpu_index + 1 : max_cpus; + } + + return max_cpus; +} + + /* * Break/Watch point helpers */