From patchwork Tue Mar 7 21:21:25 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: 659868 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2608535wrb; Tue, 7 Mar 2023 13:31:10 -0800 (PST) X-Google-Smtp-Source: AK7set/AOBQ6ob8gvO5DMGR2w3Hg8PblmkBLAnzFGh5OhJcOULYsvkmhiI7uFUkEjBeXLZB6Ky3r X-Received: by 2002:a05:6214:d49:b0:570:6deb:c284 with SMTP id 9-20020a0562140d4900b005706debc284mr29154869qvr.22.1678224670021; Tue, 07 Mar 2023 13:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678224670; cv=none; d=google.com; s=arc-20160816; b=DCYfqtP2hJuKZwGmGSNyE73AIhK78L0sPsZHIa3zLiIdwLlQQ6fzRaCrUglMMROUTt WP5uGM4T7RPJTQLewE5GAE815R03faNW9k8+J0qOOcG5FiBqnUBcRvsI+tp3sFcZzUwD fwkk08dXnlxQiJ8e7q6FZCC3+vwjDt8P+pugFh7+M2t68iCL6Zac0GAG8ahf9sjR9Mep d7FH4ZqvQhtn6/RWM22fiWnA8S2KxOMsmfEYsEk06LjEoqndCDuLwymDg8Wstuacklcf KuDpx4ilRE6vC4bvqh3bTxeUlrHg1nqOsrUo/HVBt//MYfv6Jg7t3mZwdB3cXnwk+BDT gv9g== 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=XLOB2+PFvPgJsQrZslVnHnvebb88TMXYYzglXLeqcS8=; b=malq/7QMGsdFI3xbBrqtoc0XHclDsr/bqvfWpsM1lSFdjnODLwo3VJ2bezEWyNt6RF dAApE+EFEeFS+s/LWb8ewujkawOrl0/KCYBv05aD7jbOOetsPjEvrcXiamYDMdLtpt1z Mp7othlDSJJS7Id9XPnbOCQsPhNWM0pC1DBH/EJS6HfltfAytqpVi5hVn2mrUsiDx4ZC gWmZvcHIZfYFl9mQ5Y43tiP7iyqZk8XtLpIEwqa179p1CtjYahYHaRq9VeftahbWYdMF 86/9L6HjUXHUKtW4Mr50EyvtnwiUCo/9r1uSd+xmM8ZNJgimmxmEVXFcFc4p/HWcf84v 4J5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KmnPUjoz; 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 s16-20020a05620a255000b00733219d3e01si3443192qko.380.2023.03.07.13.31.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Mar 2023 13:31:10 -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=KmnPUjoz; 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 1pZesB-0004hd-4F; Tue, 07 Mar 2023 16:29:27 -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 1pZes9-0004gX-OI for qemu-devel@nongnu.org; Tue, 07 Mar 2023 16:29:25 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZes7-0000vG-4T for qemu-devel@nongnu.org; Tue, 07 Mar 2023 16:29:25 -0500 Received: by mail-wm1-x336.google.com with SMTP id o11-20020a05600c4fcb00b003eb33ea29a8so18072wmq.1 for ; Tue, 07 Mar 2023 13:29:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678224562; 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=XLOB2+PFvPgJsQrZslVnHnvebb88TMXYYzglXLeqcS8=; b=KmnPUjoznmoBpLpN84K6aHA9TJ1iIGD+inL8IhkPeX4FlTgEPTMNHrVrUuL9Bv0BXu Gs3FwENIwX7xIjUFnaKSm3EUfrh/NzGZCHNaOMoRE78vJ9h6KCrSDjFQecK24BRLGPmI oAg5gwT2KRk+GmyTSa9AK3JVfQbEzBaCSgsMGGUP1gtqij8jD3PJOkGzk80BASmBDy4q SqdiqLxfBE8Rbpcl4oWw0LmjlPPuc9ZRvPk+sXRXFQyzspiwssaSnbIC7LfYtkvL3lPM IYk5KhuOjmL7KGBkq6gxdZtFYVbGh+7vh5uZdbZXUd2nyHsUJxZaT+Il4zOzAHWZIk+G yEMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678224562; 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=XLOB2+PFvPgJsQrZslVnHnvebb88TMXYYzglXLeqcS8=; b=bLMo0hmkULz/VghulB/r/25G8XnpV6FKpf5bZbeWZYn9/MTvlwRjhk09be8tb2ZV5W jOdAJ+gJkJQn4Vh184Cm9Qn40kb0hO6/mmZgmWoBFtj261N7vFeuR9E8BwdoofFUc/iv /m5+AubAi8hJXgeDICJy85hwOlDYeyUYSUFJGb8+bGZtjjklfZi48TreRjslYcfmYoJl GhXR1R/SUV2QVAntf4c45I34RfrViDY50FfsOkoH73Q6zCuFsrJlgddsBuLziugCR8nn d+E64QFR7hLxt/nIBPb2Exii2JrktYW9IPT5muOOPCHyFBEZYqWtvpMiuCPY4iCsCCkg hdXw== X-Gm-Message-State: AO0yUKWzQD0qygBAHRMlYraeYylb8GnX8mp01wbXnKAFB6MWZAMaklFs N9beo07QTuYRkj87nx2D/wgmZLZUgiWG15jPRHc= X-Received: by 2002:a05:600c:46c6:b0:3e2:1368:e395 with SMTP id q6-20020a05600c46c600b003e21368e395mr13965198wmo.33.1678224561758; Tue, 07 Mar 2023 13:29:21 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id q18-20020a5d5752000000b002ce3d3d17e5sm12220587wrw.79.2023.03.07.13.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 13:29:20 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 441421FFC5; Tue, 7 Mar 2023 21:21:41 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PULL 16/30] gdbstub: introduce gdb_get_max_cpus Date: Tue, 7 Mar 2023 21:21:25 +0000 Message-Id: <20230307212139.883112-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307212139.883112-1-alex.bennee@linaro.org> References: <20230307212139.883112-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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=ham 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. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-17-alex.bennee@linaro.org> Message-Id: <20230303025805.625589-17-richard.henderson@linaro.org> diff --git a/gdbstub/internals.h b/gdbstub/internals.h index d8c0292d99..26a6468a69 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -129,6 +129,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 ed38ab0aaa..1b783100c2 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 ab2d182654..3a5587d387 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -440,6 +440,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 92663d971c..e10988a62b 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -393,6 +393,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; + + CPU_FOREACH(cpu) { + max_cpus = max_cpus <= cpu->cpu_index ? cpu->cpu_index + 1 : max_cpus; + } + + return max_cpus; +} + + /* * Break/Watch point helpers */