From patchwork Fri Mar 3 02:57:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658463 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226228wrb; Thu, 2 Mar 2023 19:01:18 -0800 (PST) X-Google-Smtp-Source: AK7set9SNOMqbwThC/ynjyuqh819f5JEbzjBoF2o++k1jocucTCwnt1w5AYGdmzCZ203rTfiv83f X-Received: by 2002:ac8:4e4a:0:b0:3b9:f4a0:e600 with SMTP id e10-20020ac84e4a000000b003b9f4a0e600mr704716qtw.60.1677812478216; Thu, 02 Mar 2023 19:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812478; cv=none; d=google.com; s=arc-20160816; b=m1LHxNB3TfL1JGxp62FFdO4RyyZpWmRMSSk6SBzLGpbGm5h2m/0QZDBBjtavEcN+8z hwjBFEb4XSwwylnxu78ClqgycZ8TXV5w6H4t4kCzPvu0o+To0HxkGXQ3ncFNAe7qp29v ZaYK4tlcSWeKzFb8rCklqQhqtRv0sx9XDD6+Gk/pOqLgilvBAaA0SnNixYRZu4E3KAib epFYGwFdz5iK96Ll9H3YJOxXulszoNLMYuJPJJlRwBLUbXRJcSpKbNrNuUft6m69Md5A VoMWtBrvpxEoE2lT5Utu83CDF0EXB3GMvmDURgP1o0o1yAP3CNyAGx/hXeA46T9sPtDI Y04w== 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=3WIxe+smKoqvvD+KwVzWzoBm2ZPTc7NcUurnb42ciEE=; b=0RJIg00y/BLwJT+k/hiSB5cxap6R4zeMUcvwTCmvvhvuCzC7/MF8ek7vNztAEH4Kq4 sfH16hcUrcrmJKKevusAr9TS0Z80XlGO+L7CVzS2oLqtodjUvES7zkpKdLRjLYHu7otK RB8kjKgxlqQpP1VRonzSqEGz6i7b8aCo9ARQ2JTDz0D0vWkJ6pxx79Te5Aqbjy5R3h8J 4FDl33FEWu2iiEmy1h7gAG1uxPaHgF0/MP/G5NlaNfstagBNOgRQUnt5s2xl+ldQf3r2 SPZnrVVIgPOqHT0vgYKJeKKgiBwtOJlsaVqEFI1oWkXls6F48mFcH7RXTTmRZJbKJ+fN t1Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KksIPJN2; 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 b15-20020ac801cf000000b003b68cf4ae53si878532qtg.505.2023.03.02.19.01.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:01:18 -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=KksIPJN2; 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 1pXvco-0007WE-MB; Thu, 02 Mar 2023 21:58:26 -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 1pXvcl-0007Ua-E0 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcj-0001ou-MD for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: by mail-pj1-x1031.google.com with SMTP id x34so1210009pjj.0 for ; Thu, 02 Mar 2023 18:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812301; 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=3WIxe+smKoqvvD+KwVzWzoBm2ZPTc7NcUurnb42ciEE=; b=KksIPJN2jDvsGZjjtxBd96APwfcAAkQTUQzr5RgyG8to8hnhVD8BrCWSKVulK20iQP f+BmpEiWOKM11NT1kWWYWJjFQtBvK+ubSTe0uwRVxU+tWNEnNML8Y8w5qgumyE1e4Jpt oC09KQaZM1WzOLHF6iuiiWVAECsz4krJj9tpXl4HzWJqBwRt73fE1GvM/fExZA2HGdWC 3zs79m+Rtz1Idl8ezm1DpwcDtRPEnNzCZ1xW+6WwL2rQyB19Ez+bxBW9Ji+HvdWRkFI1 mVYPdzPFOMFklEo1D8XOWNWVf1MgakrDNT+3ogxZTKwzxz+KMcCdquMEx0YKftNDCIxd 56jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812301; 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=3WIxe+smKoqvvD+KwVzWzoBm2ZPTc7NcUurnb42ciEE=; b=V3ekmxUJeY8eYz4/DEQcnA6ad1l3M0jAFPURhz81RswLEPcmuiDVpUfPtt48DMpTbL vJFdVT9cxJrxQPpgFd6OPM1UZLx2PGHA6kLWH4LLN5c/R7268bx93GcAGUv2wpjiw5A+ p1UkU8wwTfCLLHOHyzbWV1P1gkQ+A0p4HXszSRzXtXnKSZszvYFg5IFTWbRkqq4GDxmK CVaDH2w3RezA6IJL/d/dhCnsNqjUW85e+MoXHQJxUVscKD4FGzivAVxPmKqQ2fhtkYXN ZC4bdoBkqqi8mn5Sr5sMyuV7wOdmjeRp5s9yw41SoZVgcX7n2F2elmc7p5MNn5QBEHB6 4lVw== X-Gm-Message-State: AO0yUKVlZAqLsP2iIgKmI2jzpAl4aqId82rEAuVo2wVtfLH4qoGos0Z4 cBRn0IUNtXH0vjnBWELTs04AU9EmIBB0Tjmimbo= X-Received: by 2002:a17:903:1d2:b0:19c:be07:4af2 with SMTP id e18-20020a17090301d200b0019cbe074af2mr594838plh.45.1677812300880; Thu, 02 Mar 2023 18:58:20 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 16/29] gdbstub: introduce gdb_get_max_cpus Date: Thu, 2 Mar 2023 18:57:52 -0800 Message-Id: <20230303025805.625589-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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 From: Alex Bennée 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> --- 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 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 */