From patchwork Mon Feb 26 16:56:23 2024 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: 775901 Delivered-To: patch@linaro.org Received: by 2002:ab3:621a:0:b0:258:3251:9e33 with SMTP id w26csp1481447lte; Mon, 26 Feb 2024 09:08:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX+Gu4BBZWp6HWH3yczYVoNBpAJ8OVj8UCwC4oY66p3x958/8Nd79IQN6t+jaqWLpRgJO+CIxtUYcKKrcsfbZWS X-Google-Smtp-Source: AGHT+IE9vlJPFtN29HvvWDCViEWyb/8mBafPvij7N0Ov6hUOfB06Dfm3OTKFNPC+VE4ljL6mg5yb X-Received: by 2002:aca:220a:0:b0:3c1:78c2:22f9 with SMTP id b10-20020aca220a000000b003c178c222f9mr6633603oic.25.1708967330358; Mon, 26 Feb 2024 09:08:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708967330; cv=none; d=google.com; s=arc-20160816; b=wmvZLAb0mr+Fm3ohmYQJSnGoKWvjFW/9rn52Pe7acTW7PRF4ETHYPQUn/tGVQSRMb9 t+7uKXYtr0CoQ04ZdGBDRN6WtjUmI1WQAOvfnfAiB9aKe6MEzBCFQCnSuB58Csd0oTm9 3dYgRGcBoMd+lfDQ7PCVQV91G5fO8ips93mwszjNTxupjGzPTfQxw+JpX5zmayM/R+RZ CdtDczht1nQiqEe8k97mQozOaX1nKzs1587CMmyuklsgUjY7JXZ48+Xe4YkRLrlL50EH d8fHo+dUNtx0hyraMYNC7btVaMcI6oUUHLl17n+jsGw1Q496uFBzFLcTvzWZ8EeuFYc2 LWzg== 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=/6OMZ0loRFGpvJj8x2xSy3ZdDA+ZTmmsIgUpBxK3Sio=; fh=inHz/qE9VTgeXyA0ge5D6fVYa/Mfhts5ntNvtYndEVE=; b=f5lD3JbtsVF5BkpTwZX/2X4GFXvV0bSjSggdwFTgNcknzGFfII7K/7Mf0YmclIbRcx dH1VCTTDoPp0A4z0d6uqPp+gavSeN/KuY1Y2al9Z0rP7AbjMs3Y7slU+I/qs8ylOQcBs xT3Ztm5Wth/1qwg8OyCJdDaVCun0+BMQwRRutIvnZnjomZmVWo47wBd1j9iuQRxHy1gv VdN517+5l+yk8fB0ikls1UT/XdVBRB1zFX9mxfRYVDvPrZG3lrvstFghOkymkHu/u06C 2fZ9U+HgfjklIMzKZiZZfAYI7L4sGr5QYxQ/9rNtXniAHyhlAfTYIPoD8tu23NpNDJqc Yr1A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ovqHkjBl; 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 ic4-20020a0561024b8400b00466e0d8a2cesi791693vsb.162.2024.02.26.09.08.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Feb 2024 09:08:50 -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=ovqHkjBl; 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 1reeIH-0005x6-Oz; Mon, 26 Feb 2024 11:57:33 -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 1reeHv-0005cb-Di for qemu-devel@nongnu.org; Mon, 26 Feb 2024 11:57:11 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reeHb-0007c3-UZ for qemu-devel@nongnu.org; Mon, 26 Feb 2024 11:57:10 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33dd2f0a0c4so962093f8f.0 for ; Mon, 26 Feb 2024 08:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708966610; x=1709571410; darn=nongnu.org; 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=/6OMZ0loRFGpvJj8x2xSy3ZdDA+ZTmmsIgUpBxK3Sio=; b=ovqHkjBlWJNm/dAKJxYpC+A6nvh8HdFyyZmgXoa3UeMYz7bDsoiIvKTPZAkgiHr4cI o9yCEpCEjsI3zLUMSi5jNlrOqNa7uL9onDpV7S/e4HOIlLlrW/7z6/5UJEdH1qjQO66l 4pmEs3uV+PEFlwfeMdK5ZPURgVKIPXwtP0Rac1kObc6Af9NB4f0zhP0HtJ70buvmlaCV k/O5+/7LKQzLJzVlD39pn0HURdjU+2Xde9Ns9flF++q0pIlzp7krcAz1p4Sfi0K5sEtx gPJbzcFVAV/LIELVBVA+G0n/rr+/VufHdDcvJpV1MORg8C2fjlIEAX28WsqarZ6KGGym eqPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708966610; x=1709571410; 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=/6OMZ0loRFGpvJj8x2xSy3ZdDA+ZTmmsIgUpBxK3Sio=; b=sYhEkwZIvA8cgthQ6JT7CgRvCDh1W5N5PHasUe/tPU6gxxdtjVLSBNfXD1mresgXhx JtQ9fNobia9uNpE6lWSNBKJBDszuEvXZDQzfobk7tbzJCvosXlUOHXPR9e4Gkiv6OnFQ ZbVISNjNDMaqL23ob411qjtCKZFwu/YT/TahIt22OReFjEIukiL0HbM7/PjFaevs/8cy 5WaKbFZUjuZcJ5su5eyNoLjUkdna13S+31Vs4IKndlTdr40e0v5UHTf5aZYsQB8CqdAR rzp4krq8DBaWUPXBZu5NmBsdbdhntUaHCTUtz6fTpIlISsws+ZTTtdYtMfAoQcFhuLQy 4cOg== X-Gm-Message-State: AOJu0YwXOc6ogMHDLyPAcisR15h6U5oGxXR1c+yg6mCnf+UVrziwprrF yh63N3uSf2LuSJBg4kW/8BmqbUi5GzoM1QH4aazXJLrpn8R8pVnVGPigSbQ2djk= X-Received: by 2002:adf:fc01:0:b0:33d:a185:17ed with SMTP id i1-20020adffc01000000b0033da18517edmr4554880wrr.56.1708966610090; Mon, 26 Feb 2024 08:56:50 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bx27-20020a5d5b1b000000b0033daa63807fsm8976587wrb.24.2024.02.26.08.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:56:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 15E7F5F904; Mon, 26 Feb 2024 16:56:47 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Liu Zhiwei , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-riscv@nongnu.org, Michael Rolnik , Song Gao , Alexandre Iooss , Marcel Apfelbaum , David Hildenbrand , Pierrick Bouvier , John Snow , Eduardo Habkost , Mahmoud Mandour , qemu-arm@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Cleber Rosa , qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Yoshinori Sato , Yanan Wang , Brian Cain , Ilya Leoshkevich , Weiwei Li , "Edgar E. Iglesias" , Bin Meng , Laurent Vivier , Palmer Dabbelt , Daniel Henrique Barboza , Alistair Francis , Akihiko Odaki Subject: [PATCH v3 04/27] target/ppc: Use GDBFeature for dynamic XML Date: Mon, 26 Feb 2024 16:56:23 +0000 Message-Id: <20240226165646.425600-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240226165646.425600-1-alex.bennee@linaro.org> References: <20240226165646.425600-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Akihiko Odaki In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Richard Henderson Message-Id: <20240103173349.398526-28-alex.bennee@linaro.org> Message-Id: <20231213-gdb-v17-2-777047380591@daynix.com> Signed-off-by: Alex Bennée --- target/ppc/cpu-qom.h | 1 + target/ppc/cpu.h | 4 +--- target/ppc/cpu_init.c | 4 ---- target/ppc/gdbstub.c | 51 ++++++++++++++++--------------------------- 4 files changed, 21 insertions(+), 39 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 0241609efef..8247fa23367 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -20,6 +20,7 @@ #ifndef QEMU_PPC_CPU_QOM_H #define QEMU_PPC_CPU_QOM_H +#include "exec/gdbstub.h" #include "hw/core/cpu.h" #ifdef TARGET_PPC64 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index ec14574d142..c66989a5e60 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1492,8 +1492,7 @@ struct PowerPCCPUClass { int bfd_mach; uint32_t l1_dcache_size, l1_icache_size; #ifndef CONFIG_USER_ONLY - unsigned int gdb_num_sprs; - const char *gdb_spr_xml; + GDBFeature gdb_spr; #endif const PPCHash64Options *hash64_opts; struct ppc_radix_page_info *radix_page_info; @@ -1546,7 +1545,6 @@ int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); #ifndef CONFIG_USER_ONLY hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu); const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name); #endif int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 9bccddb350c..5f0ecf443d8 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6682,10 +6682,6 @@ static void init_ppc_proc(PowerPCCPU *cpu) /* PowerPC implementation specific initialisations (SPRs, timers, ...) */ (*pcc->init_proc)(env); -#if !defined(CONFIG_USER_ONLY) - ppc_gdb_gen_spr_xml(cpu); -#endif - /* MSR bits & flags consistency checks */ if (env->msr_mask & (1 << 25)) { switch (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) { diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index dfe31d0f47f..c4c55961083 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -300,15 +300,23 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cs, uint8_t *mem_buf, int n) } #ifndef CONFIG_USER_ONLY -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) +static void gdb_gen_spr_feature(CPUState *cs) { - PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); + PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; - GString *xml; - char *spr_name; + GDBFeatureBuilder builder; unsigned int num_regs = 0; int i; + if (pcc->gdb_spr.xml) { + return; + } + + gdb_feature_builder_init(&builder, &pcc->gdb_spr, + "org.qemu.power.spr", "power-spr.xml", + cs->gdb_num_regs); + for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { ppc_spr_t *spr = &env->spr_cb[i]; @@ -326,35 +334,13 @@ void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) */ spr->gdb_id = num_regs; num_regs++; - } - - if (pcc->gdb_spr_xml) { - return; - } - xml = g_string_new(""); - g_string_append(xml, ""); - g_string_append(xml, ""); - - for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { - ppc_spr_t *spr = &env->spr_cb[i]; - - if (!spr->name) { - continue; - } - - spr_name = g_ascii_strdown(spr->name, -1); - g_string_append_printf(xml, ""); + gdb_feature_builder_append_reg(&builder, g_ascii_strdown(spr->name, -1), + TARGET_LONG_BITS, num_regs, + "int", "spr"); } - g_string_append(xml, ""); - - pcc->gdb_num_sprs = num_regs; - pcc->gdb_spr_xml = g_string_free(xml, false); + gdb_feature_builder_end(&builder); } const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) @@ -362,7 +348,7 @@ const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); if (strcmp(xml_name, "power-spr.xml") == 0) { - return pcc->gdb_spr_xml; + return pcc->gdb_spr.xml; } return NULL; } @@ -635,7 +621,8 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc) 32, "power-vsx.xml", 0); } #ifndef CONFIG_USER_ONLY + gdb_gen_spr_feature(cs); gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, - pcc->gdb_num_sprs, "power-spr.xml", 0); + pcc->gdb_spr.num_regs, "power-spr.xml", 0); #endif }